Is Your API Real Time? Test Its Latency and Responsiveness with the rtapi Tool from NGINX
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 byrtapi
(you can substitute--file
for-f
and--output
for-o
).$ rtapi -f endpoints.json -o report.pdf
Interpreting the Report
The report generated by rtapi
contains a graph of response latency like the following (from an NGINX Plus API gateway configured using the NGINX Controller API Management Module). The Y axis shows latency in milliseconds, and the X axis shows the proportion of calls processed in less than a given latency, expressed as a percentile. For your API to be considered real time, latency for the 99th percentile (99% on the graph) needs to be less than 30ms.
How Can NGINX Help?
Is your API’s latency below 30ms?
If you’re like many companies we talk with, chances are it’s not. With many API gateway and API management solutions, latency of 100ms is common, and even 500ms is not that unusual.
We can help you improve your API performance – NGINX and NGINX Plus are the fastest API gateway in the industry, and together with NGINX Controller can help you route, authenticate, secure, shape, and cache API calls in less than 30ms. Learn more, talk to an NGINX expert, and discover how NGINX can help you on your journey towards real‑time APIs at nginx.com/real-time-api.
The post Is Your API Real Time? Test Its Latency and Responsiveness with the rtapi Tool from NGINX appeared first on NGINX.
Source: Is Your API Real Time? Test Its Latency and Responsiveness with the rtapi Tool from NGINX