When scaling web applications, stores and websites – it’s often useful to estimate web traffic by looking at the peak traffic you will receive. Such an estimate can be used to make sure that your solution will scale to the required levels when needed. With some metric to estimate the peaks, you can also estimate how much server resources are required for your web hosting solution to handle the desired amount of traffic.
To make estimation easy, a tool you likely have available is Google Analytics. In Google Analytics you can easily find the day on which you have received the highest amount of traffic earlier. For many, this day is something you’ll remember – because that often is the moment where you find out that your hosting setup did not scale like you might have hoped for.
Having a web hosting solution that does not automatically scale to handle your peak traffic will result in increasing response times, both for your website visitors, and for your team working in the backend. At some point, you may even experience that the website becomes completely unresponsive and starts throwing errors of various sorts. This can be proxy errors in the 5xx range or other timeouts.
Page views per second
At Servebolt we use the metric page views per second (pvs in short form) as the key metric to estimate and scale web solutions. The page views per second metric captures almost all important aspects of serving web requests at the peaks. It does not capture bandwidth, but that is very rarely an actual scaling problem, because most setups that require some scale effectively use caching correctly and CDNs to offload bandwidth demanding content.
The fine thing about page views per second is that it can fairly easily be estimated for any website, using data that is always available. The input can be from Google Analytics, or if you’re more of a techy – you can use log files to get even more precise data. Precision is not very important though, because our back of the envelope estimation usually is good enough.
The formula we use to estimate the peak page views per second is as follows:
Peak page views per second = (Max Historic Daily Page Views / 6) / 3600 seconds
Max historic daily page views is a number you can easily find in Google Analytics by going to Site Content > All Pages, and selecting the last year as the time period – in the daily view.
In the example above, you can see the peak was at January 24, generating a peak of 205 000 page views. If we inject this number into the estimation formula, we get:
Peak page views per second = (205 000 / 6) / 3600 = 34166 / 3600 = 9,49 which means ~10 page views per second
You’ll always want to round up this number to be on the safer side, so for simplicity we can say that this peak would require your hosting to handle 10 concurrent page views per second.
The page view estimation explained in detail
- The formula takes a daily number of page views as the input (205 000)
- We then spread this traffic over 4 hours instead of 24, which resembles a general website traffic pattern. This gives a roughly estimated max load of 34 166 page views per hour.
- The number we’re looking for, is page views per second. Therefore, we convert the hourly number to per second, by dividing the hourly by 3600
To simplify calculation, you can of course just divide the daily page views directly by 129600 – which will get you the same result. However, we usually do not do that, because we may want to make adjustments to some of the variables.
By looking at the hourly data on your peak traffic day, you may for example identify that the majority of traffic happened just within the time frame of two hours. You can then easily change the formula, so that you don’t divide by 6, but rather just by 2. Then the estimation changes to a peak page view estimate of 205 000 / 2 / 3600 = 28,47 – which is about 29 page views per second.
Similarly, you can change the peak page view number if you have reason to believe that the campaign you are running will grow traffic. You may have doubled the amount of subscribers to your news letter, or the amount of users in the Facebook group that produced your previous peak.
Scaling of server resources
With an estimate of your peak requirements, it is easy to validate that you on the server side have enough resources to deal with the traffic. You can either do it your self or ask your hosting provider to calculate how much traffic your website can handle. With a good estimate of page views per second – you can easily make sure that it will work!
The server resources required will largely depend on your Time to First Byte, which is a capture-all measurement of the server resources that are needed to deliver a single web page. This is a metric you can improve in numerous ways. You can for example check out our article how to scale WooCommerce or how to make WooCommerce fast.
Let us know if you have success with your estimations in the comment thread!