Tag Archives: Spring Boot

Microservice Registration and Discovery with Spring Cloud

Microservices are at center while designing any application with multiple parts which are required to be scaled horizontally to serve growing demand. It helps breaking system into small independent components making it easier to manage/develop and scale. But before deploying the architecture we need to answer few questions
How these microservices will discover each other?
How we will ensure High Availability of these microservices?
How our end service dealing with user will consume these microservices?

How these microservices will discover each other?
We need a central location where these services running on different machines can register themselves and declare the ip address and port at which they are running for example we have an addition service running on ip address and port 8080 this service will register itself to some central location with name additionservice and ip, port

Name IP/Port

Any other service who wants to perform addition will discover details of addition service by looking up to this central repository using service name additionservice

Spring Cloud Netflix provides many different components to perform service discovery , load balancing and handling failures of these services
Eureka is the Netflix Service Discovery Server and Client and act as central location for service registry every service in our ecosystem will register it self with Eureka along with some meta data information such as ip and port
If we scale our micorservice by launching one more instance to run on some different ip say and port 8080. We will have entry in our Eureka Server as

Name IP/Port No.Ofinstances
additionservice, 2

We can deploy some smart load balancing at client side so when it discovers the service endpoints from our service discovery Eureka Server gets two ip addresses and smartly distributes the load across these endpoints

Having multiple instances of service makes our service Highly Available and at same point by introducing the concept of central service registry it decouples client from having know how of where the services are deployed and running even if we change the location of these services at run time it won’t impact client consuming our services via Eureka.

Eureka Server does not have its own back-end and the service instances have to send heartbeats to server to keep their registrations up to date. Clients also have an in-memory cache of eureka, thus avoiding trip to server for every request.

There is concept of zones in Eureka Server stay tuned for updates on them !! ☺
Follow below Github repo to get code for EurekaServer, EurekaClient and EurkaConsumer

Boot Says Hello To Azure

Microsoft Azure is the new and big kid in Cloud Computing. I thought to get hands-on in deploying spring boot web service to Microsoft Azure. This blog post is not aimed to brief about how to develop a spring boot app/service rather focus is on knowing how to deploy a spring boot app on Azure.

We need to create an Web-App once we have our account created on Azure. Follow below snapshot for creating same on Azure


Once created we have to configure our Web-App environment according to our App need, like selecting the Java version, server.
Azure provides many different ways to deploy the App. We can do it from Azure Plugin for Eclipse / Intellij or directly from GitHub but for this exercise let’s stick to the most basic of all, uploading our spring boot app jar using FTP.

To load the jar via FTP we need to configure FTP user, this can be done easily by going in deployment credentials in deployed Web-App Service.

As Spring boot uses embedded Tomcat sever, we have to tell Azure Web App Service about this, to do this an extra file (web.config) is required that details the jar location and port to be selected at random.The web.config file goes into the wwwroot folder.web.config

Once you are connected to remote FTP server you will see wwwroot folder as in below image


In our case we have uploaded the Jar and Web.Config in same wwwroot folder. Once done we are good to go and access our Spring Boot saying “Hello” to Azure.