Contents
- Start with the requested service and its problem
- Get a comparable baseline instead of a random snapshot
- When data indicates a memory shortage
- When processor capacity is the bottleneck
- Cgroup, VM, and shared host change available budget
- Application concurrency links RAM and CPU
- Verify the increase as a controlled experiment
- Describe the result according to the evidence.
- Frequently asked questions
Start with the requested service and its problem
More RAM or CPU makes sense when it solves a confirmed resource shortage. So the first question is not “what percentage is the dashboard showing,” but what has deteriorated: website responsiveness, batch job time, error rate, or availability. Note when the problem occurs and whether it is related to the number of requests, the size of the data, or a specific scheduled run.
The same workload can have different meanings. A computation can properly utilize all cores without service disruption. A high RAM utilization can be a useful cache. Conversely, a low average CPU can hide a single bottleneck thread or a long wait for a remote database. Therefore, capacity decisions need several related metrics and a reasonable time window.
First, consider other limits: disk, I/O, network, database lock, external API, or application-specific limitations. Adding RAM will not fix an invalid DNS record, and additional CPU will not speed up a request that is waiting for a one-minute timeout for an unavailable service. The upgrade should have a documented expected improvement mechanism.
Get a comparable baseline instead of a random snapshot
Measure both normal and actual peak traffic. Record the number of logical CPUs, memory available within the system, and important service limits. A container or VM may not have what the entire host offers. When planning, at least consider the period in which a problematic task or expected peak traffic will occur.
date -Is
nproc
lscpu
free -h
swapon --show
uptime
vmstat 1 10The first line of vmstat may summarize a different time range than the other interval samples. Do not confuse a long-term average with a current peak. A short ten-second series is a guide, not a full capacity audit of a site with a daily cycle. If the necessary history is not available, note this limitation and prepare targeted measurements.
For application metrics, track not only the average, but also the slow portion of requests, the queue, and errors as needed. A change that increases the number of successfully completed requests but dramatically increases the wait time may not achieve the desired goal. Define up front what behavior you consider acceptable.
When data indicates a memory shortage
Monitor MemAvailable, active pressure, swap transfers, and any OOM events. A small value of completely free RAM does not necessarily mean a problem: Linux also uses memory for cache. MemAvailable is an estimate of usable capacity for further work without the need for similar swapping, not an absolute guarantee that every requested allocation will succeed.
grep -E "^(MemTotal|MemAvailable|SwapTotal|SwapFree|Dirty|Writeback):" /proc/meminfo
cat /proc/pressure/memory
sudo journalctl -k --since "-2 hours" --no-pagerA busy swap is not automatically evidence of a current problem. Previously swapped, infrequently used pages may remain in swap even after the pressure is over. More important is the active move, memory pressure, and response impact. Manual swapoff alone can introduce new RAM demands and is not suitable as a cosmetic graph reset.
More RAM can help when the working set and necessary concurrency are demonstrably outgrowing the available budget, or when useful cache is repeatedly squeezed out with measurable I/O impact. However, if the process is growing indefinitely due to an error, upgrading will only extend the time until the next failure. Distinguish between a stable high demand and a persistent uncontrolled growth.
When processor capacity is the bottleneck
Look for persistent compute, queued tasks, and concurrency with longer response times. Distinguish between total CPUs and individual cores. A single saturated thread on a multi-core machine can throttle a particular function even if the overall average is low. Adding more of the same cores may not help it if the application does not parallelize the work.
top -b -d 1 -n 10 -o %CPU
# Pokud je dostupný sysstat:
mpstat -P ALL 1 10
pidstat -u -p ALL 1 10For multithreaded or multiprocess work, additional usable capacity can shorten the queue. However, check serial parts, memory throughput, and dependencies. Time spent waiting for the database is not the same as CPU needed to perform the calculation. High load with many tasks in D requires separate I/O diagnostics, not automatically more cores.
A short, regular spike may correspond to a properly running check or synchronization. Evaluate its duration, overlap with interactive traffic, and the ability to eliminate unnecessary rework. If the response is on target and the spike subsides quickly, there may be no reason to increase capacity just because of the visible spike.
Cgroup, VM, and shared host change available budget
Check the actual limits of the service and parent group. A process may be reaching MemoryMax or CPUQuota even though the entire machine has a reserve. In this case, the issue is appropriate allocation of available capacity, not necessarily buying a larger server. However, changing the limit must preserve space for other services.
systemctl show APLIKACE.service -p ControlGroup -p MemoryMax \
-p MemoryCurrent -p CPUQuotaPerSecUSec -p CPUWeightCPUWeight and CPUQuota are not the same limit. Relative weight helps to divide competing traffic, quota sets a different kind of ceiling. Also consider the container's overhead budget. For VMs, steal or shared host conditions may apply; more vCPUs are not an automatic guarantee of more physical time when the host is heavily overloaded.
The guest system's visible RAM may differ from the nominal hypervisor configuration, for example due to ballooning or other limitations. Compare the host and guest views instead of assuming that the size listed in the inventory always corresponds to the actual usable capacity. The exact behavior depends on the specific environment.
Application concurrency links RAM and CPU
Adding workers will increase the number of concurrent requests, but it may also increase memory requirements and the number of database connections. If workers are still waiting for CPU, the next concurrency may be worse. If they were limited by memory and queue with otherwise available capacity, you need to justify the cost of the additional process and the corresponding budget.
Separate fast pages from large exports and batch jobs. The average cost of a process may hide a small number of very expensive cases. Measure specific traffic and its dispersion. Also distinguish between cold and warm cache states; savings after the first run may not be the result of a newly added CPU.
A good design might involve optimizing an expensive path, reducing concurrency, or moving long work to a queue. This is not a reason to reject capacity at all costs. The point is to see if the new resource will improve the actual limit, or just allow the application to create more of the same problem at the same time.
Verify the increase as a controlled experiment
Before making a change, write down the hypothesis, expected benefit, and comparison conditions. Change one critical parameter if possible. If you add RAM, switch cache, and deploy new code at the same time, it is impossible to reliably tell from the results which change helped. Maintain the necessary rollback option and consider whether the infrastructure requires a restart.
After the change, rerun a representative scenario and compare response, throughput, memory peak, queues, and errors. For a long duty cycle, wait for the appropriate peak or perform an approved limited test. The lower CPU percentage after adding cores is partly a change in the denominator; the benefit is also evidenced by better completion of actual work.
- For RAM: documented pressure or unnecessary working set extrusion has decreased and service has improved.
- For CPU: the processor queue was shortened and the application used additional capacity.
- For both cases: other services and new limits remained within an acceptable budget.
- On failure: the hypothesis is reevaluated instead of further blind raising.
Describe the result according to the evidence.
The practical conclusion should state the problem path, the measured period, the confirmed limit and the test result. If the data is not sufficient, it is correct to write that the decision is not yet substantiated. From one screenshot, it is not possible to reliably determine the specific size of the upgrade for the entire future operation.
In CH-J Tools, you can monitor CPU, RAM, swap and other status and connect with terminal diagnostics. However, the displayed values need time and application context. The best capacity change is one where you can explain why it helped, how it was verified and what reserve the server has for further really expected work.
Frequently asked questions
Low free means low RAM?
Not automatically. Monitor available memory, cache, pressure, active swapping, and application impact.
Is occupied swap a reason to immediately add RAM?
Not by itself. What matters is current pressure, page movement, and response, not just historically occupied capacity.
Will more cores help a single slow thread?
Not necessarily. It depends on the parallelization capabilities and whether the cause is a calculation or some other dependency.
How do I know if the upgrade really helped?
Compare the same representative traffic, responses, queues, and errors. Changing the percentage due to a larger denominator alone is not enough.
Detailed documentation
Linux: the meaning of memory data /proc/meminfo →
procps-ng: free interpretation →
Linux kernel: pressure on PSI resources →