Your Database is the Bottleneck (And It's Probably Your Fault)
It is December 24th. The traffic on your e-commerce shop is peaking. You are watching top via SSH, and your load average just hit 15.0. The culprit? It’s almost always MySQL.
Most Virtual Private Server (VPS) providers hand you a default installation of CentOS 5 and MySQL 5.0 or 5.1. The default my.cnf configuration is designed to run on a machine with 64MB of RAM. If you are running a serious web application in 2010 without tuning these parameters, you are essentially driving a Ferrari in first gear. I've spent the last week debugging a Magento store that kept crashing under load, and the fix wasn't "more servers"—it was better configuration.
1. Stop Using MyISAM
This is the most common mistake I see in the Nordic hosting market. By default, older MySQL versions use the MyISAM storage engine. MyISAM uses table-level locking. This means when a customer writes to your orders table, MySQL locks the entire table. No one else can read or write until that transaction finishes.
On a busy site, this creates a queue. Your CPU goes idle waiting for I/O (iowait), and your site times out.
The Fix: Switch to InnoDB. It supports row-level locking and transactions (ACID compliance). Check your tables:
SELECT table_name, engine FROM information_schema.tables WHERE table_schema = 'your_database';
If you see MyISAM, change it immediately:
ALTER TABLE your_table_name ENGINE=InnoDB;
2. The Holy Grail: innodb_buffer_pool_size
If you only change one setting in /etc/my.cnf, make it this one. InnoDB loves RAM. It caches data and indexes in memory to avoid hitting the disk.
The default is often a pitiful 8MB. If you have a CoolVDS instance with 4GB of RAM dedicated to the database, you should allocate about 70-80% of that to the buffer pool.
[mysqld]
# 70% of RAM for a DB-only server
innodb_buffer_pool_size = 3G
# If you have high write throughput
innodb_log_file_size = 256M
Pro Tip: Don't just guess your memory usage. Use the mysqltuner.pl Perl script. It analyzes your running instance and suggests specific variables. It’s a lifesaver.
3. The Disk I/O Lie
In virtualized environments, disk I/O is the scarcest resource. Many budget hosts oversell their hard drives. You might think you have a dedicated disk, but you are sharing a 15k RPM SAS array with 50 other noisy neighbors. If one of them starts a backup, your latency spikes.
This is why we architect CoolVDS differently. We use Xen virtualization to strictly isolate resources. We don't oversell. When you need disk throughput for a heavy JOIN operation, you get the IOPS we promised. For high-write databases, we recommend RAID 10 setups which provide the redundancy of mirroring with the speed of striping.
4. Norway Specifics: Latency and The Law
If your customers are in Oslo, Bergen, or Trondheim, hosting in a German or US datacenter adds unnecessary milliseconds. Physics is physics. A packet traveling from Oslo to Texas and back takes time.
Hosting locally isn't just about speed; it's about the Personopplysningsloven (Personal Data Act). The Datatilsynet is becoming increasingly strict about where Norwegian user data lives. Keeping your MySQL data on servers physically located in Norway simplifies compliance massively.
Quick Latency Test (Ping from Oslo)
| Destination | Latency (ms) |
|---|---|
| CoolVDS (Oslo) | 2-5 ms |
| Amsterdam | 25-35 ms |
| New York | 90-110 ms |
5. A Dangerous but Effective Tweak
If you are absolutely desperate for write speed and can tolerate losing 1 second of data in the event of a total power failure (and you have a battery-backed RAID controller), change this:
innodb_flush_log_at_trx_commit = 2
By default, this is set to 1, meaning MySQL flushes to disk after every transaction. Setting it to 2 writes to the OS cache and flushes to disk once per second. The performance gain on write-heavy applications is massive, often 10x or more. But understand the risk.
Conclusion
Performance isn't magic. It's about ensuring your working set fits in RAM and minimizing disk seeks. If you've tuned my.cnf and are still seeing high iowait, your current host is likely choking your I/O.
Don't let a slow database kill your Q4 revenue. Deploy a high-performance Xen VDS with CoolVDS today. We offer low-latency connectivity to NIX (Norwegian Internet Exchange) and hardware that doesn't quit.