examples icon indicating copy to clipboard operation
examples copied to clipboard

Request: Add cross-service rate limiting example

Open vozi-tech opened this issue 4 months ago • 0 comments

Description

It would be valuable to have a dedicated example demonstrating how to implement rate limiting that can be shared across multiple services in an Encore application.

Background

While the repository includes a ts/middleware example that covers rate limiting and authorization middleware, a more comprehensive example focused specifically on cross-service rate limiting would be beneficial for developers building microservices architectures.

Proposed Implementation Approaches

The example could demonstrate:

  • Redis-based rate limiting: Using Redis as a shared state store to track rate limits across multiple service instances
  • Distributed rate limiting patterns: Implementing token bucket, leaky bucket, or sliding window algorithms
  • Centralized rate limiting service: Creating a dedicated rate limiting service that other services can call

Use Cases to Cover

  1. API Gateway Rate Limiting: Enforcing global rate limits at the gateway level before requests reach individual services
  2. Per-User Rate Limiting Across Services: Tracking and enforcing rate limits for specific users across multiple microservices
  3. Service-to-Service Rate Limiting: Protecting internal service APIs from being overwhelmed by other services
  4. Tiered Rate Limiting: Implementing different rate limits based on user subscription levels or API keys

Language Support

Implementations in both TypeScript and Go would be helpful to serve the full Encore community.

Benefits

This example would help developers:

  • Implement proper rate limiting in microservices architectures
  • Prevent service abuse and ensure fair resource usage
  • Protect backend services from being overwhelmed
  • Learn best practices for distributed rate limiting

Thank you for considering this request!

vozi-tech avatar Oct 04 '25 07:10 vozi-tech