0
votes

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?

  1. 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

  1. 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:

  1. Direct access to cluster and databases
  2. Fast response

Cons:

Complex microservices parts, blending layers

What variant is more preferable or is another best?

1

1 Answers

0
votes

Checkout the Kong project, which has a nice diagram on their github page showing how you want to think about an API gateway. Also you may want to consider using them for your implementation.