DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Identify API Policies for All Levels in the Application Network With API-Led Connectivity
  • Rate Limiting Strategies for Efficient Traffic Management
  • What Is the Difference Between API Rate Limiting and Throttle Controls?
  • Custom Rate Limiting for Microservices

Trending

  • Issue and Present Verifiable Credentials With Spring Boot and Android
  • AI-Based Threat Detection in Cloud Security
  • Performance Optimization Techniques for Snowflake on AWS
  • The Modern Data Stack Is Overrated — Here’s What Works
  1. DZone
  2. Data Engineering
  3. Databases
  4. Applying Rate Limiting Policy and Spike Control Policy in API

Applying Rate Limiting Policy and Spike Control Policy in API

This article describes applying and testing Rate Limiting Policy and Spike Control Policy in Mule 4 and driving a comparison between the two.

By 
Kuldeep Rana user avatar
Kuldeep Rana
·
Jun. 17, 19 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
18.4K Views

Join the DZone community and get the full member experience.

Join For Free

This article describes applying and testing Rate Limiting Policy and Spike Control Policy in Mule 4 and driving a comparison between the two.

Image title

What Is Rate Limiting Policy?

In Rate Limiting Policy, one is allowed to send only a certain number of requests in a given time interval.

When a request is sent and the rate limit is not reached, the request is processed further. But if the rate limit has been reached, the request is not processed and is terminated.e

What Is Spike Control Policy?

The Spike Control Policy is provided for smoothing API traffic. The policy ensures that within any given period of time, no more than the maximum configured requests are processed.

If there is no request quota in the current window, the policy allows requests to be queued for later reprocessing without closing the connection to the client.

Here, I am applying these policies in my previous article.

Setting up Rate Limiting Policy

In API Manager, Click on the newly created API and click on policies on the left panel.

Click on Apply New Policy and select Rate Limiting policy from the Select Policy Tab.

The configuration for the Rate Limiting Policy:

Image title

Once you click apply on the configuration tab, the policy will be displayed in the API Manager.

Image title

Testing the Rate Limiting Policy

Look at the configuration above.

Only three calls to the API in 1 minute i.e. the API will be requested successfully only 3 times in 1 minute and no more than that.

Image title

Any request to the API above 3 requests will fail it, displaying the message: "error": "Quota has been exceeded"

Image title

The API does not wait for the time to complete to process the request. It will only process the request once the 1 minute time is over (and that only 3 requests).

NO QUEUING OF THE REQUEST  FOR LATER PROCESSING

Setting up Spike Control Policy

Delete the existing Rate Limiting policy and replace it with Spike Control Policy.

Image title

The Configuration of the Spike Control Policy:

Image title

Three requests to the API in 5 seconds and any request exceeding three will wait for 10 seconds to be processed again without losing the connection with the client.

Therefore, Spike Control provides the smoothing of the traffic by restricting the calls to the API for a certain amount of time and lining the request in the queue.

For three request in 5 sec:

Image title

For request exceeding 3, in 5 seconds:

Image title

The page is reloading and will display the result after 10 seconds delay time, therefore restricting the traffic to the API for smooth functioning.

For requests exceeding the time Quota:

This situation occurs when there are many requests waiting in the queue to be processed after the time delay.

Image title

Try changing the configuration values and then see the results.

Conclusion

Rate limiting excluded all the requests if the quota is exceeded, but in the case of Spike Control, the delay time is set, which reduces the number of failing requests even after the quota is exceeded. Hence the smooth flow of traffic.

API rate limit Spike (software development) Requests

Opinions expressed by DZone contributors are their own.

Related

  • Identify API Policies for All Levels in the Application Network With API-Led Connectivity
  • Rate Limiting Strategies for Efficient Traffic Management
  • What Is the Difference Between API Rate Limiting and Throttle Controls?
  • Custom Rate Limiting for Microservices

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!