API Management 101: Rate Limiting (2024)

API rate limiting is one of the fundamental aspects of managing traffic to your APIs. It is important for quality of service, efficiency and security. It is also one of the easiest and most efficient ways to control traffic to your APIs.

What is API rate limiting and how does it work?

An API rate limit refers to the number of calls the client (API consumer) can make in a second. Rate limits are calculated in requests per second (RPS).

Let’s say you only want a client to call an API a maximum of 10 times per minute. You can apply a rate limit to expressed as “10 requests per 60 seconds”. The client will be able to call the API successfully up to 10 times within any 60-second interval. If they call the API any more within that timeframe, they’ll get an error stating they have exceeded their rate limit.

Benefits of rate limiting

API rate limiting can:

  • Help with API overuse caused by accidental issues within client code, which results in the API being slammed with requests.
  • Prevent a denial-of-service (DoS) attack meant to overwhelm the API resources, which could easily be executed without rate limits in place.
  • Protect your API from other events that would impact its availability.
  • Ensure that everyone who calls your API receives an efficient, quality service.
  • Support various API monetisation models.

What are the different types of rate limiting?

There are different ways that you can approach API rate limiting.

Key-level rate limiting is focused on controlling API traffic from individual sources and making sure that users are staying within their prescribed limits. You could limit the rate of calls the user of a key can make to all available APIs (i.e. a global limit) or to specific, individual APIs (a key-level-per-API limit).

API-level rate limiting assesses all traffic coming into an API from all sources and ensures that the overall rate limit is not exceeded. This limit could be calculated by something as simple as having a good idea of the maximum number of requests you could expect from users of your API. It could also be something more scientific and precise, such as the number of requests your system can handle while still performing at a high level. You can quickly establish this threshold with performance testing.

Which type of API rate limiting should you use?

These two approaches have different use cases. They can also be used in unison to power an overall API rate limiting strategy.

The simplest way to figure out which type of rate limits you should apply can be determined by asking a few questions:

  • Do you want to protect against denial of service attacks or overwhelming amounts of traffic fromall usersof the API? Then, go for anAPI-level global rate limit!
  • Do you want to limit the number of API requests a specific user can make toall APIsthey have access to? Then choose akey-level global rate limit!
  • Do you want to limit the number of requests a specific user can make to specific APIs they have access to? Then it’s time for akey-level per-API rate limit.

How to implement rate limiting in API environments

If you want to implement API rate limiting, you have various strategies available to you, including several algorithm-based approaches. These include:

  • Leaky bucket– a first come, first served approach that queues items and processes them at a regular rate.
  • Fixed window– a fixed number of requests are permitted in a fixed period of time (per second, hour, day and so on).
  • Moving/sliding window– similar to a fixed window but with a sliding timescale, to avoid bursts of intense demand each time the window opens again.
  • Sliding log– user logs are time stamped and the total calculated, with a limit set on the total rate.

How to test API rate limiting

It’s important to test that your API rate limit is working as it should. It’s not the kind of thing you want untested when you’re facing a DoS attack! There are companies that will undertake API pen testing to test how robust your API security is, including how well your rate limiting works.

You’ll also need to check your API rate limits are still appropriate as your business grows. An API management tool with a handy dashboard should make it easy for you to see which limits you have in place.

How long does the rate limit last?

There is no fixed answer to how long an API rate limit lasts. It is common to apply a dynamic rate limit based on the number of requests per second, but you could also think in terms of minutes, hours or whatever timeframe best suits your business model.

What is API throttling vs rate limiting?

There are two ways that requests can be handled once they exceed the prescribed limit. One is by returning an error (via API rate limiting); the other is by queueing the request (though throttling) to be executed later.

You can implement throttling at key or policy level, depending on your requirements. It’s a versatile approach that can work well if you prefer not to throw an error back when a rate limit is exceeded. By using throttling, you can instead queue the request to auto-retry.

Throttling means that you can protect your API while still enabling people to use it. However, it can slow down the service that the user receives considerably, so how to throttle API requests needs careful thought in terms of maintaining service quality and availability.

What does “API rate limit exceeded” mean?

“API rate limit exceeded” means precisely what it says – that the client trying to call an API has exceeded its rate limit. This will result in the service producing a 429 error status response. You can modify that response to include relevant details about why the response has been triggered.

How to bypass an API rate limit

While API rate limiting can go a long way towards protecting the availability of your APIs and downstream services, it is not without its flaws. Some individuals have worked out how to bypass an API rate limit. In fact, they’ve worked out several ways to do so.

If you use an IP-based rate-limiter, rather than key-level rate limiting, people could bypass your limits using proxy servers. They can multiply their usual quota by the number of proxies they can use.

Key-based API rate limiting can also be bypassed, by people creating multiple accounts and getting numerous keys.

There are other techniques out there, such as using client-side JavaScript to bypass rate limits, so be aware that knowing how to rate limit API products doesn’t make them impervious to being bypassed!

We mentioned pen testing above. While you’re thinking about API functionality, performance and testing, why not check out this article on API testing tools?

API Management 101: Rate Limiting (2024)
Top Articles
Net Profit or Loss for the Period, Fundamental Errors and Changes in Accounting Policies-MASB
What’s The Best Loan To Buy A House? A Guide To Different Loan Options | Quicken Loans
Riverrun Rv Park Middletown Photos
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Bj 사슴이 분수
O'reilly's Auto Parts Closest To My Location
Obor Guide Osrs
Ixl Elmoreco.com
Mcoc Immunity Chart July 2022
South Carolina defeats Caitlin Clark and Iowa to win national championship and complete perfect season
Anki Fsrs
Infinite Campus Parent Portal Hall County
Uvalde Topic
Nalley Tartar Sauce
Buff Cookie Only Fans
VMware’s Partner Connect Program: an evolution of opportunities
Unlv Mid Semester Classes
Craftology East Peoria Il
Costco Gas Foster City
Jayah And Kimora Phone Number
FDA Approves Arcutis’ ZORYVE® (roflumilast) Topical Foam, 0.3% for the Treatment of Seborrheic Dermatitis in Individuals Aged 9 Years and Older - Arcutis Biotherapeutics
Allentown Craigslist Heavy Equipment
Eine Band wie ein Baum
Stoney's Pizza & Gaming Parlor Danville Menu
Greenville Sc Greyhound
12 Facts About John J. McCloy: The 20th Century’s Most Powerful American?
Craigslist Ludington Michigan
Coindraw App
Summoners War Update Notes
Frank Vascellaro
Www.1Tamilmv.con
Tripcheck Oregon Map
The Bold and the Beautiful
Wega Kit Filtros Fiat Cronos Argo 1.8 E-torq + Aceite 5w30 5l
Jr Miss Naturist Pageant
拿到绿卡后一亩三分地
Stafford Rotoworld
Infinite Campus Parent Portal Hall County
9 oplossingen voor het laptoptouchpad dat niet werkt in Windows - TWCB (NL)
Cl Bellingham
Blackwolf Run Pro Shop
'The Night Agent' Star Luciane Buchanan's Dating Life Is a Mystery
18 Seriously Good Camping Meals (healthy, easy, minimal prep! )
Sml Wikia
Samantha Lyne Wikipedia
March 2023 Wincalendar
Lsreg Att
Bumgarner Funeral Home Troy Nc Obituaries
Skybird_06
Fishing Hook Memorial Tattoo
Obituaries in Westchester, NY | The Journal News
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6424

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.