7 Design Craigslist

 

This chapter covers

  • Designing an application with two distinct types of users
  • Considering geolocation routing for partitioning users
  • Designing read-heavy vs. write-heavy applications
  • Handling minor deviations during the interview

We want to design a web application for classifieds posts. Craigslist is an example of a typical web application that may have more than a billion users. It is partitioned by geography. We can discuss the overall system, which includes browser and mobile apps, a stateless backend, simple storage requirements, and analytics. More use cases and constraints can be added for an open-ended discussion. This chapter is unique in that it is the only one in this book where we discuss a monolith architecture as a possible system design.

7.1 User stories and requirements

Let’s discuss the user stories for Craigslist. We distinguish two primary user types: viewer and poster.

A poster should be able to create and delete a post and search their posts as they may have many, especially if they were programmatically generated. This post should contain the following information:

  • Title.
  • Some paragraphs of description.
  • Price. Assume a single currency and ignore currency conversions.
  • Location.
  • Up to 10 photos of 1 MB each.
  • Video, though this may be added to a later iteration of our application.

A poster can renew their post every seven days. They will receive an email notification with a click-through to renew their post.

A viewer should be able to

7.2 API

7.3 SQL database schema

7.4 Initial high-level architecture

7.5 A monolith architecture

7.6 Using an SQL database and object store

7.7 Migrations are troublesome

7.8 Writing and reading posts

7.9 Functional partitioning

7.10 Caching

7.11 CDN

7.12 Scaling reads with a SQL cluster

7.13 Scaling write throughput