Sunday, March 3, 2019

Running your first Gatling load test in 10 minutes or less

Gatling report

How many concurrent users can your infrastructure handle? Do you know when your most critical features have regressed in performance? Will your website survive a Denial of Service attack? If you are unsure, Gatling's lightweight and powerful capabilities will help answer these questions.

Advantages of Gatling

  • Gatling is load testing as code which is ideal for integration with DevOps, Continuous Integration, and build tools.
  • Simulate thousands of requests per second against your APIs and applications.
  • Identify or troubleshoot performance and load issues.
  • Are your APIs and website C10k compliant? Determine how many concurrent users your infrastructure, APIs, and applications can handle.
  • Test your public APIs and applications against Denial of Service attacks.
  • Automatically generates an exhaustive, dynamic, and colorful report with high-precision metrics.
  • Performance is measured in percentiles which is more reliable than averages.

Gatling Installation (5 minutes)

Gatling has several installation options:

Gatling Directory Structure

Source code directory:

  • $GATLING_HOME/user-files/simulations (directory for your Scala load tests)
  • $GATLING_HOME/user-files/resources (directory for your users.csv file if you need a load test with multiple unique authenticated users)

Running your first load test (5 minutes)

  1. Copy/Merge the user-files directory from my GitHub repo to your local $GATLING_HOME directory. The $GATLING_HOME directory will be your Gatling download directory. Refer to the user-files/simulations directory for tests.
  2. Run Gatling locally as a standalone application by running the following command:
    • On Linux/Unix: $GATLING_HOME/bin/gatling.sh
    • On Windows: %GATLING_HOME%\bin\gatling.bat

    Gatling will prompt a few questions:

    • Which test to run? Choose any test simulation to run.
    • Enter an optional test description? Hit enter to skip.
    • When the simulation is done, the console will display a link to the HTML reports.

Load Test Examples

Refer to the user-files/simulations directory for test examples. I have a few authenticated and unauthenticated load tests for REST APIs and a website. The authenticated tests refer to user data (users.csv). The Gatling installation also has several load tests for Web applications (refer to tests in $GATLING_HOME/user-files/simulations/computerdatabase).

Reports

Load test reports are automatically generated in $GATLING_HOME/results when your load test completes. Refer to the console when your test finishes for the full path. Gatling creates beautiful charts!

Gatling report

No comments :

Post a Comment