⬅ Previous Topic
Service-Oriented Architecture (SOA) – A Beginner's GuideNext Topic ⮕
Strangler Fig Pattern in System Design⬅ Previous Topic
Service-Oriented Architecture (SOA) – A Beginner's GuideNext Topic ⮕
Strangler Fig Pattern in System DesignThe API Gateway Pattern is a system design pattern where a single entry point (called the API Gateway) handles all client requests and routes them to the appropriate backend services. It acts as a reverse proxy, taking requests from clients, directing them to the right microservices, and aggregating the results if needed.
In a microservices architecture, there are many small services, each performing a specific task. If clients were to call each service directly, it would lead to complexities:
To solve these problems, we introduce a central component — the API Gateway.
The API Gateway sits between the client and backend services. It performs functions such as:
Imagine you're building an e-commerce platform with the following microservices:
Without an API Gateway, the mobile app would need to call all three services separately. That would mean:
The client calls a single API Gateway endpoint. The gateway then:
Let’s say the client wants to view the homepage:
Answer: Because it introduces complexity, redundancy, and security issues. Each service would need to replicate common concerns (auth, logging), and the client must be aware of all services.
Netflix uses Zuul (an open-source API Gateway) to manage thousands of client devices with diverse network conditions. It provides:
This ensures mobile, smart TVs, and web clients get optimized responses from backend services.
Answer: Yes, it can — if not designed with redundancy and scalability in mind. Typically, it's deployed in a highly available configuration using load balancers and multiple gateway instances.
Use the API Gateway pattern when:
The API Gateway Pattern is essential in microservices-based architecture. It improves system scalability, security, and maintainability by acting as a single point of entry. While it introduces complexity in configuration and monitoring, its advantages often outweigh the drawbacks in distributed systems.
Answer: No. In simple systems with few services or monolithic architecture, it may not be necessary. It becomes important when your system grows and needs better organization, scalability, and centralized control.
⬅ Previous Topic
Service-Oriented Architecture (SOA) – A Beginner's GuideNext Topic ⮕
Strangler Fig Pattern in System DesignYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.