Showing posts with label Netflix. Show all posts
Showing posts with label Netflix. Show all posts

Sunday, June 7, 2020

Server side load balancing using Eureka and Zuul

Routing is an important part of a microservice architecture. In real time cloud application, service instances are added/removed dynamically based on requirement and availability in such scenario its very important to manage traffic load. In the following example you will see how to use Zuul API Gateway to enable sever side load balancing of your RESTful Web Services.

Request flow -

1. When service boots up it registers itself with discovery server. Multiple instances register itself with discovery server. Here spring.application.name is use to identify a particular service

2. Zuul gateway also registers itself with discovery server. Remember Zuul gateway is also a discovery client

3. When client sends request to zuul gateway for a particular service, Zuul gateway queries discovery server to fetch available healthy instance of the service and then accordingly send request to that service.

Please check previous example on Discovery Server.

Discovery code -

Wednesday, June 3, 2020

Spring cloud service discovery example

Real time cloud application consist of a large number of micro services communicating with each other. Service instances are added/removed dynamically based on requirement and availability. Service discovery is the process of one service dynamically discovering the network location (IP address and port) of another service without hard coding their location.


Steps involved in service discovery

1. Service registers location - when service boots up it registers itself with discovery server

2. Client looks for service location - When client needs to hit a particular service first it goes to discovery server for its location

3. Discovery server sends back location - Discovery server sends the active location of the particular service

4. Client request service at location - This is a normal request to the service

5. Service sends response - Service responds to client accordingly

Example -

Started eureka server on default port 8761 and Started 2 instances of Application service on 8081 and 8082