Netflix and Chill: How to Keep WordPress up All Night

     
By on July 19, 2017

You’re on a laptop, finishing off a particularly stressful day of work. You’re about to snap it shut when you notice one last email that’s slipped through. It’s Netflix – and they want to make a documentary about you.

It’s the offer every growing business dreams of getting. Marketing is tough—but here’s an offer that will expose your brand to a potential audience of millions.

So all good, right? Sure. But you’d better be ready for the tidal wave of traffic that’s about to hit your website. And that’s exactly what happened to the Erika Lust team.

Who Is Erika Lust?

Born in 1977 in Sweden, Erika studied political sciences, feminism, and gender studies. She became sick of the chauvinistic, one-sided nature of mainstream adult movies.

A third of internet traffic, and one in every four Google searches, is porn-related. In this Tedx talk, Erika—armed with these stats—describes how she realized porn was distorting teenagers’ understanding of sex. Here’s Erika:

“Porn is today’s sex education.”

In this distortion, women are treated as objects. So she decided to do something about it. She started making her own adult movies—movies filmed by women that afforded them the same role as men.

Since then, Erika has grown her business by promoting ethical porn and encouraging other filmmakers to join the movement. More and more people started shooting—and so did Netflix. The first episode of Hot Girls Wanted: Turned On is all about Erika Lust.

Stuck In Traffic

Following the documentary release, they expected a little bump in traffic. What they didn’t expect was a mountain. Site visits increased by 6 times the amount of the previous month.

The site started to feel the strain. At peak times, the average throughput was a measly 2.0 requests per second, meaning that the site could only deliver 172,800 page views per day. Which is a bit like being surrounded by schools of valuable fish with only a hair net to catch them with.

The Erika Lust team were concerned. This could reflect poorly on their brand image—not to mention the potential new revenue they were losing. Under extreme pressure, the site even went down a few times.

So they reached out to Mobile Jazz.

When Lust Met Jazz

When a partner isn’t performing, you can stick it out and concede it’s probably the best you’re going to get. Or, you could recognize you deserve so much better—and dump them. Erika Lust were sick of being taken for granted when it came to the website. They took action and gave their previous WordPress provider the boot.

They needed someone who could deliver—an innovative tech company working at the forefront of web development. They started local, and focused their search efforts in Barcelona. One company stood out. It was a company that came highly recommended with an impressive portfolio—Mobile Jazz

At Mobile Jazz, we were thrilled. But the inherited WordPress site needed a lot of love and attention. On top of that, Erika Lust wanted to build an on-demand video service for their website. After some initial development work they were impressed, and made Mobile Jazz the sole company responsible for all web development.

After getting information on the Netflix traffic problem, we at Mobile Jazz quickly got to work. The first step was identifying the problem behind the slow site performance at peak traffic times. The Erika Lust team had told us about the hosting provider they were using in Andorra, so like any good detective we went straight to our first lead with a few questions.

And like any good detective novel, the lead wasn’t entirely transparent. We reached our for urgent information, and after 24 hours received a message from them stating that they’d done a load test, and had included some performance info and graphs. Only the information was next to useless—there was no info on CPU usage and no info on bandwidth usage. Nor could we check what kind of activity was happening within the servers. For them, everything was fine.

This would need some more serious sleuthing.

Pinning Down The Problem

We still hadn’t identified the problem, so we put together an analysis plan. We checked network traffic, then created a copy of the site on Amazon Web Services.

How does AWS match up against Google? Find out here.

Then, we did our own load stress test. We checked the CPU, memory, and installed New Relic to scan for issues.

Using Google Chrome developer tools, we got a clear picture of the web resources usage and load times for each resource.

What did we learn from this? The site was heavy. Here’s why:

  • The homepage was around 10MB-20MB.
  • The images on the site weren’t optimized.
  • Animated GIFs were being used as short videos.

The WordPress response time was as fast as a drugged slug. It took almost 1 second to answer—not ideal in 2017. On top of that, MySQL and Apache were being used in the same machine, and there was no cache plugin.

Problem identified.

Performance Testing

We had a hypothesis—now we had to test it.

Remember that we created a copy of the site in AWS? Now we installed the WP Super Cache plugin in order to complete some performance testing.

Like a personal trainer spotting bar weights for a bodybuilder, we started to run load stress tests on both the real (Andorran servers) and copied (AWS servers) sites.

First, the response time and latency figures. Here are the results from the Andorran servers:

Now here’s the response time and latency results from AWS:

Much better. AWS holds out much better, keeping response time and latency down even as the amount of users climbs steeply.

But to get a really clear idea on site performance, we needed some average throughput stats:

Just look at the difference in average throughput when using Amazon servers and the WP Super Cache plugin—major improvement.

With Amazon now serving up at tasty amount of pages per second, let’s look at how that translates into number of monthly visitors. Time to hit the math:

  • Using Google Analytics, we worked out that on average a user visiting the site looked at 2.49 pages per session.
  • We multiplied the average throughput figures by the number of seconds in a day to get the number of daily page views.
  • From there we can work out the total number of users the server can handle, based on the number of pages each user visits on average.
  • The Andorran servers with no WP optimization could handle 69K daily visits.
  • The AWS servers with WP optimization could handle 1.8M daily visits.

Now that’s a big leap in traffic handled, and a clear indication that a move to AWS would lead to major improvements in site performance.

But Erika Lust had given us a clear brief: “We don’t want to break the bank when it comes to transfer costs.”

Keeping Costs In Check

How do you transfer cloud providers without blowing your budget? The total monthly cost based on the traffic we were dealing with would have been $2190.88.

You can’t do anything about what cloud services charge. So we tackled the traffic costs head on. Here’s how:

  • We optimized the site images.
  • We used a streaming service for videos.
  • We used a CDN for static content, which improved the speed and brought down the price.

Hold on. What’s a CDN?

A CDN is a Content Delivery Network. It lets you deliver content based on user location, which means data can be transferred faster with a load that’s distributed more evenly between different servers. Depending on how the content is provided, you could use:

  • A push CDN: Content is manually uploaded to a main server then distributed to other servers.
  • A pull CDN: Content is fetched from the original server when it’s accessed for the first time.

Here are the benefits in full:

There are a number of CDN providers to choose from, from Amazon CloudFront and Google CDN at the more expensive end of the scale, to StackPath and KeyCDN which are both significantly cheaper. Whichever you decide to go with, go through the pricing plans carefully (normally Asia is a lot more expensive), look at the number of POPs, check the security features, and consider any additional features you may need.

The Final Architecture

Problem nailed, speed optimized, CDN chosen. Here’s what the final architecture looked like:

With WordPress optimized with WP Super Cache, we enabled the CDN option. We modified the theme for using imgix to load the home page images, and to play videos from the Wowza servers. We then changed some functions to load JS files from the CDN where the Super Cache plugin wasn’t quite enough. Apache2 with the Google Pagespeed module then minified JS and CSS files automatically.

From Lust to Love

Erika Lust were worried that an inaccessible site following the Netflix documentary would result in lost revenue and a bad image; a site that hosts adult movies that can’t handle an increase in traffic? Really?

Mobile Jazz returned with a solution that increased response time and average throughput—cue sigh of relief. Erika Lust were about to keep the site up and running with fast response times, even with the spike in visits (6x compared to before the documentary aired). What’s more—they recorded their best month ever in sales.

It’s been a real thrill working with the Erika Lust team to scale their WordPress and make it fly.

Fancy spicing up your site’s performance? We’d love to hear from you.

Read the comments

Steve is a writer and translator, with a background in social work for young people and at-risk groups. You’ll find him in Barcelona attempting to: learn Catalan, play football, and hunt down the best curry in the city. See more of his work here.

Want to receive more insightful articles like this? Subscribe here.


By submitting your information you agree to our Privacy Policy