Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microservices - What is the exact difference between service discovery and Service Gateway?

I read the articles like : What is the difference between an API-Gateway and an Edge Service?, but still not clear on what's the exact difference between the service discovery (say Eureka) and Service Gateway (Zuul) ? Any pointers?

enter image description here

like image 904
Jeff Cook Avatar asked Dec 08 '22 13:12

Jeff Cook


2 Answers

The Services gateway (a.k.a. API gateway) is receiving requests from the clients. It is the (single) service that the clients see. But it doesn't know by itself how to do what the clients want so it must forward the request to another service. It inspects the URL and extracts the name of the service that will actually serve the request, the backend service. That backend service may be located on a different machine. It may have a dynamic address or port, that may change from time to time, from different reasons (nodes fail, new nodes are added to the network etc).

So, the gateway doesn't know where to forward the request. This is the job of the Service-discovery service (Eureka). Eureka knows on which node is located and at which address and port every service is listening for requests. The gateway is asking Eureka where it can find the backend service (by sending it only its name). After Eureka is responding, the gateway is forwarding the request to that address.

like image 158
Constantin Galbenu Avatar answered Jan 15 '23 23:01

Constantin Galbenu


The differences is more understandable if you focus in responsabilities of both Zuul and Eureka. As you can see below each one has specific tasks. Thats the main differences.

enter image description here

like image 25
Ebert Toribio Avatar answered Jan 16 '23 00:01

Ebert Toribio