A Fun and Easy Introduction to API Performance.

Analysing, Understanding, and Optimising

Ishani Dabral
Walmart Global Tech Blog
6 min readAug 19, 2024

--

1. Image source: Freepik

Introduction

APIs (application programming interfaces) are the unsung heroes of our favourite digital tools, working hard behind the scenes to make sure everything runs smoothly. But like any hard worker, their performance needs to be checked regularly to ensure they’re at the top of their game. That is where API performance analysis comes in.

Analysing your APIs’ performance is like giving them a regular health check-up. It helps you catch potential issues before they become major headaches, saving you time, money, and a whole lot of stress. Plus, it helps you keep your users happy with a smooth and responsive experience — and happy users are what we’re all aiming for, right?

Not only that, but performance analysis also gives you the insights to make smart decisions about your APIs. Maybe you need to add more APIs to share the load, tweak a few settings on your current ones, or perhaps replace an underperforming API altogether. Whatever the case, performance analysis is the key to making these decisions with confidence.

The Inside Track on API Performance Analysis

Industry pros use several tried-and-true methods to keep track of their APIs. Here are some terms you are likely to encounter:

2. Image Source: Freepik

1. Latency: Ever felt like time stood still while waiting for a webpage to load? That is exactly what we want to avoid. By measuring the time, it takes for an API to perform a request, we can identify and rectify any sluggishness. It’s like keeping a watchful eye on time, ensuring that every interaction happens swiftly and smoothly.

2. Error Rates: We have all seen those annoying error messages pop up when things do not go as planned. Monitoring how frequently these hiccups occur with your API is crucial. It is like having a radar for issues, allowing you to pinpoint and address any potential problems before they escalate.

3. Throughput: Think of this as the highway of your API. You want to know how many cars (requests) it can handle per second to avoid any traffic jams i.e. about how many successful requests your API can handle over time — kind of like its endurance level.

4. Availability: Imagine repeatedly visiting a store only to find it closed each time — frustrating, right? The same frustration applies to your API if it’s not available when needed. Monitoring uptime ensures that your API is always open for business, ready to serve requests whenever they come knocking. It’s like ensuring that the doors to your digital storefront are never shuttered.

5. Payload: Just as a heavy backpack can weigh you down and slow your pace, a large payload can bog down your API’s response time. Monitoring the size of data transferred in each request is crucial. It’s like lightening your load, ensuring that interactions happen swiftly and efficiently without unnecessary bulk.

6. API Call Trends: Keeping tabs on usage patterns unveils valuable insights into peak usage times, popular endpoints, and the heavy hitters making the most requests. It’s like having a bird’s-eye view of your API’s landscape to meet user needs effectively.

Ways to measure API performance:

  1. Performance measuring tools: JMeter is a powerful, open-source software designed to load test functional behaviour and measure performance. Think of it as a personal fitness coach for your APIs, helping you evaluate their speed, strength, and stamina under diverse conditions. But what does it do, exactly? JMeter is all about stress testing your APIs. It pushes them to their limits, helping you understand their breaking point and how much they can handle before they start to buckle under pressure. It’s like a workout for your APIs, ensuring they’re in top-notch shape to handle any scenario.
  2. Metrics Dashboards: Think of tools such as Grafana, Istio, and Splunk (and various others like New Relic, Datadog) as the diagnostic tools for your API performance analysis. Istio dashboards offer an abundance of metrics, encompassing everything from latency and traffic to errors and saturation, providing a comprehensive health check for your APIs. Grafana, on the other hand, is a powerhouse for visualizing and understanding your data. Meanwhile, let’s not forget Splunk. Known as the Google for machine data, Splunk is a versatile tool that enables real-time and historical search capabilities, along with generating graphs, reports, alerts, and visualisations.

Ways to optimise API performance

3. Image Source: Freepik
  1. Caching: Remember how you could recall your best friend’s phone number without thinking? That’s your brain’s version of caching. Similarly, in the realm of APIs, caching involves storing the results of common requests. By doing so, it speeds up response times, just like how remembering that phone number saved you time and effort.
  2. Rate Limiting: Picture a vigilant nightclub bouncer keeping the crowd in check. Rate limiting acts as the bouncer for your API, ensuring that users or services don’t overwhelm it by bombarding it with too many requests in a short span. This ensures fair access and prevents overload, much like the bouncer maintaining order at the entrance.
  3. Load Balancing: Have you ever tried to distribute your shopping bags evenly in both hands so that no one hand is overburdened? That’s similar to load balancing — It’s about intelligently distributing incoming requests across multiple servers, ensuring that no single server is overloaded. This keeps the system running smoothly, just like evenly distributing the weight of your bags prevents discomfort.
  4. Data Optimisation: This is like decluttering your closet. You reduce the space taken up by getting rid of unnecessary clothes, folding the rest properly, or even using methods that allow you to pick out only the clothes you need for the day. Similarly, in the world of APIs, you can reduce the payload size by removing unnecessary data, compressing data (ex Gzip), providing data incrementally in the form of paging (pagination)or using techniques that allow clients to request only the data they need (ex GraphQL). This streamlines data delivery, making interactions more efficient, much like a well-organized closet makes finding what you need a breeze.
  5. Asynchronous Processing: It’s like ordering a coffee and a croissant at a cafe. You don’t wait for the coffee to be ready before ordering the croissant. Similarly, asynchronous processing in APIs allows long tasks to run independently, without blocking other requests. It’s like keeping things moving smoothly in a busy café, ensuring that one order doesn’t hold up the entire queue.
  6. Use a CDN: Ever wish you could clone yourself to be in two places at once? A Content Delivery Network (CDN) can do this for your API, reducing latency by serving requests from the server closest to the user. It’s like having multiple versions of yourself strategically placed, ensuring that everyone gets what they need swiftly and efficiently.
  7. Regularly Update and Patch Your API: Just like updating your wardrobe or fixing a flat tire, keeping your API up-to-date and patched ensures you’re always at your best.
  8. Connection Pooling: Think of connection pooling like a car rental service, but for your database. Just like you wouldn’t buy a new car every time you need to drive somewhere,
    your application doesn’t need to create a new connection each time it wants to talk to your database. Instead, it can just “rent” one from the pool.
    When your application starts up, it creates a bunch of connections (let’s call them cars) and puts them in the pool (our rental lot). When you need to send a query (or take a drive), you borrow a connection from the pool, use it, and then return it when you’re done.
    The beauty of this is that the expensive part — setting up the connections (or manufacturing the cars) — is done upfront. Borrowing and returning connections from the pool is super quick and efficient, just like renting a car. Plus, there’s always a connection ready for you, so no waiting around!

A Deeper Dive

Performance analysis isn’t just a one-and-done deal — it’s an ongoing process of learning and improving. The more you analyse, the better you will understand your APIs and how to get the best out of them. The upcoming article dives into the fascinating world of technicalities using industry standards to get a detailed look at your API’s performance.

--

--