9 Microservices Patterns Every Backend Engineer Must Articulate - Part 1
From the 6 timeless distributed systems foundations to the 3 modern patterns dominating today’s production architectures Most backend developers can name microservices patterns. Very few can clearly articulate the exact
From the 6 timeless distributed systems foundations to the 3 modern patterns dominating today’s production architectures
Most backend developers can name microservices patterns. Very few can clearly articulate the exact problem each one solves, the trade-off you accept when you introduce it, and when to avoid it altogether.
When you are learning distributed systems—or preparing for a senior engineering interview—it is easy to blur these concepts together because they always sit side-by-side on architecture diagrams.
And over the last few years, the backend landscape has shifted noticeably. The industry has pulled back from hyper-fragmented “nano-services” toward pragmatic modularity, guaranteed event delivery, and AI-ready APIs.
In this guide, we will break down the 6 classic foundations alongside the 3 modern patterns every backend engineer should have in their mental toolkit—complete with modern Java/Spring tooling notes for each.
The 6 Timeless Foundations
- Database per Service
The Problem: When multiple services share a single relational database, teams become tightly coupled at the schema level. One column rename or index change can silently break another team’s service.
The Fix: Give each service its own private database. Other services are forbidden from querying those tables directly and must go through well-defined APIs or asynchronous events.
The Trade-off: You lose cross-service SQL joins and native foreign-key constraints. Distributed data consistency becomes an application-level responsibility.
When NOT to use it: Early-stage products where domain boundaries are still shifting weekly.
Modern Java Stack: Spring Data (JPA, JDBC, MongoDB, Redis) supporting polyglot persistence—using isolated schemas or dedicated database instances tailored to each bounded context.
- API Gateway
The Problem: Exposing dozens of internal microservices directly to external browsers and mobile apps creates a massive security surface, inconsistent authentication, and tight coupling between client code and internal service URLs.
The Fix: Place a single entry point in front of your services to centralize routing, authentication, rate limiting, SSL termination, and observability.
The Trade-off: If you overload the gateway with custom business logic or complex transformations, it quickly becomes a monolithic bottleneck and a single point of failure.
When NOT to use it: Internal-only service-to-service communication inside a trusted private network (where a service mesh or internal load balancer fits better).
Modern Java Stack: Spring Cloud Gateway, Kong, or Envoy.
- Backend for Frontend (BFF)
The Problem: A mobile app on a spotty cellular connection needs small, compact JSON payloads, while a desktop web dashboard needs rich, aggregated data. A single generic API ends up bloated for mobile and under-fetching for web.
The Fix: Build a dedicated adapter layer per client experience (e.g., a Mobile BFF and a Web BFF) that aggregates downstream service calls and shapes payloads specifically for that UI.
The Trade-off: More deployable services to maintain and the risk of duplicating validation or orchestration logic across different BFFs.
When NOT to use it: When you only have one client type or when GraphQL already lets clients query the exact fields they need.
Modern Java Stack: Lightweight Spring Boot (with Java 21/25 Virtual Threads for concurrent downstream aggregation) or Node.js/TypeScript BFFs.
- CQRS (Command Query Responsibility Segregation)
The Problem: Complex, normalized write models designed for data integrity often perform poorly when serving heavy, filtered read queries or analytics dashboards.
The Fix: Split state-changing Commands (Write DB) from data-fetching Queries (Read DB). Sync changes asynchronously from the write side to optimized, denormalized read views.
The Trade-off: Eventual consistency. Users may briefly see stale data on the read side immediately after submitting a write.
When NOT to use it: Standard CRUD domains where read and write traffic are balanced and simple SQL queries perform fast enough.
Modern Java Stack: Spring Boot + PostgreSQL (Write side) streaming updates to Elasticsearch, Redis, or read-optimized PostgreSQL views.
- Event Sourcing
The Problem: Standard database updates overwrite the previous row value. You know what the current state is, but you lose the complete history of how and why it got there.
The Fix: Store every state change as an append-only sequence of immutable domain events (e.g., OrderPlaced, PaymentCaptured, ItemShipped). Reconstruct current state by replaying those events.
The Trade-off: Steep learning curve, tricky event schema evolution over time, and slower state reconstruction unless you maintain periodic snapshots.
When NOT to use it: Simple catalog or configuration data where full temporal audit logs and time-travel debugging add no business value.
Modern Java Stack: Axon Framework, EventStoreDB, or Kafka paired with custom event stores.
- Saga Pattern
The Problem: Traditional distributed two-phase commit (2PC) locks do not scale across independent microservices and introduce severe availability bottlenecks.
The Fix: Break a multi-service workflow into a sequence of local ACID transactions. Coordinate them either via events (Choreography) or a central state-machine controller (Orchestration). If step 3 fails, execute compensating transactions to undo steps 1 and 2.
The Trade-off: Debugging partial failures and writing idempotent rollback logic across asynchronous services is significantly harder than a single local transaction.
When NOT to use it: Inside a single database or modular monolith where a standard @Transactional boundary already guarantees atomicity.
Modern Java Stack: Temporal, Camunda, or Spring State Machine. NextPage
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.




