Cross-Cutting Concerns in Microservices | Microservice Architecture — Ep. 22
Let’s return to our migration from a monolith. Imagine we’ve successfully split it into dozens of microservices. Some services are internal, some face clients.
The company grows, the number of clients increases — along with their demands:
- new devices
- new protocols
- new response formats
- new pricing tiers
Multiple services, combined with lots of clients lead to complex inter-service relations.
If we take a naive approach and extract domain slices into services along with everything required to provide proper access — every team will be solving the same set of problems.
Each service now has to:
- support multiple communication protocols
- handle authentication
- evaluate tenant tiers
- manage throttling and load balancing
- collect logs, metrics, and tracing data
There is one more problem — data aggregation. Many endpoints need data from multiple services. To reduce latency, we introduce caching, but:
- some queries are hot, others are rarely used
- some queries require near real-time freshness
- different clients may need different response shapes
- different clients may want to combine data from different domains
Aggregation services risk becoming bloated and complex, with clusters of similar endpoints coupled to specific client needs, and excessive duplication of both code and cached data.
How can we address these problems?