Search code examples
springnetflix-eurekaspring-cloud-gateway

What are the differences between spring cloud gateway and eureka service discovery?


I am new to spring cloud and want to know that spring cloud gateway and euroke doing the same thing? I read the docs but does not get clear information about differences.

Could you please enlighten me?


Solution

  • These are two totally different things basically:

    From the documentation of spring cloud gateway:

    Spring Cloud Gateway features:
    
    Built on Spring Framework 5, Project Reactor and Spring Boot 2.0
    
    Able to match routes on any request attribute.
    
    Predicates and filters are specific to routes.
    
    Hystrix Circuit Breaker integration.
    
    Spring Cloud DiscoveryClient integration
    
    Easy to write Predicates and Filters
    
    Request Rate Limiting
    
    Path Rewriting
    

    So think about it as a single "entry point" to your application that can consist of tens or even hundreds of different microservices at the backend.

    However you don't want that end user will know all the addresses of these micro-services, so you place the gateway in front of them. The user knows one service only, but you route the request in the gateway to the corresponding microservice.

    Now as for the eureka. Its a registry of all microservices that you have. When microservice starts it can say: "hey eureka, I'm microservice of type ABC and I'm ready to serve the requests on host/port XYZ"

    Now when another microservice wants to talk microservice ABC it can (implicitly) go to eureka and obtain a list of up-to-date actual hosts/ports on which instances of microservice of type ABC are available. And all this whithout knowing the actual hosts ports of ABC but only by logical name "ABC".

    Note, that gateway when redirects requests to microservices can also contact eureka to resolve actual host/ports.

    So Eureka is a service registry, an inventory of all the services that you have.