What Upsun does automatically
On Upsun, we calculate your worker count automatically using this formula:When the defaults don’t fit
If you’re running Magento, 45MB per request might not be enough - you’re going to run out of container memory before you run out of workers. Your metrics will show 100% memory utilization and Out Of Memory kills. If you’re running a lightweight API, you might only need 4MB per request. The system is assuming 45MB, so you’re underutilizing your memory and running fewer workers than you could support. This is when you want to adjust sizing hints.Understanding sizing hints
Sizing hints are exactly that: hints. They’re not limits or restrictions. They tell Upsun how to calculate the number of workers to allocate. You configure them in your.upsun/config.yaml:
request_memory: 35 instead of 45, you get more workers for the same container size.
Some people get this backwards and think “more is better.” It’s not. Lower request memory tells the system “my requests are lighter, I can support more workers.”
Finding your actual memory usage
You can check how much memory your requests actually use by analyzing your PHP access logs:request_memory value (converted to MB).
This isn’t an exact science. Not all requests use the same memory. Some take 40MB, some take 20MB, some take 100MB. You’re not utilizing all workers at the same time. The goal is to find a reasonable average that keeps your memory utilization under 100% while maximizing worker availability.
Tuning in small increments
If you decide to adjust sizing hints, do it gradually:- Start with your current value (default is 45MB)
- Lower it by 10MB (to 35MB)
- Check your metrics - are you still under 100% memory utilization?
- Wait a day and verify the system is stable
- If you need more workers, lower it another 10MB
- Repeat until you find the right balance
CPU limits and worker caps
To ensure that Upsun doesn’t add more workers than the CPU can handle, a CPU limit applies as soon as the number of set workers equals or exceeds 25. This limit is calculated as: number of vCPU cores × 5. For example, with 8 vCPUs, you can have a maximum of 40 workers (8 × 5 = 40) - even if you have enough memory to support more. Why? Because the CPU has to switch between all these processes. If you give it too many workers, context switching overhead becomes a problem. When 8 vCPUs are juggling 40 different tasks (5 per vCPU), they’re already working hard. Going beyond that makes things slower, not faster.Sizing hints vs memory limit
Let’s clarify the difference between sizing hints and PHP memory limit, since they’re often confused: Sizing hints (request_memory, reserved_memory):
- Used to calculate worker count
- Not enforced as limits
- Hints for capacity planning
- Lower values = more workers allocated
- Enforced per-request by PHP itself
- Kills requests that exceed the limit
- Protects the container from runaway processes
- Logs violations for debugging
request_memory: 45 but one request uses 50MB, nothing bad happens. The sizing hints are averages, not hard limits.
If you set memory_limit: 128M and a request tries to use 200MB, that request gets killed. See our article on why you shouldn’t set your PHP memory limit to 60GB for more details.
Finding the right balance
When you understand what these settings actually do, you can tune them appropriately for your application. The goal is to find the sweet spot where:- Your workers have enough memory to handle typical requests
- You have enough workers to handle concurrent traffic
- Your memory utilization stays under 100%
- Your CPU isn’t overwhelmed by context switching