The Death of Prefork: Why Your RAM Is Disappearing
If you are still running a high-traffic site on a default Apache 2.2 installation with mod_php, you are essentially throwing money into a furnace. I watched a client last week try to scale a Magento installation on a standard 4GB VPS. The server wasn't CPU bound; it was swapping to disk because every single Apache child process was dragging a full PHP interpreter along with it, regardless of whether it was serving a PHP script or a static JPG.
It is nearly 2010. We need to stop configuring servers like it is 2002. The solution isn't adding more RAM; it's changing the architecture to the LEMP stack (Linux, Nginx, MySQL, PHP-FPM).
The PHP-FPM Advantage
PHP-FPM (FastCGI Process Manager) separates the web server from the PHP processing. This allows Nginx to handle thousands of concurrent static connections with a tiny memory footprint (often less than 2MB per process), passing only the dynamic requests to the PHP-FPM backend.
With the release of PHP 5.3 earlier this year, FPM is finally getting the mainstream attention it deserves, moving from a patch set to a core consideration for serious systems administrators.
Pro Tip: On CoolVDS Xen instances, we recommend separating your static assets domain. Let Nginx serve images directly from memory buffers, bypassing PHP entirely. This reduces the load on the FPM pools significantly.
Tuning the Pool Configuration
The default configuration in /usr/local/etc/php-fpm.conf (or /etc/php5/fpm/main.conf depending on your compile) is rarely optimal for production. The most critical directive is process management.
Avoid pm = dynamic if you have predictable traffic and ample RAM. Process spawning adds latency. For a high-performance store targeting the Norwegian market, where millisecond latency to Oslo matters, use static management.
<value name="style">static</value>
<value name="max_children">50</value>
Note: Calculate max_children based on your average PHP process size. If a process takes 30MB and you have 2GB of Dedicated RAM on your CoolVDS slice, leave 500MB for the OS and DB, and divide the rest. (1500 / 30 = 50).
Nginx Configuration for FPM
You need to tell Nginx to talk to the FPM socket or TCP port. Using a Unix socket prevents TCP overhead, which provides a slight edge in I/O performance.
Here is a battle-tested snippet for your nginx.conf server block:
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
The Hardware Reality: IOPS Matter
Software optimization only takes you so far. If your database is thrashing the disk, PHP-FPM processes will pile up waiting for MySQL to return data. This creates a backlog that looks like a CPU issue but is actually an I/O bottleneck.
Many hosting providers in Europe are still running on slow SATA drives with high contention ratios. At CoolVDS, we utilize Enterprise 15k RPM SAS RAID-10 arrays and emerging SLC SSD technology for database partitions. When your PHP application hits the disk, it needs to read fast.
Data Sovereignty and Latency
For developers targeting Norwegian users, physical location is not just about ping times—though hitting NIX (Norwegian Internet Exchange) directly is a huge advantage. It is also about compliance with the Personopplysningsloven (Personal Data Act). Hosting your data on servers physically located in Oslo ensures you aren't accidentally routing sensitive customer logs through jurisdictions with weaker privacy protections.
Conclusion
Stop letting Apache eat your RAM. Migrating to Nginx and PHP-FPM reduces your memory footprint and stabilizes your server under load. It requires a bit more command-line expertise to set up spawn-fcgi or the new FPM daemon, but the stability gains are undeniable.
Ready to compile your custom LEMP stack? Deploy a high-performance Xen VPS with CoolVDS today and get full root access to build it right.