AI Hints
Home›System Design Tutorial›Gateways and Practice
System Design · Lesson 22 of 120

API Gateways

One front door.

⏱ 2 min read▶ Video at 24:59🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

As Shoply grows, it splits into several services. Products, orders, payments, and users. Clients shouldn't need to know about all of them. An API gateway gives them one front door.

API Gateways
From the video: API Gateways
  • Many services
  • Clients shouldn't care
  • One front door

Through the gateway

Every request from an app goes to the gateway first. The gateway checks who the user is. It applies rate limits. Then it routes the request to the right service, based on the path. Slash orders goes to the order service, and slash products goes to the product service.

  1. App
  2. Gateway
  3. Check user
  4. Rate limit
  5. Right service
Through the gateway
From the video: Through the gateway

What gateways handle

Gateways take care of shared jobs, so each service doesn't repeat them. Authentication, rate limiting, routing, logging, and sometimes caching. The risk is that the gateway is now in front of everything, so it must be fast, and run on several machines.

keyvalue
Authenticationwho is this?
Rate limitingnot too many requests
Routingpath to service
Loggingone place to watch

Summary

An API gateway is one front door that handles authentication, limits, and routing for all your services. Next, let's practise. Design Shoply's API.

Key takeaways
  • One entry point
  • Shared jobs in one place
  • Must be fast and redundant
Next up: Practice: Design an API — a shop's endpoints