Simulate Heavy Traffic and Avoid Crashes with Load Testing

7 min read
Oct 26, 2023 8:23:00 AM

With seasonal high-level traffic, you’ll need to be prepared tremendously if you expect higher-than-usual traffic volumes. Load testing is one way to ensure your e-commerce site can withstand the increased traffic volume and spot any potential issues you’ll face during peak periods.

During Black Friday 2022, Amazon sales increased by 440% in Germany and 269% in the USA. A study from Deloitte shows that a one-second increase in load times causes page views to reduce by 11%, customer satisfaction to decrease by 16%, and conversions to decrease by 4.42%. A BigCommerce study found that even a one-second delay can cause conversion rates to dip by as much as 7%, as end-users are unwilling to wait when they can visit a competitor instead.

The ultimate cause of bottlenecks can be a feature, microservice, your infrastructure, or even your architecture. So, in this article, we will talk about why load testing is crucial to prepare for heavy traffic and how to prepare your website in advance with Gatling Enterprise to move in the right direction.


Why is it essential to load tests during the holiday season? 

Manage high peaks of traffic:

Studies have shown that traffic to the top 100 shopping sites increased by 137% on Black Friday and 112% on Cyber Monday. Many e-commerce websites experience high traffic during the holiday shopping season.

How do you check the amount of traffic your application will get? The best way is to look at the past traffic. If you have a website with consistent traffic, you can check your previous years’ analytics to understand what you can expect.

 

Reduce chances of website crashes:

With load testing, you can identify the amount of traffic that will break your website or cause an outage.

What you’re testing is the response times and errors for the requests and API calls that occur when users are accessing and navigating your website. After you complete a test, you’ll be able to see if any requests or API calls are slow or run into errors and what amount of traffic is causing them to experience these issues. It can further help you identify the resources needed to prepare for the high-traffic peaks and the required changes in the infrastructure before the sale begins.

 

Prevent losing potential sales to a competitor:

Consumers are getting impatient day by day, especially during the holiday season. According to a study conducted by Hobo in 2023, 40 percent of consumers will wait no more than three seconds for a web page to render before abandoning the site. A large amount of traffic means a large amount of sales and revenue.

Similarly, each second a website is down during the high-level traffic, it can cause huge losses. Research by UserWay identified that e-commerce retailers could lose an estimated $828 million in revenue during Christmas due to poor website accessibility.

 

What factors affect your application during the heavy traffic season?

When you browse a website on a computer or open an app on your smartphone, it is essential to have a fast enough loading time and display quality that doesn’t diminish the user experience, especially during the heavy traffic season. The application’s performance can be measured using the response time to load the different contents. Response time is simply the time between a user’s request and the receipt of a response. At this time, the request is transmitted and processed by the server, and the response is transmitted back to the user.

There are two types of performance:

 

Front end:

The time for the browser to load and display the web page elements. Depending on the elements and animations on the site, the response time can be longer or shorter.

The front-end response time depends mainly on the performance of the visitor’s browser. The website will load using the web browser’s memory: if the user has a low-performance device, then the website will take much longer to be displayed than with a modern and powerful device. To address this, you can adapt the scripts and the image sizes embedded on your site.

 

Back end:

Mainly the server response time (calculation time), and in the case of a server overload, some requests can timeout or go up as an error.

The back-end response time is related to your application or website server performance. Suppose your web server is poorly dimensioned and can’t keep up with the load and the increase in visitors. In that case, users will experience degraded performance, which will strongly impact the user experience. If you are new to this area, remember there are 5 steps to help build your load-testing strategy.


How do we commence load testing during the holiday season?

Software development and preparations begin months before the actual heavy traffic season arrives. The perfect time to start load testing is during the initial software development process. Could not start early? It is never too late to start load testing with Gatling Enterprise.

Gatling Enterprise is constantly adding new features. You can commence your load-testing with or without code. Let us discover how!

 

Load-testing without code

With the heavy traffic season approaching, the first load test should be effortless. Gatling created a new feature, a code-like approach with a no-code interface to run your simulations in minutes. With the latest feature, you can quickly implement your load testing strategy by choosing the injection profile amongst capacity, stress, and soak tests. Next, closely match your requirements and access your complete Gatling reports. Gatling is constantly upgrading and adding additional features to the no-code generator to have tests closest to the actual user journey.

 

Load-testing with code

To go a step further, Gatling’s code-like scripting enables you to easily maintain your testing scenarios and seamlessly automate them in your continuous delivery pipeline. Gatling ships with a powerful DSL (Domain Specific Language) that makes it simple to construct a detailed load test. You can quickly develop scripting scenarios using Scala, Java, and Kotlin and can support integrations including Maven, Gradle, SBT, GitHub actions, Jenkins, Grafana, Bamboo, TeamCity, GitLab, Slack, and Microsoft Teams. How do we create a successful load testing to tackle high-level holiday traffic?

 

Start with a simple scenario:

For example, let us write a code in JAVA to test a simple scenario of loading the home page while preparing for Black Friday. Here, we define our Black Friday test simulation class (BlackFridayLoadTest). We define the protocol we want to use (HTTP) and supply the default parameters. For our script, we supply our web application’s base URL.

Now, we can define the steps of the scenario. These are the steps that the virtual user will take on our website when we execute the load test. You can modify the steps to replicate the accurate user behavior for your actual load test.

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;

import io.gatling.javaapi.core.*;
import io.gatling.javaapi.http.*;

public class BlackFridayLoadTest extends Simulation {
    HttpProtocolBuilder baseHttpProtocol = http.baseUrl("https://my-ecom-website.com");

    ScenarioBuilder scn = scenario("simple test")
            .exec(
                    http("Load Home Page")
                            .get("/")
            );

    {
        setUp(
                scn.injectOpen(atOnceUsers(1))
        ).protocols(baseHttpProtocol);
    }
}

 

Get a realistic user journey

You probably have a good idea of how you’d like your user to experience your website:

1. User Journey

However, users might have a different process. It’s essential to use analytics tools to find out how your users are using your website. Once you’ve done that, you can use the Gatling Recorder to replicate this journey and then add different injection profiles to complete your scripts.

 

Execute different types of tests

This load test profile is suitable for creating and debugging our Gatling script. But to ensure our web application is ready for the holidays, we must define a suitable injection profile. Do we expect users to arrive at specific periods throughout the day, or is it more likely to be a steady stream of traffic? Can we manage sudden spikes of traffic?

There are several test types: capacity, stress, and soak test. The stress and soak tests are the most relevant during the holiday season. A stress test can help us determine if our application can sustain a sudden spike in traffic during these events. Soak tests can assess our website’s resilience throughout the long event, Black Friday, Cyber Monday, Christmas shopping season, etc.

 

Measure response time through Gatling reports

Beyond looking at errors and the error rate in our load test, the critical metric to monitor is transaction response times. At Gatling, we monitor these broadly in percentiles.

Measuring response times in percentiles is far superior to relying on the average and standard deviation. These enable you to accurately reflect what performance is like for the given percentage of your users. In our load testing results, if the 99th percentile was shown as 100ms, 99% of users experienced a response time of 100ms or less.

Presenting metrics to stakeholders in this way is of far greater value. Remember that we want to ensure that the vast majority of users of our site have a great experience, with fast load times and good performance.

Gatling Enterprise Laptop Product

 

Conclusion

The heavy traffic season is a perfect reason to start investing in your load-testing efforts, but once the season ends, you shouldn’t stop there. Surges in traffic or unexpected load on your system could happen any time of the year, and your system needs to be ready to handle this.

Developing load-testing scripts with Gatling no-code is an excellent place to start. You must then take load testing to the next level with distributed load testing, on-demand, and detailed real-time reporting. Gatling Enterprise’s load-test-as-code is the natural solution to progress to.

A minimal investment in high-quality load testing with Gatling Enterprise, self-hosted or in the cloud version, is worthwhile. You can never know when that next spike in traffic will come. Hence, it is essential to ensure your system and your business are ready to handle and take advantage of it.