chapter seven

7 Design Craigslist

 

This chapter covers

  • Designing an application for where there are 2 distinct types of users.
  • Considering geolocation routing to partition users by geography.
  • Designing read-heavy vs write-heavy applications.
  • 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 over 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 also unique in that it is the only system 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 2 primary user types - viewer and poster.

A poster should be able to create and delete a post, and search her posts as she 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. 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 her post every 7 days. She will receive an email notification with a click-through to renew her 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 a 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

7.14 Email Service

7.15 Search

7.16 Removing old posts