How to share VPS resources between several products

Plan CPU, memory, disk, and swap for products running together.

Modules of different colours in a shared server chassis: a metaphor for distributing resources between products.
Modules of different colours in a shared server chassis: a metaphor for distributing resources between products.

Several independent products can run on one machine, but independence in code does not isolate CPU, memory, or disk. One product’s queue can slow another product’s pages. Preparing a backup may consume space just as the database creates temporary files. Capacity planning therefore starts with the work the server must handle simultaneously.

For Solution200, this follows naturally from the discussion of a shared foundation: reusable capabilities remove duplicated code, while hosting products requires a separate resource budget. The number of websites alone does not determine that budget. Their tasks, activity, and acceptable latency matter.

List the work first

List the base system, web processes, database, cache, search, background consumers, logs, and backups. These are possible roles, not a requirement to install every service. For each role, describe normal work, a short peak, and whether it can wait.

For example, a hypothetical journal serves pages while another product processes images. Image processing can have limited concurrency; readers need a prompt response. If both processes have unlimited concurrency, good results in isolation tell us little about their combined behaviour.

Resource What to budget What to observe
CPU Normal requests and acceptable concurrency of expensive jobs Utilisation, runnable queue, response latency
RAM Process working sets and room for peaks and restarts Available memory, pressure, out-of-memory terminations
Disk Data, logs, temporary files, copies, and growth Free bytes, inodes, growth rate
I/O Concurrent reads and writes across roles Operation waiting time and application latency
Swap Behaviour under memory pressure Swap activity and its effect on latency

Memory and concurrency are connected

Suppose a VPS has 8 GiB of RAM. Provisionally assigning 3 GiB to the system and shared services and keeping 1 GiB in reserve leaves 4 GiB for application processes. Assuming 200 MiB per process gives roughly twenty processes. This is an arithmetic estimate, not a recommended setting: real processes vary, consumption changes, and some pages may be shared.

The estimate raises useful questions about limits. It does not justify automatically running twenty processes for each product. Check total concurrency, expensive requests, and restarting one service alongside the others.

On Linux, free -h is useful for an initial observation. The free manual explains available as an estimate of memory available to new applications without swapping. One snapshot does not show peak demand. A low free value also does not mean all memory is irreclaimably occupied: the system uses memory for caching.

Swap and disk need their own allowance

Swap can help absorb some memory pressure, but active disk swapping can increase latency. Do not add it to RAM as equivalent capacity. The Linux memory overview introduces pages, reclaim, and swap; sizing depends on workload and latency requirements.

Disk capacity must cover more than today’s data. Allow for log growth, updates, temporary output, and recovery operations. On filesystems with a fixed inode supply, many small files can exhaust it before bytes run out. The illustrative checks df -h and df -i answer different questions.

Give headroom a specific purpose

A hypothetical 100 GiB disk might provisionally allocate 35 GiB to current data, 15 GiB to expected growth, 10 GiB to the system and logs, and 20 GiB to temporary work. That leaves 20 GiB in reserve. These figures are invented; the allocation method matters. If preparing a copy requires another 25 GiB locally, the plan already fails that scenario, even though the disk is less than half full today.

Clarify what each allocation includes. Is a temporary copy created alongside the source files? Are several completed outputs retained? Is failed output removed? Without these answers, the same free capacity can silently be promised to several tasks.

Do not assess CPU headroom solely through average utilisation either. Short bursts may coincide, and deferrable work competes with interactive requests. Decide which task to reduce first if readers start receiving slow responses. That priority decision comes before choosing an exact process count.

A scenario for adding a product

Before adding a hypothetical second journal, record the first journal’s behaviour under ordinary reading. In a controlled environment, introduce the new product’s typical request, then its expensive background job. This shows which step consumes headroom. Starting everything together without intermediate observations makes the result harder to explain.

Compare equal amounts of work using consistent criteria. If one run reads cached content while another rebuilds all derived output, the difference does not measure only the added product. Separately record cache warmness, remaining queue work, and whether it finishes after the peak. A fast response then cannot conceal a backlog accumulating in the background.

E-01 in practice before allocating resources

During the initial inspection, I recorded the resources of the new E-01 training server. The plan lists 2 GB RAM and 20 GB SSD. For planning, I separately read the guest system’s metrics:

free -b
swapon --show --bytes
lsblk -b -o NAME,SIZE,TYPE,MOUNTPOINTS
df -hT
df -i

free -b reported 2 031 960 064 bytes of total RAM and 1 759 944 704 bytes in the available field. The latter is an estimate of available memory at that moment. There was no active swap: swapon --show --bytes exited with code 0 and no output.

lsblk reported a /dev/sda disk of 21 474 836 480 bytes, or 20 GiB. For the mounted root filesystem, df -hT showed ext4, 5% usage, and 18G available; df -i showed 3% inode usage. I recorded the whole-disk size separately from available filesystem space.

These metrics establish a starting boundary for adding services one at a time. They do not yet determine how many sites E-01 can handle or the process limit it needs. Once a specific workload is present, I will repeat the measurement and keep headroom for its peaks. The hypothetical budgets above remain examples; the E-01 numbers belong to this separate practical run.

Test workloads together

In a controlled environment, combine representative reads, a background job, and a backup. Define acceptable latency and stop conditions before starting; collect peaks as well as averages. After reducing concurrency, repeat the specific scenario that exposed the problem.

If headroom disappears, several responses are possible: reschedule an expensive job, limit it, increase capacity, or move a role to another machine. The choice depends on the bottleneck. Adding CPU will not fix a full disk.

Planning should produce a table of assumptions and observations, with dates and scenarios. A new product, different traffic, or changed background work is a reason to revisit it. That keeps the budget a decision that can be tested.

  1. Observability What to record before changing a server
  2. Observability When a server is truly ready to launch
  3. PHP PHP and Composer: what to check beyond the version number
  4. Observability Why a VPS snapshot is not enough for recovery
  5. Observability E-01 resources before public access: RAM, disk and swap

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article