SD-2 · CHAT APP · INTERACTIVEBreak it.
Break it.
Then fix it.
Connect a million phones, watch messages go missing or arrive out of order, and add the parts a real chat app needs. Every switch is a decision you would defend in an interview.
CHALLENGEDeliver every message to 1M connected phones, in order, with p99 under 200 ms and none lost.
StatusDOWNAt 100K connected phones
p99 delivery40 msTarget under 200 ms
Lost messages5%Messages being dropped
Monthly cost$1,5504 gateways · 1 chat server
PhonesLIVE
100K connected · 2.0K msgs/straffic source
Gateways × 4OK
Hold open WebSockets100K conns · 40K msgs/s
Chat serverOK
Stateless2.0K / 5.0K ops/s
Message storeOK
Writes only0 reads · 2.0K writes/s
Messages to offline phones vanish. About 5% of deliveries find the phone offline. Keep their messages and retry until the phone acknowledges them.
1MOpen connectionsPolling instead would mean 500K “anything new?” requests a second.
5×Fan-outEach message is delivered to about five phones.
1Writer per chatOrder comes from one place: the chat’s partition in the log.
5%Deliveries to offline phonesThose messages wait in an inbox until the phone reconnects.
Want the reasoning behind every switch?Visual walkthroughFull write-up
Was this lab useful?Your vote tells us what to improve next.