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

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • NGINX With Eureka Instead of Spring Cloud Gateway or Zuul
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)
  • Component Tests for Spring Cloud Microservices
  • A Robust Distributed Payment Network With Enchanted Audit Functionality - Part 2: Spring Boot, Axon, and Implementation

Trending

  • Prioritizing Cloud Security Risks: A Developer's Guide to Tackling Security Debt
  • Introduction to Retrieval Augmented Generation (RAG)
  • The Perfection Trap: Rethinking Parkinson's Law for Modern Engineering Teams
  • Driving DevOps With Smart, Scalable Testing
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Adding Rate Limiting for Spring Cloud Netflix Zuul

Adding Rate Limiting for Spring Cloud Netflix Zuul

Take a look at supported rate limiters and how to implement them for Spring Cloud Netflix Zuul API gateway for microservices.

By 
Marcos Barbero user avatar
Marcos Barbero
DZone Core CORE ·
Jun. 13, 18 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
18.3K Views

Join the DZone community and get the full member experience.

Join For Free

In the development of APIs, sometimes it's necessary to control the rate of the traffic received by the network to prevent attacks such as DoS or to limit the number of requests a single user/origin can make to a certain endpoint.

In microservices architecture, the API Gateway is the entry point for the whole application, and having rate limiting in this layer suits it perfectly.

Spring Cloud Netflix Zuul

Spring Cloud Netflix Zuul is an Open Source API Gateway that wraps Netflix Zuul and adds quite a few functionalities, sadly rate limiting is something that's not provided out of the box.

Adding Rate Limit on Zuul

To fix that problem, it's possible to use this OSS Rate Limit library along with Spring Cloud Netflix Zuul, which will add out-of-the-box support for rate limiting the requests.

Supported Limiters

The current implementation supports a list of rate limit policies per service, as well as a default configuration for every other service, if necessary.

Type Description

Authenticated User

Uses the authenticated username or 'anonymous'

Request Origin

Uses the user origin request

URL

Uses the request path of the downstream service

Global configuration per service

This one does not validate the request Origin, Authenticated User or URI. To use this approach just don’t set any type


Supported Storage

  • In Memory
  • Consul
  • Redis
  • JDBC (Uses Spring Data JPA)
  • Bucket4j
    • JCache
    • Hazelcast
    • Ignite
    • Infinispan

Implementation

All the rate-limiting implementation is done using Zuul Filters and applying the validations based on the configuration set per service, in case there's no policy set, then the rate limit filters are not triggered.

When a limit is reached the API Gateway returns 429 Too Many Requests status code to the client.

Configuration

Everything described above can be configured using properties or YAML files and there's no need to add any custom code to make it work.

Further Details

For further details on the implementation and usage, please go to the project repo.

zuul rate limit Spring Cloud Spring Framework

Published at DZone with permission of Marcos Barbero, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • NGINX With Eureka Instead of Spring Cloud Gateway or Zuul
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)
  • Component Tests for Spring Cloud Microservices
  • A Robust Distributed Payment Network With Enchanted Audit Functionality - Part 2: Spring Boot, Axon, and Implementation

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!