This is a quick tutorial for creating a REST API client using Spring Cloud Ribbon component. For this tutorial, you will need a running Eureka server and a Eureka client application. In case if you do not have Eureka server or a Eureka client application, check out my previous posts which explain how to setup eureka server and how to develop a eureka client application.
What is Ribbon?
In short, Ribbon is a load balancer. Let’s say you have a service which is used by 1000’s of customers. In that case, you may have multiple instances of service running on multiple servers for load balancing purpose. Now if you want to consume that service in another service, you should not hard code its URL. Because that will always point to only one service and will defeat the purpose of load balancing.
Ribbon helps us to solve this issue. Ribbon on backend talks with Eureka server and will get all instances of services and try to distribute the load across instances.
TL;DR You can download whole project by clicking following link.
To give you a brief idea about the project… We will have a producer which we will be launching multiple times. We will be creating a consumer with Ribbon which will consume the service exposed by the producer. At the same time, it will take care of load balancing as well.
Continue reading Spring Cloud: Creating REST Client Using Ribbon