Compute
Compute decides how much traffic your server can handle and how fast it responds under load. Your server runs as one or more podlets, which are running copies of your server. Serverpod Cloud adds podlets when load rises and removes them when it falls, within a range you set.
How compute works
Two settings make up your project's compute:
- Podlet size: How much memory and CPU each podlet has. All podlets in a project are the same size.
- Autoscaling range: The fewest and the most podlets your project runs, set as Min podlets and Max podlets.
Each podlet size has this much memory, and larger sizes also get more CPU:
| Podlet size | Memory |
|---|---|
| Small | 256 MB |
| Medium | 512 MB |
| Large | 1 GB |
| XL | 2 GB |
| XXL | 4 GB |
On Starter, compute is fixed at one small podlet that scales to zero when idle. On Growth, you choose the size and the range. The pricing page lists what each size costs.
When to change compute
The size and the range solve different problems:
- A larger size: For a server that runs out of memory or responds slowly even when traffic is low, such as one that processes images or keeps large data sets in memory.
- A higher Max podlets: For traffic that comes in peaks. Serverpod Cloud adds podlets during a peak and removes them afterward.
- A higher Min podlets: For traffic that rises faster than new podlets can start. The podlets you keep running are ready when the rise begins.
- Min podlets of 0: For projects with quiet periods. The project scales to zero when nobody uses it.
If you set Max podlets above 1, each podlet has its own memory. A value your server stores in a local cache stays on the podlet that stored it. To share cached values across podlets, use the global cache and connect your project to Redis. Without Redis, server events also reach only the podlet that posts them. The framework's Scalability page covers what else changes when your server runs as several copies.
Check your project's compute
To see your project's current compute, open its Settings in the Serverpod Cloud console. The Compute card in the Plan section shows the podlet size, its memory, and the range of podlets the project can run, such as 0-1 PODLETS.
From the terminal, run serverpod cloud project show in your project's directory. The Compute row shows the podlet size, its memory, and the range, such as 0-1 podlets.
Change the podlet size and autoscaling range
In the Serverpod Cloud console, open your project's Settings and select Edit plan. Set Podlet size and Autoscaling range in the Compute section, then select Save. The Cloud CLI can't change compute.
The change usually applies within a minute or two, and your server restarts once.
On Starter, the console shows Upgrade plan instead of Edit plan, because Starter's compute is fixed. To choose a size or a range, select Upgrade plan and move the project to Growth.
Only the project's owner can change compute. For anyone else, Edit plan is dimmed, and hovering it shows who the owner is.
Cost and limits
- Billed per minute: On Growth, each podlet is metered per minute while it runs, so a project at zero podlets adds no podlet cost. The pricing page lists the price of each size.
- Up to 20 podlets: On Growth, Max podlets goes up to 20.
Related
- Plans and billing: the plans, and how to move a project between them.
- Scale to zero: how a project with Min podlets set to 0 stops when idle and wakes on the next request.
- Use Redis for pub/sub and caching: sharing a cache and server events across podlets.
- Scalability: what changes in your server code when it runs as several copies.
- CLI reference:
projectcommand: theproject showcommand and its options.