Bugpit

Lessons › From one user to millions

Five million people online

Your chat app has 5 million people online at the peak. They make 5,000 requests a second, and 1,500 of those are new messages. Every one of them holds a connection open, even when nobody's typing.

Play this level

Free with an account. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

A normal request comes and goes. Chat, live scores and notifications need the server to speak first, so each user keeps a WebSocket open. The limit stops being requests per second.

Here the limit is how many stay connected. API Gateway closes a WebSocket after two hours, and by default allows 500 new connections a second. That's about 3.6 million open at once: AWS's own worked example.

You also pay for silence. At $0.25 per million connection minutes, a user sitting idle costs more than the messages they send.

If the 500 limit is too low you can ask for more. This level uses the default, so run a second gateway.

What you have to achieve

5,000 requests a second at the busiest hour, 30% of them writes.

What you learn

Look at Monthly cost: most of it pays for connections that sit quiet, not for messages. At this size it's often cheaper to run your own WebSocket servers, and that's a real trade: more to run, less to pay. Worth checking before you build.

Check yourself

In a chat app, what becomes the limit instead of requests per second?

Show the answer

How many people stay connected. Each user holds a WebSocket open, even when quiet. Open connections are the scarce thing.

What did most of the bill pay for?

Show the answer

Connections that sit quiet. At $0.25 per million connection minutes, an idle user costs more than the messages they send.

Try it yourself

More in From one user to millions

← When one service takes you down Pay for nothing when nobody comes →