I try create some microservices based on Akka which use CQRS. So my microservice has write (send command to cluster) and read side (read projections from database) with Http endpoints, but this is not the main problem. Because of many microservices, the question arose as to collect complex API for clients. I found answer: API Gateway pattern. But I have next question: How can I implement it?
I can create separate project, which will implement API Gateway pattern (in simple case it is a reverse proxy). Full stack will be:
Load balancer -> API Gateway project -> Load balancer -> Microcervice read part -> Database -> Microcervice write part -> Akka cluster
Pros:
API Gateway separate project with own abstractions
Cons:
Two balancers, and not so fast proxy in API Gateway project
API Gateway (auth, etc) implemented in Microservice parts, load balancer will collect endpoints in complex API. Full stack will be:
Load balancer -> Microcervice read part (with public API) -> Database -> Microcervice write part (with public API) -> Akka cluster
Pros:
- Direct access to cluster and databases
- Fast response
Cons:
Complex microservices parts, blending layers
What variant is more preferable or is another best?