Skip to content

Design a Product Analytics System, stage 3 of 9: break it

The database is down for twenty minutes

Today the capture API inserts each request's events straight into the database. Twenty minutes at peak is about 100 million events.

System so far· 6 parts
1234CLIENTCustomers' appsEDGECapture APIDATABASEEvents(column store)DATABASEPostgresSERVICEQuery serviceCLIENTCustomers'dashboards

Select a component to see what it is responsible for and which state it owns.

  1. 1Customers' apps → Capture API: Batches of events
  2. 2Customers' dashboards → Query service: Chart request
  3. 3Query service → Postgres: Teams and saved charts
  4. 4Query service → Events (column store): Aggregate by column

What you need to know

0 of 2 checks done
  1. Events arrive at a rate you don't control; the database absorbs them at a rate that varies, sometimes zero during an upgrade. A durable log (a stream like Kafka) between the two lets each run at its own pace. See Append-only logs.

    The capture API's job shrinks to: check, stamp, append to the stream, acknowledge.

  2. Work it out

    The database is down for 20 minutes at a peak of about 90,000 events a second. Roughly how many million events must be held?
    million events