Bugpit

Lessons › From one user to millions

Pay for nothing when nobody comes

A side project with 20 requests a second at its busiest, and almost nothing overnight. Two servers sit idle for most of the day, and you pay for every hour of it.

Play this level

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

The lesson

A server costs the same whether anyone uses it or not. A function like AWS Lambda only charges when it runs: $0.20 per million calls, plus time and memory.

The catch is the first call. A function that isn't running has to start: AWS says cold starts typically hit under 1% of calls, and last from under 100 ms to over a second.

1% sounds small until you notice that's right where p99 sits. When cold starts reach 1 call in 100, your p99 is a cold start.

You can keep functions warm and pay for them even when idle, which is how you end up paying for a server again.

What you have to achieve

20 requests a second at the busiest hour, 10% of them writes.

What you learn

The machine bill dropped to the database alone, and p99 jumped: that's the cold start. For a quiet app that's a great trade. Turn up the traffic in Free design and you'll find the point where a plain server gets cheaper again.

Check yourself

Why did serverless suit this app?

Show the answer

You only pay when it runs, and the app is mostly idle. A server costs the same when idle. Functions charge per call, which wins for quiet apps.

Why did p99 jump after the switch?

Show the answer

Cold starts land right where p99 sits. When about 1 call in 100 is a cold start, your slowest 1% are the cold starts.

Try it yourself

More in From one user to millions

← Five million people online Ask in plain words →