Upgrade to Pro — share decks privately, control downloads, hide ads and more …

12 Steps to API Load Testing with Apache JMeter

12 Steps to API Load Testing with Apache JMeter

http://wso2.com/cloud/api-cloud This tutorial takes you through creating and running load tests for your API.

Load-testing is an important aspect of API management, and helps ensure that your API gateway is ready to sustain the load coming from API subscribers through developer portal, command-line, scripts, web applications, and mobile apps.

The blog version of this deck is available at: http://wso2.com/blogs/cloud/load-testing-published-apis-with-jmeter/

Apache JMeter can be downloaded from: http://jmeter.apache.org/download_jmeter.cgi

Free trial of WSO2 API Cloud is available at http://wso2.com/cloud/api-cloud

Avatar for DSotnikov

DSotnikov

March 11, 2016
Tweet

Other Decks in Technology

Transcript

  1. Apache JMeter and API load testing • Apache JMeter™ is

    a popular free, open source software, designed to load test functional behavior and measure performance • It was originally designed for testing Web applications but has since expanded to other test functions • Load-testing your APIs allow you to know in advance what kind of load from subscribers and applications your gateway can sustain
  2. 1. Publish your API and subscribe to it • If

    using WSO2 API Cloud, get yourself a free trial and follow these tutorials:
  3. 2. Download and launch JMeter 1. Download from: http://jmeter.apache.org/download_jmeter.cgi 2.

    Unzip the package 3. Start Apache JMeter: ◦ sh jmeter.sh on Linux or Mac ◦ jmeter.bat on Windows.
  4. 3. Add your test • Right click the Test Plan

    node and click the Add / Threads (Users) / Thread Group on the shortcut menu:
  5. 4. Add API call request • Right click the Thread

    Group and click the Add / Sampler / HTTP Request on the shortcut menu:
  6. 5. Copy over server name and path • Invoke API

    in API store’s API console and copy over Server Name and Path to HTTP Request in JMeter:
  7. 6. Add authorization header 1. Right click the HTTP Request

    node and, on the shortcut menu, click Add / Config Element / HTTP Header Manager 2. In the HTTP Header Manager, click the Add button. A new row will get added to the table of Headers Stored in the Header Manager 3. Set Name to Authorization 4. And copy the Bearer part from API Console
  8. 7. Add listener to see results • Right click the

    Thread Group node and, on the shortcut menu, click Add / Listener / View Results Tree:
  9. 8. Test the API • Click the Run button and

    verify that the API call was successful. If prompted to save the configuration, do so.
  10. 9. Increase the load • To be able to test

    at larger load, go back to the Thread Group node, and increase the Number of Threads and Loop Count:
  11. 10. See when and why calls fail • Check out

    the Response data tab to see why • Limits imposed by Subscription Tier you set for the API (e.g. 20 calls / minute) result in “You have exceeded your quota” • Limits based on your API Cloud subscription level lead to “Your request was blocked due to exceeding the allocated quota. Please contact the API Store owner to resolve this.”
  12. 11. (Optional) Simulate more subscribers 1. Create another subscriber account

    or another application in API Cloud 2. Subscribe to the API 3. Create another HTTP request in Apache JMeter with this new application’s authorization header
  13. 12. (Optional) Distributed load 1. Deploy Apache JMeter on multiple

    machines 2. Copy the saved test plan 3. Run the following command line or the corresponding .bat command on Windows: sh jmeter.sh -n -t TestPlan.jmx -l Test1.jtl where -t specifies the saved Test Plan file and -l specifies the output file for the responses
  14. API Management Options on the Market Hosted Service: WSO2 API

    Cloud free trial at : • http://wso2.com/cloud/api-cloud Open Source: WSO2 API Manager free download at : • http://wso2.com/api-management/try-it/