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. 

Extending Spring Boot’s Zuul Proxy to Record Requests and Responses

An easy way to capture the incoming requests to your server and replay them can be very useful. For example, if you lack an automation team, or simply want to be quick about it, you can record the REST requests of a scenario and play them again after every push to GIT. You can also use the recorded requests to simulate many users. Or, you can analyze the requests to learn useful statistics, etc. You get the idea.

OK, so how can we do it the easy way? First, we’ll exploit spring boot Zuul gateway filters feature – this gateway can activate custom filters for every request and every response. A handler must simply extend ZuulFilter and provide information of:

Microservices Architecture With Spring Boot and Spring Cloud

Did you know that some of the largest tech companies, like Amazon and Google, are using Java to develop a microservices architecture? Many companies are building a microservices architecture to scale their people, but not their systems. If you’re also looking to do so, a good way to get started is to hire more Java developers (because there are so many of them). 

Within the Java ecosystem, you’ll find some well-rooted patterns for building microservice architectures. And if you’ve developed with Spring before, then Spring Boot and Spring Cloud should feel like a nice homecoming.

Redirecting HTTP Requests With Zuul in Spring Boot

Zuul is part of the Spring Cloud Netflix package and allows redirect REST requests to perform various types of filters.

In almost any project where we use microservices, it is desirable that all communications between those microservices go through a communal place so that the inputs and outputs are recorded and can implement security or redirect requests, depending on various parameters.