Configuring database memory for your tier
Specific buffer values for PostgreSQL and MySQL for VDS-1…VDS-6, and a rule for distributing memory between the database, application, and system.
Updated August 23, 2026
Default database settings are designed to start anywhere, not to run fast. On VDS-3 with 8 GB of memory, PostgreSQL out of the box uses 128 MB for cache — meaning it reads almost everything from disk, even though it could read from memory.
Allocation rule
Split the tier's memory roughly like this:
- system and service processes — 10–15%;
- the application (PHP-FPM, Node, gunicorn) — by the number of workers;
- the database — whatever is left, but no more than 60–70% of total memory.
Never give the database all the memory: the system will go into swap, and NVMe won't help you — latency will grow tens of times over.
How much is in use right now:
free -h
ps -eo pmem,rss,comm --sort=-rss | head
Memory graphs for an hour, a day, a week, and a month are available in the "Overview" of the panel /hosting/vds/m/<id> — they show the real peak, not the current moment.
PostgreSQL
/etc/postgresql/17/main/postgresql.conf:
| Tier | shared_buffers | effective_cache_size | work_mem | maintenance_work_mem | max_connections |
|---|---|---|---|---|---|
| VDS-1 (2 GB) | 384MB | 1GB | 8MB | 96MB | 40 |
| VDS-2 (4 GB) | 1GB | 2GB | 12MB | 256MB | 60 |
| VDS-3 (8 GB) | 2GB | 5GB | 16MB | 512MB | 100 |
| VDS-4 (16 GB) | 4GB | 10GB | 24MB | 1GB | 150 |
| VDS-5 (24 GB) | 6GB | 16GB | 32MB | 2GB | 200 |
| VDS-6 (32 GB) | 8GB | 22GB | 48MB | 2GB | 250 |
Plus the general NVMe settings:
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem is allocated per sort operation, not per connection: a hundred parallel queries with complex sorting will multiply it hundreds of times over. Don't set it too high.
Applying: systemctl restart postgresql (changing shared_buffers requires a restart specifically).
MySQL and MariaDB
| Tier | innodb_buffer_pool_size | innodb_log_file_size | max_connections |
|---|---|---|---|
| VDS-1 | 512M | 128M | 60 |
| VDS-2 | 1G | 256M | 100 |
| VDS-3 | 3G | 512M | 150 |
| VDS-4 | 8G | 1G | 200 |
| VDS-5 | 12G | 1G | 250 |
| VDS-6 | 18G | 2G | 300 |
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 1
innodb_io_capacity = 2000
The buffer pool is the main parameter: if it fits the working data set, the disk is barely read.
Checking the effect
SELECT sum(blks_hit)*100/sum(blks_hit+blks_read) FROM pg_stat_database;
For MySQL, look at SHOW ENGINE INNODB STATUS and the ratio of Innodb_buffer_pool_reads to Innodb_buffer_pool_read_requests. A cache hit rate below 95% means the database doesn't have enough memory.
Common mistakes
| Symptom | Cause |
|---|---|
| The database won't start after an edit | More memory requested than is available — check the journal |
| The process was killed by OOM | The database, application, and system together exceed the tier's memory |
| It got slower after "optimization" | work_mem is set too high, the machine is swapping |
| The disk is constantly being read | The buffers are too small, the working set doesn't fit |
If you're still hitting a wall after tuning memory, the problem is the amount of data, not the config. You can only upgrade your plan, with a prorated payment for the remaining days of the paid term; downgrades aren't available, so choose the next tier deliberately.