The CFO vs. The Root User: Pruning Cloud Infrastructure Costs in 2013
There is a pervasive myth circulating in boardroom meetings across Oslo right now: "Moving to the cloud saves money automatically."
This is categorically false.
If you lift-and-shift a legacy Apache-based architecture onto a metered cloud instance without aggressive tuning, you are simply renting expensive inefficiency. I recently audited a media streaming startup in Stavanger that was burning through 40.000 NOK monthly on hosting fees. Their servers weren't overloaded by traffic; they were choking on I/O wait times and poorly configured Apache preforks.
As technical leaders, we need to balance the Total Cost of Ownership (TCO) with raw performance. We don't need infinite scalability for a corporate intranet; we need predictable, high-density performance. Here is how we optimize infrastructure in the current 2013 landscape, ensuring compliance with Norwegian data laws while keeping the hardware usage lean.
1. The Virtualization Trap: OpenVZ vs. KVM
Many budget hosting providers oversell their nodes using OpenVZ. It looks cheap on paper. However, OpenVZ shares the host kernel. If a "noisy neighbor" on your physical node decides to compile a massive C++ project, your database latency spikes. You cannot optimize what you do not control.
For mission-critical workloads, we must insist on Kernel-based Virtual Machine (KVM) technology. KVM provides full hardware virtualization. The kernel is yours. The memory is yours.
Pro Tip: Check your `/proc/user_beancounters` file if you are on an OpenVZ system. If you see the `failcnt` column rising, your provider is throttling you, and your application is silently dropping requests. This is the hidden cost of "cheap" VPS hosting.
At CoolVDS, we standardize on KVM because it allows us to run custom kernels and rigorous TCP stack tuning that container-based virtualization simply prevents.
2. Storage: The SSD ROI Calculation
Spinning rust is dead for databases. In 2013, the price delta between SAS HDDs and Enterprise SSDs is narrowing, but the IOPS (Input/Output Operations Per Second) difference is logarithmic.
A standard 15k RPM SAS drive might give you 180 IOPS. A modern Enterprise SSD pushes thousands. If your MySQL server is I/O bound, you don't need more CPU cores (which cost more in licensing and hosting tiers); you need faster storage.
I recently migrated a Magento installation from a 4-core HDD VPS to a 2-core SSD VPS. The page load times dropped from 2.4s to 0.8s, and the monthly bill decreased by 30%. Why? Because the CPU wasn't waiting for the disk anymore.
If you are deploying on CoolVDS, you are running on local RAID-protected SSDs. This allows us to reduce the `innodb_buffer_pool_instances` overhead because the penalty for a cache miss is significantly lower.
3. The Software Stack: Replacing Apache with Nginx
Apache 2.2 (and even the newer 2.4) uses a thread/process-based architecture. Under heavy load, it eats RAM linearly. Nginx, currently at version 1.4.1, uses an event-driven architecture. It can handle 10,000 concurrent connections with a fraction of the memory footprint.
Switching from LAMP (Linux Apache MySQL PHP) to LEMP (Linux Nginx MySQL PHP-FPM) is the single most effective software change for cost reduction. You can serve the same traffic on a 512MB VPS that would require 2GB on Apache.
Here is a production-ready `nginx.conf` snippet optimized for a 1GB VPS running CentOS 6.4:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Optimization for file serving
sendfile on;
tcp_nopush on;
tcp_nodelay on;
# Keepalive to reduce handshake overhead
keepalive_timeout 65;
# Gzip to save bandwidth costs
gzip on;
gzip_comp_level 5;
gzip_types text/plain application/xml text/css application/javascript;
}
Don't forget to restart the service after applying changes. Since systemd isn't standard yet on most RHEL derivatives:
service nginx restart
4. Database Tuning: Stop Guessing
Default MySQL 5.5 configurations are intended for small development machines, not production servers. The `innodb_buffer_pool_size` is the most critical setting. It should be set to roughly 70-80% of your available RAM on a dedicated database server.
However, on a shared VPS where the web server also runs, setting this too high will induce swapping. And swapping kills performance.
Configuration for a 2GB RAM VPS (MySQL 5.5):
[mysqld]
# InnoDB Settings
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2 # 0 for speed, 1 for safety, 2 for balance
innodb_file_per_table = 1
# Connection Settings
max_connections = 150
query_cache_size = 0 # Disable query cache for high concurrency writes
query_cache_type = 0
Note on `innodb_flush_log_at_trx_commit = 2`: This writes the log buffer to the file system at each commit but only flushes to the disk once per second. In the event of an OS crash, you might lose one second of transactions, but the I/O saving is massive compared to setting `1`. For most web apps, this is an acceptable trade-off.
5. Local Nuances: Latency and Legality
For those of us operating out of Norway, latency to the Norwegian Internet Exchange (NIX) in Oslo is paramount. Hosting your application in a US East Coast data center might save you $5 a month, but the 100ms+ latency penalty degrades the user experience significantly.
Furthermore, we must adhere to the Personopplysningsloven (Personal Data Act). Data sovereignty is becoming a hotter topic every year. Storing customer data within Norwegian borders, or at least within the EEA, simplifies compliance with Datatilsynet (The Data Protection Authority) requirements. CoolVDS ensures that your data resides on hardware physically located here, utilizing Norwegian hydro-power, which also happens to align with green IT initiatives.
Summary: The Efficient Path Forward
Cost optimization isn't about buying the cheapest VPS. It is about buying the correct architecture.
- Virtualization: Demand KVM to avoid noisy neighbors.
- Storage: Prioritize SSD IOPS over massive HDD capacity.
- Stack: Migrate to Nginx and PHP-FPM.
- Tuning: Configure MySQL buffers to fit your RAM, not the defaults.
By implementing these changes, you can often downgrade your instance size while upgrading your performance. That is true engineering efficiency.
Ready to test a stack that respects your budget and your technical requirements? Spin up a CentOS 6 SSD instance on CoolVDS today and see what single-digit latency looks like.