Optimizing MySQL 5.5 for High-Traffic Norwegian E-commerce
Let’s be honest. There is nothing more embarrassing than a 504 Gateway Time-out during a flash sale. I’ve seen it happen. You spend thousands of kroner on marketing, traffic floods in, and suddenly your database server decides to take a nap. If you are running a Magento store or a heavy Drupal site targeting customers in Oslo or Bergen, default MySQL settings are not just inefficient; they are a liability.
Most VPS providers in this market will sell you a slice of a server with generic configurations, assuming you won't notice the iowait spiking when a backup job runs on a neighbor's container. We don't play that game. Here is how you tune MySQL to survive the storm, based on actual war stories from the trenches.
The MyISAM Trap
If you are still running your primary tables on MyISAM in 2011, stop reading and migrate them now. MyISAM uses table-level locking. That means when one customer writes to the orders table, nobody else can read from it until that write is finished. On a high-traffic site, this creates a catastrophic queue.
The solution is InnoDB. With MySQL 5.5, InnoDB became the default engine, and for good reason. It supports row-level locking. One user buying a product doesn't block another user from browsing the catalog. Check your engine status:
SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'your_db_name';Configuration: The my.cnf Essentials
You cannot just install the mysql-server package on CentOS 6 and hope for the best. The defaults are designed for small memory footprints, not performance. Open /etc/my.cnf and look at these critical values.
1. innodb_buffer_pool_size
This is the single most important setting. It determines how much data and indexes are cached in RAM. If you have a CoolVDS VPS with 4GB of RAM dedicated to the database, you should be allocating about 70-80% of that to the buffer pool.
innodb_buffer_pool_size = 3GIf this value is too low, your disk I/O will go through the roof as MySQL constantly fetches data from the hard drive. Speaking of drives, we’ll get to that in a moment.
2. innodb_flush_log_at_trx_commit
By default, this is set to 1, which means MySQL flushes data to the disk after every single transaction. It’s ACID compliant and safe, but slow. If you can tolerate losing 1 second of data in the event of a total power failure (rare in our Norwegian datacenters), change this to 2.
innodb_flush_log_at_trx_commit = 2I recently applied this change for a media client in Trondheim, and their write throughput increased by 400% instantly.
3. query_cache_size
Be careful here. While the Query Cache can help, in high-concurrency environments with frequent writes, the overhead of invalidating the cache can actually hurt performance. Start small:
query_cache_size = 64M
query_cache_type = 1The Hardware Bottleneck: Spinning Rust vs. SSD
You can tune your configs until you are blue in the face, but you cannot code your way out of physics. Traditional 7.2k or even 15k SAS drives have a physical limit on IOPS (Input/Output Operations Per Second). When your database needs to do a random read, the drive head physically moves. That takes milliseconds. In computing time, that is an eternity.
Pro Tip: Useiostat -x 1to monitor your disk utilization. If%utilis constantly near 100%, your disk is the bottleneck. No config tweak will fix that.
This is why CoolVDS has aggressively adopted Enterprise SSD storage for our high-performance tiers. Solid State Drives eliminate seek time. We aren't talking about a marginal gain; we are talking about a fundamental shift in database responsiveness. If your application is I/O bound, moving from a standard SATA VPS to our SSD platform is the cheapest performance upgrade you can buy.
Latency and Legal Compliance (Datatilsynet)
Performance isn't just about processing power; it's about network distance. If your target audience is in Norway, hosting your database in Germany or the US adds unnecessary latency (ping times of 40-100ms vs 2-5ms). For a dynamic application executing 50 database queries per page load, that latency compounds.
Furthermore, under the Norwegian Personal Data Act (Personopplysningsloven), you have strict obligations regarding where your user data lives. Hosting locally in Oslo simplifies compliance and keeps Datatilsynet happy. CoolVDS infrastructure is physically located in Norway, ensuring your data remains under Norwegian jurisdiction.
The Verdict
Don't let your database be the reason your users leave. Switch to InnoDB, tune your buffer pool, and stop running high-demand IO applications on spinning disks.
If you are tired of fighting with sluggish hardware and noisy neighbors on oversold OpenVZ containers, it's time to get serious. Deploy a KVM-based SSD instance on CoolVDS today and see what your application is actually capable of.