A small WordPress website runs on 2 GB of RAM. For a shop with its own database, 8 GB is a sensible starting point, and database or container servers need 16 GB or more. The requirement depends mainly on which services run at the same time, less on the number of visitors. Measure utilisation over several days before you upgrade.
Key facts
- Most common bottleneck
- RAM, ahead of CPU performance
- Small website
- 2 GB as a guide value
- Shop or database
- 8 to 16 GB upwards
- Measurement tools
- free -h, htop, vmstat, long-term graphs
- Swap
- Emergency reserve, no substitute for RAM
- ECC memory
- Corrects bit errors, standard in servers
Why RAM usually runs short first
With high CPU load, requests are simply processed more slowly. Missing memory causes real problems on a Linux server. First the page cache shrinks, files already read are evicted and accesses go back to the disk. If that is not enough, the kernel's out-of-memory killer terminates the process using the most memory. That is usually the database, and the failure looks like a crash with no obvious cause. A server with too little memory therefore often fails under load instead of just slowing down.
How much RAM does each service need?
The following figures are guide values for the total requirement of a machine running the service together with the operating system and a web server. They do not replace measurement, but they are a reasonable starting point. If several services share a machine, such as a database and an application, their requirements add up. Plan for reserve. A server that is permanently more than 80% occupied has no buffer left for load peaks, updates or backup runs.
- Static website or reverse proxy: 1 GB is usually enough.
- WordPress with little traffic: 2 GB, larger installations with caching and plugins 4 GB.
- WooCommerce or Shopware with its own database: 8 GB as a guide value, more under load.
- Dedicated database server: 16 GB upwards. The working data set should fit into RAM.
- Nextcloud for a small team: 4 GB, a mail server with spam and virus filtering also 4 GB.
- Docker hosts, monitoring stacks and game servers: 8 to 32 GB, depending on the number of instances.
These are starting values. A single poorly optimised plugin or a search index can double the requirement.
How do you measure the actual requirement?
A single look at free -h is easily misleading, because Linux uses free memory as a file cache. The value under used therefore looks high even when plenty of memory is available. The column that matters is available. htop shows which processes are using the memory, and vmstat 1 shows whether the kernel is already swapping. More important than a snapshot is the trend over at least a week, including backup windows, import runs and traffic peaks. Netdata, Zabbix or Prometheus record this automatically. From that you can tell whether memory is permanently short or only individual peaks need to be absorbed.
What swap does and does not do
Swap is memory paged out to the disk. It stops the kernel from killing processes immediately during a short peak, and it pages out rarely used memory pages. It does not replace RAM, because even fast NVMe drives are orders of magnitude slower than main memory. A server that swaps permanently is practically unusable, especially with databases. One to two gigabytes of swap as a buffer is sensible, and on database servers a low swappiness value as well. If swap is regularly full, you should add more memory.
Why servers use ECC RAM
ECC stands for error correcting code. These modules detect bit errors in main memory and correct single-bit errors during operation. The errors are caused by ageing, temperature or cosmic radiation. They are rare, and without ECC they go unnoticed. On a workstation this occasionally causes a crash; on a database or storage server it leads to silently corrupted data that also ends up in the backup. Server platforms therefore use ECC memory almost without exception. At Realtoxmedia the Virtual Dedicated Server (VDS) uses DDR4 ECC memory, and dedicated servers are based on Xeon and EPYC server platforms.
Upgrade or optimise?
Not every memory shortage is a hardware problem. Often individual services use more than they need because their default configuration was written for different machine sizes. Without a maxmemory setting Redis takes as much memory as it can get, and containers without limits do the same. Before an upgrade it is worth spending half an hour on configuration, which often helps more than doubling the memory. Check in this order:
- Database: a MySQL or MariaDB buffer pool set larger than the server can provide.
- PHP-FPM: too many worker processes for the available memory.
- Java services and search indexes without a configured memory limit.
- Containers and virtual machines without a configured memory limit.
- Log and monitoring agents that keep growing unnoticed in the background.
Upgrading is the right step if occupancy stays above around 80% after optimisation, if the server swaps regularly or if more services are going to be added. When choosing a server, check that RAM can be expanded later without moving to a new machine.
Start with the guide value for your use case, measure utilisation over several days and plan for around 20% reserve. Swap does not replace main memory, and servers should have ECC RAM. A server that swaps permanently needs more memory; tuning will not fix that.