Your dealer portal, your mobile app and two partner integrations all connect to the same backend services. Each service opens its own address, writes its own authentication, applies its own rate limit and keeps its own log format. As the number of services grows, the same rule ends up living in six places, then ten, and one of them gets forgotten. An API gateway is the layer that pulls this sprawl into a single entry point: clients talk only to the gateway, and the gateway forwards each request to the right service.
In this guide we explain what an API gateway is, how it differs from a load balancer and a service mesh, which jobs it takes on, the risks of added latency and a single point of failure, staged routing, and how to calculate payback. All example figures are illustrative; they are not the performance or price of any specific product.
What Is an API Gateway?
An API gateway is the single entry point that receives every API request coming from outside, applies the rules, and forwards the request to the appropriate backend service. The client does not know how many services sit behind it or where each one runs; it only knows the gateway's address.
It brings three benefits: simplicity for clients (one address, one authentication style), rule delegation for services (no service rewrites the same code) and visibility for the business (who calls which endpoint, and how often). We covered what APIs are and how they connect systems in our API integration guide; this article focuses on the layer placed in front of those connections.
We recommend reading: Our integration services
How Does an API Gateway Differ from a Load Balancer and a Service Mesh?
All of them manage traffic, but at different levels and for different questions. A load balancer answers "which instance?", while a gateway answers "may this client call this endpoint, and which service should it go to?".
| Component | Main job | Understands the API? | Typical place |
|---|---|---|---|
| Load balancer | Spreads traffic across instances of the same service | No; address and port level | In front of a service or the gateway |
| Reverse proxy | Forwards requests from one address to the backend, terminates TLS | Limited | Public edge |
| API gateway | Identity, quota, routing, transformation, logging | Yes; endpoint and client level | Single entry for traffic from outside |
| Service mesh | Manages the internal traffic between services | Service-call level | Internal network, east-west traffic |
| Backend for frontend | Gathers data for one specific interface (for example mobile) | Yes; specific to that interface | Behind or next to the gateway |
In practice they work together: a load balancer sits in front of the gateway instances, the gateway handles traffic from outside, and a service mesh manages internal traffic. We discussed the broader design questions on the service side in our microservices architecture guide.
Which Jobs Does an API Gateway Take On?
A gateway takes on eight jobs, and each has a "should not do" side. If you do not draw the line, the gateway slowly becomes a bottleneck that accumulates business logic and that nobody wants to touch.
| Job | What it does | Should not |
|---|---|---|
| Routing | Forwards to the right service by path and version | Decide on business rules |
| Authentication delegation | Verifies tokens and keys, passes the verified identity to the internal service as a header | Decide object-level permission on its own |
| Rate limit and quota | Limits requests per client, rejects the excess | Use the limit as a business rule |
| Cache | Stores unchanging read responses at the gateway | Put user-specific replies into a shared cache |
| Request and response transformation | Adds headers, adapts field names and format | Do heavy data conversion or calculation |
| Aggregation | Combines several service calls into one reply | Run long workflows |
| Logging and monitoring | Assigns a trace ID, collects latency and error metrics | Write secrets into logs |
| Circuit breaker | Temporarily cuts off an unhealthy service and returns a fast error | Swallow the error silently |
The difference between authentication and authorization is critical here. The gateway answers "who is this client?"; the decision "does this record belong to this client?" stays in the service that owns the record. See our API security guide for the full framework. Internal services must accept traffic only from the gateway; if the gateway can be bypassed, every rule loses its meaning.
How Do You Calculate Added Latency and Capacity?
A gateway adds a hop, so every request becomes slightly slower. What matters is that this cost has a budget and is measured.
In the illustrative example the backend responds in 120 ms. The gateway adds 6 ms for routing and authentication and 4 ms for transformation and logging. Added latency is 6 + 4 = 10 ms, total 120 + 10 = 130 ms, an increase of 10 ÷ 120 = 8.3%. If the target p95 response time is 200 ms and the backend p95 is 150 ms, the figure after the gateway is 160 ms, leaving a 40 ms margin.
| Item | Time | Note |
|---|---|---|
| Backend response | 120 ms | Without the gateway |
| Routing + authentication | 6 ms | Token check served from cache |
| Transformation + logging | 4 ms | Header addition, trace ID |
| Added latency | 10 ms | 6 + 4 |
| Total | 130 ms | +8.3% (10 ÷ 120) |
How Do Caching and Rate Limiting Reduce Backend Load?
Because the gateway can filter requests before they reach the backend, it also pays off on the load side. Two mechanisms stand out.
Cache. Suppose you receive 1,200,000 requests a day and 70% are reads, that is 840,000 requests. For frequently read, rarely changing replies such as product and price lists, if the cache hit rate is 60% of reads, 504,000 requests never reach the backend. Backend load falls to 1,200,000 − 504,000 = 696,000 requests, a reduction of 504,000 ÷ 1,200,000 = 42.0%. We covered the details of cache design, invalidation and expiry decisions in our caching guide.
Rate limit. A partner's faulty loop produces 5,000 requests per minute, while the per-client limit is 300 per minute. The gateway turns away 4,700 requests with a 429 reply and backend load drops from 5,000 to 300, a reduction of 4,700 ÷ 5,000 = 94%. For quota and plan design, see our API key and quota guide.
What Do Aggregation and Shared Rules Add?
There are two more gains: the client makes fewer calls, and shared rules live in one place.
Aggregation. A mobile home screen needs data from four services (orders, stock, prices, balance). If the client makes four separate calls, each costs roughly 120 ms of round trip on the mobile network, and the services take 40, 35, 50 and 30 ms to process. Sequentially the time is 4 × 120 + (40 + 35 + 50 + 30) = 480 + 155 = 635 ms. The gateway receives a single call and goes to the four services in parallel; the slowest service takes 50 ms. The time becomes 120 + 50 + 10 (gateway) = 180 ms, a drop of (635 − 180) ÷ 635 = 71.7%.
Shared rules. With six services and five shared rules (authentication, rate limiting, logging, TLS settings, header policy), applying them in each service means 6 × 5 = 30 implementations; at the gateway it is 5. If changing a rule takes 2 hours per service, that is 6 × 2 = 12 hours, versus 2 hours in one place at the gateway. With 8 changes a year it is 96 hours against 16; the difference is 80 hours, which at ₺300 per hour is ₺24,000.
How Do You Manage the Single-Point-of-Failure Risk?
Every request passes through the gateway, so if it goes down, no service can be reached. This risk is real and is the most misunderstood point: the answer is not to avoid the gateway but to avoid running it as a single instance.
In the illustrative calculation a 30-day month is 43,200 minutes. If a single gateway instance is 99.9% available, monthly downtime is 43,200 × 0.001 = 43.2 minutes. With two independent instances behind a 99.99% load balancer (assuming the instances fail independently), the gateway-side failure probability is 1 − (1 − 0.000001) × 0.9999 ≈ 0.000101 and monthly downtime falls to roughly 4.4 minutes. In reality instances are not fully independent; they share the same version, configuration and environment, so this result is an optimistic upper bound.
| Scenario | Gateway availability | Monthly downtime (gateway) | Chain (gateway × 99.9% service) |
|---|---|---|---|
| Single instance | 99.9% | 43.2 min | 99.8% (≈ 86.4 min) |
| Two instances + balancer | ≈ 99.990% | ≈ 4.4 min | ≈ 99.89% (≈ 47.6 min) |
The chain column assumes the request depends on the gateway and on a single service; a request that passes through several services takes longer. A broken routing rule affects both instances at once, so the gateway configuration is kept under version control and released in stages. Monitoring and alerting are mandatory for readiness.
How Do You Release a New Version Safely with Staged Routing?
Because the gateway can send a share of traffic to a new version, it shrinks release risk. The impact of a faulty version is proportional to the share routed to it.
1,200,000 requests a day is 50,000 requests an hour. Assume you observe the new version for 4 hours at each stage: 200,000 requests flow in total. At the 5% stage, 10,000 requests go to the new version; at 25%, 50,000. If the version is faulty, switching straight to 100% affects 200,000 requests in 4 hours; caught at the 5% stage, 10,000 are affected. The difference is 200,000 ÷ 10,000 = 20 times.
| Stage | New version share | Requests in 4 hours | Condition to proceed |
|---|---|---|---|
| 1 | 5% | 10,000 | Error rate ≤ 1.2% (baseline 0.8%) |
| 2 | 25% | 50,000 | Errors and p95 latency within thresholds |
| 3 | 100% | 200,000 | Old version kept ready for a while |
Rollback is also quick: setting the routing weight to zero does not require redeploying the service and takes about a minute. Feature flags, the application-side counterpart of this idea, are a separate topic; the gateway only manages the traffic share.
When Is an API Gateway Unnecessary or Problematic?
Not every architecture needs a gateway. In these cases the benefit may not cover the cost.
- One service, one client: With no scattered rules, the layer only adds latency.
- Two or three services that are not changing: Applying shared rules in the services may be cheaper.
- Very tight latency budget: If every millisecond counts, the extra hop may be unacceptable.
- Business logic creeping in: If calculations and rules pile up at the gateway, everyone depends on it and changes become unmanageable.
- Unclear ownership: If the gateway has no owner, rule changes wait in a queue.
Document the gateway's public interface too; our API documentation guide covers this, and for changes that break clients see our API versioning guide.
How Do You Calculate Payback?
For an illustrative dealer portal we set up the gateway in 24 person-days: 24 × ₺9,000 = ₺216,000 investment. Annual gross benefit has three items:
- Shared-rule effort: the ₺24,000 calculated above.
- Adding new services: 4 new services a year; shared-rule integration per service drops from 3 days to 0.5 days; the gain is 4 × 2.5 = 10 person-days, 10 × ₺9,000 = ₺90,000.
- Smaller incident impact: in 2 faulty releases a year, the incident cost falls from ₺60,000 to 20 times less with staged routing, that is ₺3,000; the gain is 2 × (60,000 − 3,000) = ₺114,000.
Gross benefit is 24,000 + 90,000 + 114,000 = ₺228,000. If gateway infrastructure and maintenance cost ₺6,000 a month, ₺72,000 a year, net benefit is ₺156,000 a year, ₺13,000 a month. Payback is 216,000 ÷ 13,000 ≈ 16.6 months.
If the expected gain halves (only the incident item, ₺114,000, materializes), net benefit is 114,000 − 72,000 = ₺42,000 a year, ₺3,500 a month, and payback is 216,000 ÷ 3,500 ≈ 61.7 months. The gap shows the decision depends on your number of services and release frequency; recalculate with your own figures.
How Do You Set Up an API Gateway? Six Steps
- Take an inventory: List which client calls which service through which endpoint.
- Identify the shared rules: Separate the rules every service repeats, such as authentication, rate limiting, logging and header policy; leave business logic out.
- Write the latency budget: Settle the added-latency limit and the measurement method up front.
- Build high availability: At least two instances with a load balancer in front; configuration under version control.
- Close the internal services: Services should accept only traffic coming through the gateway; block direct access at network level.
- Start with one endpoint: Move a low-risk read endpoint first, widen with staged routing and watch the measurements.
We recommend reading: How to Design a REST API: Resource Naming, Pagination, Error Format and Idempotency Guide
API and Integration Architecture with İnovabil
At İnovabil our focus is building bespoke software from scratch: custom software, ERP, CRM, e-commerce, web, mobile and integration. For a system with several clients and services, we recommend assessing in writing during requirements analysis whether an API gateway is needed, based on the number of services, the kinds of clients and the latency budget; in small systems, postponing the layer can also be the right call.
We have built CRM, purchasing and mobile for Avcılar İnşaat; a purchasing system for İZBAN; a prepaid cargo system for Kredili Kargo; logistics and shipment planning with wholesale order management for Karyak; and warehouse management plus a complaint and support management system for Sleepy. Send us a short summary of your system's clients and services and we will assess the architecture together.
We recommend reading: Our software development process: step by step from analysis to release
Frequently Asked Questions
What is an API gateway, and what is it for in short?
It is the single entry point for all API requests coming from outside. It does shared jobs such as authentication, rate limiting, routing, caching and logging in one place and forwards the request to the right service.
Is an API gateway the same as a load balancer?
No. A load balancer spreads traffic across instances of the same service and does not understand the API. A gateway decides at endpoint and client level; a load balancer is often used in front of the gateway as well.
Does an API gateway reduce performance?
It adds latency because it adds a hop; in the example that is 10 ms, or 8.3%. Caching, aggregation and rate limiting can still pay back overall by cutting backend load and client call counts; decide by measuring.
Isn't the gateway a single point of failure?
It is if you run a single instance. At least two instances, a load balancer in front and versioned configuration reduce this risk. In the example monthly downtime falls from 43.2 minutes to about 4.4 minutes; because of the independence assumption this is an optimistic bound.
Does a small system need an API gateway?
Usually not. With one service and one client, or just two or three services, the layer can add latency and operating load instead of benefit. The decision changes as the number of services and clients grows.