So you’ve got your site up or you’ve just finished your awesome new mobile app, but how many users can it handle before it comes to a screeching halt leaving a negative impression on your end users and pissing off your boss, investors or partners?
Why is load testing important?
The worst time to discover that your current infrastructure can only handle 100 simultaneous users is when you have 1000 simultaneous users trying to access your site after you’ve spent a significant amount of money on marketing, or if you’re lucky enough to have a positive article about your company publish in a major newspaper or magazine.
If you plan on 10,000 simulations users you need to test for at least that many users. It’s easy to write a web app that can respond to one user at a time it’s significantly more difficult to write a web app that can scale up to 100,000 or a million simultaneous users.
Many of my freelance clients approach me in extreme desperation after hiring the lowest bidder on one of the many freelance development marketplaces and discovering that their site becomes extremely slow or even unresponsive with only a few simultaneous users. The developers they hired were quick to push out a site that has an illusion of functionality but a few weeks later is more of a liability than an asset. These clients are never happy when I tell them that building a web site that scales well can be significantly more expensive and time consuming than what they’ve currently invested.
How many users do you plan on?
Currently this blog is only 3 weeks old and is averaging about 500 unique users per day with my highest day being 1200. Ideally I would like to have 100,000 unique users per day (I can dream) on average but the requests are not distributed evenly throughout a 24 hour period. The majority of my users are visiting from late morning to early evening in North American time zones. This traffic pattern is fairly typical for a website targeted at native English Speakers. The United States and Canada make up the majority of the native English speaking population on the web. I’m getting a decent amount of traffic from the UK and Australia but they’re not typically visiting during my peak hours of utilization.
My busiest hour is between 4 – 5 pm eastern standard time and during that 1 hour I’m getting about 20% of my blog traffic for the day. If that patters hold true while my site continues to grow and gain a following, will I be able to handle the traffic on my current $10 a month Linode VPS? If my plan is 100,000 I will need to test for 20,000 per hour or 334 per minute during my busiest hour.
How to load test?
There are numerous services and testing frameworks available. I’ve gone with loader.io because it’s easy to use and there is a free plan available that can simulate up to 10,000 simulates users. they are owned by SendGrid so I don’t think they’re going to disappear anytime soon.
Setting everything up and getting started is pretty simple. You register for free (actually free no credit card required). They send you a confirmation email. You validate your email and then you’re ready to add a site. After entering your domain name you have to validate that the site is yours. They do this by having you upload a text or html file containing a unique string. This step is necessary to prevent malicious users from using their service to overwhelm a website. You’re basically designing a test to discover the limits of your web site that is almost identical to a denial of service attack if your web site can’t handle the load that you’re going to be sending at it. I’ve included a screen-cap below of the test adding interface it’s all pretty simple. You point them at a URL and tell them how many users you want to simulate over a given period of time. You can start the test immediately or schedule the test for when you your site is usually under light load. It’s not a good idea to load test a live site that you or your clients are dependent on for revenue. You may want to point the test at a development server.
It’s important to note that the free version of loader.io only loads a single URL and doesn’t load any included js, css or images or run any javascript that may be making api calls. This isn’t a problem for me since CloudFlare is serving up all of my static content and I’m not making any api calls. If you are making many API calls in JavaScript then this might not be a suitable solution for your load testing needs.
What do the results look like?
I’m fairly confident in the way I’ve set up this WordPress blog It may only be a $10 Linode VPS that it’s running on but I’ve configured WP Super Cache and Nginx is really good at serving static files. I’m also using CloudFlare as my content distribution network. I think that my site can handle 10,000 users per minute. Let’s see if I’m correct.
So it looks like sending 10,000 requests at my server in a minute resulted in 100% success. If my site is capable of serving 10,000 users in a minute it should be fine handling 100 – 200 thousand users per day without any problem.
If you would like to see more detailed results from my test here’s a link to the results on loader.io
Update:
After my initial post I decided to to test the limit of my current configuration. I ran tests with 15,000, 17,500 and 20,000 requests per minute.
I handled 15,000 requests pretty well. –15,000 report–
At 17,500 my response times were starting to get pretty bad but the site was still functional. –17,500 report–
20,000 requests per minute brought this site down response times were over 3 seconds and about 1/3 of the requests resulted in a timeout error. I had to abort the test at 55 seconds. –20,000 report–
So now I know If I’m getting more than 15,000 page requests per minute I’ll need to do some upgrades. Realistically though I would upgrade long before that.
If you test your site, please post the results here in the comments. Let us know what kind of hosting you are using and your configuration. If you’re results aren’t that great I’ll try to give you some advice and help you improve them.
If you would like to test your own site
Try loader.io for Free
If you’re in need of a great web host I highly recommend that you
After reading through all of this you’ve decided that you would rather leave the management of you server in the hands of professionals have a look at
CloudWays offers VPS management on top of DigitalOcean’s network
That’s it for this post. I hope that you’ve found the information it contains useful. If you have any questions, criticism, advise or suggestions please leave me a comment below and let me know. If you would like to stay updated about new content on OdinSQL.com I would like to invite you to join my email list by filling out the short form on the right side navigation. I promise not to fill your inbox with spam if you do.