API Gateway Patterns: Rate Limiting, Auth and Routing
Back to blogs
Published

API Gateway Patterns: Rate Limiting, Auth and Routing

E
DevNexus
October 21, 2026
1 min read
4,603 views
0 comments
1 minute read · architecture

An API Gateway is the front door to your microservices handling cross-cutting concerns.

Rate Limiting with Redis

const key = `rate:${ip}`;
const count = await redis.incr(key);
if (count === 1) await redis.expire(key, 60);
if (count > 100) return res.status(429).json({ error: 'Too many requests' });

JWT Validation at Gateway

const payload = jwt.verify(token, process.env.JWT_PUBLIC_KEY, { algorithms: ['RS256'] });
req.headers['x-user-id'] = payload.sub;

Service Routing

location /api/users/  { proxy_pass http://user-service:3001; }
location /api/posts/  { proxy_pass http://post-service:3002; }

Conclusion

Centralise auth, rate limiting and routing at the gateway. Keep services simple.