DEV Community

Cover image for Rate limiting Rails Apps without a reverse proxy 🛡️
Flora Brandão for Upsun

Posted on

Rate limiting Rails Apps without a reverse proxy 🛡️

When you cannot put Varnish in front of your application, the edge is no longer yours. You have to handle rate limiting from inside the app itself to protect your quality of service.

Rails 8 now simplifies this by shipping rate limiting features out of the box. Using rack-attack, you can manage traffic before the application even wakes up. Here is what you need to know about implementing this:

  • Handle rate limiting at the middleware layer
  • Configure your limits using plain Ruby
  • Decide where to store your counters for performance
  • Apply caps to both anonymous and authenticated traffic
  • Choose the specific layer that fits your unique constraints

Check out the full technical write-up to see how to implement these internal controls in your Rails environment.

Rate limiting Rails apps when you can't put Varnish in front - Upsun Developer

When the edge isn't yours, rate limit from inside the application. How rack-attack works, why limits are about quality of service, and what Rails 8 changed.

favicon developer.upsun.com

Top comments (0)