Scaling WordPress in the cloud can be a painful experience. Here's how the WordPress site C21Media migrated to Amazon Web Services and scaled to meet demand.
Some lucky WordPress site owners are the victims of their own success. As their site gains more content, increases in popularity, and delivers an increasingly sophisticated service, it requires more storage, bigger bandwidth, and greater processing power.
Greater power is required to keep the site responsive and to meet customer expectations. Coping with online success requires scaling up (bigger machines) or scaling out (more machines). WordPress, like many applications running on the LAMP stack, needs care and attention to make it scale.
Ignoring the problem means losing customers. Nobody likes a slow website. There is no hard number, but Google does have global statistics on global site speed. If it takes two seconds to render your wares, even the goldfish don't lose their concentration. Ten seconds? Customers are shopping around. Twenty seconds? They are long gone.
C21Media: a real-life example
C21Media is an entertainment site that runs on a sophisticated WordPress system. Many authors have contributed to C21Media, building up tens of thousands of posts over the years.
Site customer numbers have also built up. The average month sees 58,000 unique visitors making 245,254 visits. No fewer than 38,254 users have registered for the extended features like viewing videos and reading subscription-only articles.
Behind the scenes, the C2Media site (like most WordPress sites) is powered by plenty of plug-ins, and complex theme functionality makes it look so good. C21Media use Brandy Digital, a WordPress development agency, to manage the technical infrastructure.
The price of success
The strain of C21Media's increasing global presence was beginning to show in two ways:
- Heavy traffic peaks were slowing response times, and
- The site's administrative control panel crawled through complex tasks.
A traffic peak happens each day around lunchtime. This is the time Brandy Digital sends out its newsletter, causing readers to click through to the site.
This regular lunchtime traffic spike was causing a slow response. This speed issue could not be solved just by sticking a reverse proxy cache in front of the site. Many visitors use the site in a "logged in" state, and their personalized experience can't be simply cached.
Site administrators carry out duties such as searching through posts and filtering users. Trawling through the large volume of records that built up over the years was also causing a slow response.
Something had to be done. C21Media decided to take some radical action and migrate to the cloud.
C21Media's migration to AWS
Brandy Digital and C21Media gave the site a serious overhaul. A copy of the site was built on Amazon Web Services (AWS), and the technicians got to work on all layers of the technology stack. (I know the Brandy Digital director, and I got permission from him to use the details of the migration in this article.)
At the hardware and networking level, Brandy Digital experimented with various combinations of compute and RDS. They went round the loop of creating instances, installing the site, testing, and destroying it all many times. Brandy Digital settled on compute-optimized C class instances. Despite the common sense that physical hardware always trumps virtual hardware, these VMs were more responsive than the original dedicated servers.
At the OS level, the distribution was switched from the enterprise choice CentOS to the more up-to-date Ubuntu. This brought a few advantages, including more recent software versions. The Ubuntu package repository contains a current LAMP stack. These up-to-date MySQL and PHP applications are more efficient than earlier versions.
Most of the hands-on action took place at the application level. Site developers installed plug-ins, played with fragment cache, and rewrote PHP code. System administrators checked bufferpools, tweaked VCL configuration, and stared blankly at the new Apache 2.4 directives.
Happy customers? Happy client?
But the technical work is never done. The site continues to grow, and Brandy Digital continue to enhance the technical platform. That's what it takes to run a successful WordPress site.