Menu
Dev.to #systemdesign·May 23, 2026

Choosing an API Gateway or BFF for Microservices

This article presents a common system design challenge: managing multiple backend services from a mobile client. It highlights the complexities introduced by direct client-to-service communication and proposes architectural patterns like API Gateways and Backend-for-Frontend (BFFs) to reduce coupling and simplify client integrations. The core problem is effectively centralizing concerns like routing, authentication, and error handling.

Read original on Dev.to #systemdesign

The article describes a scenario where a mobile application directly consumes multiple backend microservices (UserService, OrderService, PaymentService, and an upcoming NotificationService). This direct communication leads to increased coupling on the client side, forcing mobile developers to handle individual service domains, authentication schemes, and error formats, which becomes unmanageable as the number of services grows.

The Problem: Tight Coupling and Client-Side Complexity

When a client interacts directly with numerous microservices, it inherits the complexity of managing each service's lifecycle, endpoint, security, and data contracts. This can lead to several issues:

  • Increased mobile app development overhead for integrating new services.
  • Higher risk of breaking changes in the mobile app when backend services evolve.
  • Security challenges with managing multiple authentication tokens and whitelisting various domains.
  • Inconsistent user experience due to varying error formats and response structures.

Proposed Solutions for Decoupling

The article offers four potential solutions to address the client-side complexity, which are common architectural patterns in distributed systems:

  1. API Gateway: A single entry point for all client requests, routing them to the appropriate backend service. It abstracts the microservice topology from the client, providing a unified API.
  2. Backend for Frontend (BFF): A specialized API layer tailored for a specific client type (e.g., mobile, web). It aggregates data from multiple backend services, transforming and optimizing responses for the client's needs, reducing client-side logic.
  3. Load Balancer: Primarily distributes network traffic across multiple servers. While it can provide a single IP, it doesn't solve the application-layer problems of domain management, authentication, or response shaping.
  4. GraphQL Federation: A system where multiple GraphQL services combine to form a unified schema. Clients query this single schema, and the federation layer resolves the queries by fetching data from underlying services. This can simplify data fetching for complex UIs.
💡

Key Takeaway

The core problem highlighted is the management of application-level concerns (authentication, routing, data shaping) at the client layer. While load balancers handle network traffic, API Gateways, BFFs, and GraphQL Federation address these higher-level architectural challenges by introducing an intermediate layer between the client and backend services.

API GatewayBFFBackend for FrontendMicroservicesClient-Server CommunicationDecouplingGraphQL FederationAPI Management

Comments

Loading comments...