Performance Testing on API Management Platform

When working on the development of the application, the primary focus goes to implementing new functionalities to meet your customers’ expectations. Unfortunately, under the pressure of deadlines or other factors, people tend to forget about non-functional aspects, such as security, usability, or as in this case — performance.

What is an API management platform?

An API management platform is a tool used to access, distribute, control, and analyze APIs used by developers in an enterprise setting. API management platforms benefit organizations by centralizing control over their API integrations while ensuring they continuously meet high performance and security standards.

In this article, I would like to tell you why and how to do performance testing for an API Management Platform using the K6 tool and how to implement it.

Why do we need performance testing for an API management platform?

If you are wondering why it is worth spending extra time to take care of performance tests, the following list should be very helpful to your cause:

  • You get to know the speed and stability of your platform — just making sure that even with increased user activity, the functionalities in your platform are still running smoothly.
  • You are prepared for unexpected traffic — regardless of the circumstances and great opportunities, you can be confident that your store will handle a huge number of orders, e.g. during Black Friday.
  • You improve scalability — with cloud solutions, you make sure that with an increased flow of API requests, the architecture of your platform allows it to scale smoothly.
  • You identify bottlenecks — not all errors are detectable during manual, automatic, or security tests. Thanks to the performance tests, you can discover even more

Nowadays several API Management Platforms are available as Software as a service (SaaS). Even though you use a SaaS application, you have to handle your Data inside the organization. For this most of the enterprises use Proxy servers (Forward proxy and Reverse proxy). eg: F5 application

By using a performance test tool you can get Round-trip time (RTT). But when it comes to performance testing on an API Management Platform you need to get a detailed breakdown for this RTT. Let’s consider the following user requirement.

As a user, I need to execute 2500 Transactions per second (TPS) on API Management Platform, so that I can scale the plaform for higher performance.

Network Traffic flow

Need to consider the following factors as well.

  1. Performance testing tool should be able to execute a load of 2500 TPS
  2. The latency added by the tool should be a minimum value
  3. Need to know the latency between each network hop
  4. Need to capture error responses and send to AWS CloudWatch for further analysis
  5. Test results should be accurate and need to be visualized.

Why k6?

Below are some of the most important features in k6 that satisfied me during the evaluation:

  • Scriptability​ & Automatability
  • Low learning complexity​
  • Easy integration with CI/CD, reporting, and APM platforms
  • High accuracy and performance​
  • Comprehensive documentation
  • High community support

Ragnar Lönn, who contributed to the early development of k6, has published a comprehensive load testing tool evaluation in 2020 which, even though may seem a little biased towards k6, has some very detailed reviews and comparisons on famous open source tools we have today.

Requirement # 1 and # 2

Use k6 as the performance testing tool.

Requirement # 3

To get proxy time In/Out, you can add an iRule. Also, refer to your API Manager to get the timestamps. Build your logic to calculate the latency and add them to the response header.

Also, please make sure that both the API Management platform and your network use the same NTP source. If you are counting milliseconds for your platform SLA, then you will notice a time difference (2–3 ms)

Requirement # 4

  • You need to set up a Datadog agent in your test client.
  • Download the sample k6 test script. You will need to modify the script based on your response headers.
  • To send error responses to CW, you need to configure the CloudWatch agent. Please refer here. Mention the `file_path` as console.log
  • Use the following command to execute your test script,
K6_STATSD_ENABLE_TAGS=true k6 run --out statsd myFirstScript.js --console-output=console.log --logformat=raw --tag test_run_env=perf

Once you set up your CW agent, you can filter the error logs as you need.

AWS CloudWatch

Result Verification

k6 Console Test Output

Following is the equation for the total time calculated by the k6 built-in metrics,

http_req_duration = http_req_sending + http_req_waiting + http_req_receiving

2 ms = 18.65 µs + 1.47 ms + 558.83 µs

Based on the above flow diagram,

http_req_sending = Test client → Forward proxy

http_req_receiving = Forward proxy → Test client

http_req_waiting = forwardProxyToPlatformLatency +requestProcessingTime + plaformToReverseProxyLatency + reverseProxyToBackendLatency+backendToReverseProxyLatency +reverseProxyToPlatformLatency+ responseProcessingTime + plaformToForwardProxyLatency

Requirement # 5

To visualize k6 test results, first I tried out InfluxDB (v1.8.9) + Garafana. By default, k6 generates and sends a large amount of unique series to InfluxDB that would lead to a large amount of cardinality. Due to this, it took more time to load the test data into your visualization tool. You can find a workaround here.

To get more insights into this issue, I used Chronograf and run the same script. Following are the Statistics of the InfluxDB when k6 data are written to the DB,

Following are the Statistics of the InfluxDB when k6 data are read by the visualization tool,

k6 Integration with Datadog

Due to the above issue, I used Datadog for the visualization.

The Datadog agent includes the DogStatsD service to collect and aggregate metrics. DogStatsD implements the StatsD protocol with some extensions. For example, DogStatsD tagging allows to collect k6 metrics with tags to distinguish between requests for different URLs, response statuses, groups, etc. As it receives data, DogStatsD aggregates multiple data points for each unique metric into a single data point over a period called the flush interval (ten seconds, by default).

Datadog Dashboard

Download this Datadog dashboard template and export it to your Datadog application.

Phew, you’ve got to the end! I hope you’ve learned something valuable today and performance tests became more accessible to you. Using tools like k6 makes performance testing extremely easy but provides so much valuable information about your platform.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dilshan Fernando

Quality Engineering | Test Automation Engineer | AWS Certified Solutions Architect | Problem Solver