APIs lie at the very heart of modern applications and evolving digital architectures, with API calls representing 83% of all web traffic, according to the Akamai State of the Internet Security Report. In today’s landscape, where it’s so easy for consumers to switch to a digital competitor, it is of the utmost importance for them to have a positive experience with your site or app. Speed is highly valued, and is ultimately driven by responsive, healthy, and adaptable APIs. If you get this right – your API is faster than your competitor’s – developers will choose you.
However, it’s a major challenge for most businesses to process API calls in as near to real time as possible. According to the IDC report APIs — The Determining Agents Between Success or Failure of Digital Business, over 90% of organizations expect a latency of less than 50 milliseconds, while almost 60% expect latency of 20 milliseconds or less. (Latency is defined as the amount of time it takes for your API infrastructure to respond to an API call – from the moment a request arrives at the API gateway to when the first byte of a response is returned to the client.) We’ve used this data, together with some end-to-end analysis of the API lifecycle, to define a real‑time API as one with latency of 30ms or less.
So, how do your APIs measure up? Are they already fast enough to be considered real time, or do they need to improve? Does your product feel a bit sluggish, but you can’t quite place why that is? Maybe you don’t know for sure what your API latency looks like?
Enter rtapi
– a real‑time API latency measurement tool created by NGINX to test the responsiveness of your API endpoints and create a PDF report that you can easily distribute and socialize among your peers.
Running rtapi
-
Download the
rtapi
binary from GitHub, using one of two methods:-
If you have Golang installed, run this command:
$ go get github.com/nginxinc/rtapi
-
Navigate to github.com/nginxinc/rtapi/releases, download the latest binary for your platform, and make it executable.
-
-
Specify one or more API endpoints (targets) that you wish to query, in JSON format as in the following example. We recommend saving the JSON in a file called endpoints.json, but you can also provide it in the next step as a string on the
rtapi
command line.The only required parameters for each endpoint are
target.url
andtarget.method
. If you don’t specifytarget.body
andtarget.header
, they remain empty. If you don’t specify a parameter in thequery_parameters
object, the default for it shown in the following example is used.
[
{
"target": {
"url": "https://www.example.com",
"method": "POST",
"body": "{\"id\":\"0\"}",
"header": {
"Content-Type": [
"application/json"
]
}
},
"query_parameters": {
"threads": 2,
"max_threads": 2,
"connections": 10,
"duration": 10,
"request_rate": 500
}
}
]
Run the following command, where -f
is the name of the file containing a JSON‑formatted list of API endpoints and -o
is the name of the PDF report to be generated by rtapi
(you can substitute --file
for -f
and --output
for -o
).
$ rtapi -f endpoints.json -o report.pdf
Comments
Comments are closed.