Ch. 10 · Microservices

Microservice API Gateways and Edge Responsibilities

Microservice API Gateways and Edge Responsibilities. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readintermediateupdated Oct 3, 2026

A gateway can centralize routing and selected edge policy. Avoid moving all business orchestration into it and creating a new monolith at the boundary.

Before you start

You should understand HTTP, database transactions and the difference between one process and independently failing services. Draw the participants and message direction before choosing a pattern. Include timeout, duplicate delivery and recovery in the model instead of considering only successful requests.

The practical goal is to reason through this situation: The gateway authenticates and routes while domain services enforce their own authorization. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Assign edge responsibilities

Centralize routing and selected cross-cutting policy.

Step 2: Keep domain ownership

Inventory and payment rules remain in their owning services.

Step 3: Secure alternate access

Domain services authorize operations even when requests bypass the normal gateway.

Worked scenario

The gateway authenticates and routes while domain services enforce their own authorization.

The gateway validates an access token, but the billing service checks whether that caller may refund the particular invoice. A background consumer or internal caller may reach billing through another path. Moving all workflow logic into the gateway makes every domain change depend on that central component.

Common mistake

Trusting gateway checks alone can leave alternate internal access paths unprotected.

Verify the behavior

Test alternate paths and verify domain authorization independently of routing.

Interview exercise

Choose a gateway feature.

Answer and reasoning

Use bounded cross-cutting responsibilities and keep domain invariants within their owning services.

Continue learning

Compare the scenario with the Microservices interview questions and test your understanding with the Microservices MCQs. For terminology and implementation details, consult the reference material.

More in Microservices

read ✓Microservices · hard

Microservices Anti-Corruption Layer

Protect a service's domain model from a foreign or legacy model with a translation layer at the boundary.

~2 min readread →
read ✓Microservices · hard

Microservices API Versioning and Evolution

Evolve service APIs without breaking consumers using additive changes, explicit versioning and consumer-driven contracts.

~2 min readread →
read ✓Microservices · hard

Microservices Backend for Frontend

Use a per-client BFF to aggregate services and shape responses, without letting it become a shared god service.

~2 min readread →
esc