How to Create Microservices Using Spring

In this article, we will understand how to create Spring-based Microservices using a Use Case.

Use Case

Let’s consider the use case of BookMyHotel Web Application, developed by a company known as MyInternetSolutions.

NGINX With Eureka Instead of Spring Cloud Gateway or Zuul

For one of my clients I have a Eureka-based microservices horizontally scaled architecture. As an entry point of the project, I was first using Zuul, and later on, I replaced it with Spring Cloud Gateway. The simplified architecture of the project looks like this:

Simplified project architecture
Simplified project architecture

Both Zuul and Spring Cloud Gateway have integrated flawlessly with Eureka service discovery. However, the whole project was hosted on AWS EC2. In AWS EC2, you are paying for resources/Virtual Machines that you are using. It is better if you use smaller Virtual Machine Instances because the price will be lower. 

How to Use Hazelcast Auto-Discovery With Eureka

Hazelcast IMDG supports auto-discovery for many different environments. Since we introduced the generic discovery SPI, a lot of plugins were developed so you can use Hazelcast seamlessly on KubernetesAWSAzureGCP, and more. Should you need a custom plugin, you are also able to create your own.

If your infrastructure is not based on any popular Cloud environment but you still want to take advantage of the dynamic discovery rather than static IP configuration, you can set up your service registry. One of the more popular choices, especially in the JVM-based microservice world, is Eureka (initially developed by Netflix and now part of Spring Cloud). Eureka follows the client-server model, and you usually set up a server (or a cluster of servers for high availability) and use clients to register and locate services.