Skip to content
charmnailspa

charmnailspa

Technological development

Primary Menu
  • Computer & Technology
  • internet marketing
  • Web Design
  • Technology
  • computer
  • Business
  • About Us
    • Advertise Here
    • Contact Us
    • Privacy Policy
    • Sitemap
  • Home
  • Big Picture of Spring Cloud Gateway  – Grape Up
  • Technology

Big Picture of Spring Cloud Gateway  – Grape Up

Lisa H. Shelton April 27, 2022 8 minutes read

[ad_1]

In my life, I had an opportunity to work in a team that maintains the Api Gateway System. The creation of this system began more than 15 years ago, so it is quite a long time ago considering the rate of technology changing. The system was updated to Java 8, developed on a light-way server which is Tomcat Apache, and contained various tests: integration, performance, end-to-end, and unit test. Although the gateway was maintained with diligence, it is obvious that its core contains a lot of requests processing implementation like routing, modifying headers, converting request payload, which nowadays can be delivered by a framework like Spring Cloud Gateway. In this article, I am going to show the benefits of the above-mentioned framework. 

The major benefits, which are delivered by Spring Cloud Gateway: 

  • support to reactive programming model: reactive http endpoint, reactive web socket 
  • configuring request processing (routes, filters, predicates) by java code or yet another markup language (YAML) 
  • dynamic reloading of configuration without restarting the server (integration with Spring Cloud Config Server) 
  • support for SSL 
  • actuator Api 
  • integration gateway to Service Discovery mechanism 
  • load-balancing mechanisms  
  • rate-limiting (throttling) mechanisms 
  • circuit breakers mechanism 
  • integration with Oauth2 due to providing security features 

Those above-mentioned features have an enormous impact on the speed and easiness of creating an Api gateway system. In this article, I am going to describe a couple of those features. 

Due to the software, the world is the world of practice and systems cannot work only in theory, I decided to create a lab environment to prove the practical value of the Cloud Spring Gateway Ecosystem. Below I put an architecture of the lab environment: 

Table of Contents

Toggle
  • Building elements of Spring Cloud Gateway 
  • Spring Cloud Config Server integrated with Gateway 
  • Reactive web flow in Api Gateway 
  • Rate limiting possibilities of Gateway 
  • Service Discovery  
  • Circuit Breaker mention 
  • Experiment on your own 
  • Summary 
  • About the Author
    • Lisa H. Shelton

Building elements of Spring Cloud Gateway 

The first feature of Spring Cloud Gateway I am going to describe is a configuration of request processing. It can be considered the heart of the gateway. It is one of the major parts and responsibilities. As I mentioned earlier this logic can be created by java code or by YAML files. Below I add an example configuration in YAML and Java code way. Basic building blocks used to create processing logic are:  

  • Predicates – match requests based on their feature (path, hostname, headers, cookies, query) 
  • Filters – process and modify requests in a variety of ways. Can be divided depending on their purpose: 
  • gateway filter – modify the incoming http request or outgoing http response  
  • global filter – special filters applying to all routes so long as some conditions are fulfilled 

Details about different implementations of getaway building components can be found in docs: https://cloud.spring.io/spring-cloud-gateway/reference/html/. 

Example of configuring route in Java DSL: 

Configuration same route with YAML: 

Spring Cloud Config Server integrated with Gateway 

Someone might not be a huge fan of YAML language but using it here may have a big advantage in this case. It is possible to store configuration files in Spring Cloud Config Server and once configuration changes it can be reloaded dynamically. To do this process we need to use the Actuator Api endpoint.
Dynamic reloading of gateway configuration shows the picture below. The first four steps show request processing consistent with the current configuration. The gateway passes requests from the client to the “employees/v1” endpoint of the PeopleOps microservice (step 2). Then gateway passes the response back from the PeopleOps microservice to the client app (step 4). The next step is updating the configuration. Once Config Server uses git repository to store configuration, updating means committing recent changes made in the application.yaml file (step 5 in the picture). After pushing new commits to the repo is necessary to send a GET request on the proper actuator endpoint (step 6). These two steps are enough so that client requests are passed to a new endpoint in PeopleOps Microservice (steps 7,8,9,10).

Reactive web flow in Api Gateway 

As the documentation said Spring Cloud Gateway is built on top of Spring Web Flux. Reactive programming gains popularity among Java developers so Spring Gateway offers to create fully reactive applications. In my lab, I created Controller in a Marketing microservice which generates article data repetitively every 4 seconds. The browser observes this stream of requests. The picture below shows that 6 chunks of data were received in 24 seconds.

I do not dive into reactive programming style deeply, there are a lot of articles about the benefits and differences between reactive and other programming styles. I just put the implementation of a simple reactive endpoint in the Marketing microservice below. It is accessible on GitHub too: https://github.com/chrrono/Spring-Cloud-Gateway-lab/blob/master/Marketing/src/main/java/com/grapeup/reactive/marketing/MarketingApplication.java  

Rate limiting possibilities of Gateway 

The next feature of Spring Cloud Gateway is the implementation of rate-limiting (throttling) mechanisms. This mechanism was designed to protect gateways from harmful traffic. One of the examples might be distributed denial-of-service (DDoS) attack. It consists of creating an enormous number of requests per second which the system cannot handle.
The filtering of requests may be based on the user principles, special fields in headers, or other rules. In production environments, mostly several gateways instance up and running but for Spring Cloud Gateway framework is not an obstacle, because it uses Redis to store information about the number of requests per key. All instances are connected to one Redis instance so throttling can work correctly in a multi-instances environment.
Due to prove the advantages of this functionality I configured rate-limiting in Gateway in the lab environment and created an end-to-end test, which can be described in the picture below.

The parameters configured for throttling are as follows: DefaultReplenishRate = 4, DefaultBurstCapacity = 8. It means getaways allow 4 Transactions (Request) per second (TPS) for the concrete key. The key in my example is the header value of “Host” field, which means that the first and second clients have a limit of 4TPS separately. If the limit is exceeded, the gateway replies by http response with 429 http code. Because of that, all requests from the first client are passed to the production service, but for the second client only half of the requests are passed to the production service by the gateway, and another half are replied to the client immediately with 429 Http Code. 

If someone is interested in how I test it using Rest Assured, JUnit, and Executor Service in Java test is accessible here:  https://github.com/chrrono/Spring-Cloud-Gateway-lab/blob/master/Gateway/src/test/java/com/grapeup/gateway/demo/GatewayApplicationTests.java

Service Discovery  

The next integration subject concerns the service discovery mechanism. Service discovery is a service registry. Microservice starting registers itself to Service Discovery and other applications may use its entry to find and communicate with this microservice. Integration Spring Cloud Gateway with Eureka service discovery is simple. Without the creation of any configuration regarding request processing, requests can be passed from the gateway to a specific microservice and its concrete endpoint.

The below Picture shows all registering applications from my lab architecture created due to a practical test of Spring Cloud Gateway. “Production” microservice has one entry for two instances. It is a special configuration, which enables load balancing by a gateway.

Circuit Breaker mention 

The circuit breaker is a pattern that is used in case of failure connected to a specific microservice. All we need is to define Spring Gateway fallback procedures. Once the connection breaks down, the request will be forwarded to a new route. The circuit breaker offers more possibilities, for example, special action in case of network delays and it can be configured in the gateway.

Experiment on your own 

I encourage you to conduct your own tests or develop a system that I build, in your own direction. Below, there are two links to GitHub repositories: 

  1. https://github.com/chrrono/config-for-Config-server (Repo for keep configuration for Spring Cloud Config Server) 
  2. https://github.com/chrrono/Spring-Cloud-Gateway-lab (All microservices code and docker-compose configuration)  

To establish a local environment in a straightforward way, I created a docker-compose configuration. This is a link for the docker-compose.yml file: https://github.com/chrrono/Spring-Cloud-Gateway-lab/blob/master/docker-compose.yml 

All you need to do is install a docker on your machine. I used Docker Desktop on my Windows machine. After executing the “docker-compose up” command in the proper location you should see all servers up and running: 

To conduct some tests I use the Postman application, Google Chrome, and my end-to-end tests (Rest Assured, JUnit, and Executor Service in Java). Do with this code all you want and allow yourself to have only one limitation: your imagination 😊

Summary 

Spring Cloud Gateway is a huge topic, undoubtedly. In this article, I focused on showing some basic building components and the overall intention of gateway and interaction with others spring cloud services. I hope readers appreciate the possibilities and care by describing the framework. If someone has an interest in exploring Spring Cloud Gateway on your own, I added links to a repo, which can be used as a template project for your explorations.

[ad_2]

Source link

About the Author

Lisa H. Shelton

Administrator

Visit Website View All Posts

Post navigation

Previous: 8 steps to being (almost) completely anonymous online
Next: MHIENG to License Carbon Capture Technology for Natural Gas Plant in Italy

Related News

From Discussion to Action: Enhancing Meeting Outcomes with Employee Monitoring Software
  • Technology

From Discussion to Action: Enhancing Meeting Outcomes with Employee Monitoring Software

Lisa H. Shelton December 1, 2025 0
How AI and Machine Learning Eliminate Data Issues
  • Technology

How AI and Machine Learning Eliminate Data Issues

Lisa H. Shelton November 26, 2025 0
Wigs for Patients Designed for Natural Beauty
  • Technology

Wigs for Patients Designed for Natural Beauty

Lisa H. Shelton September 9, 2025 0
January 2026
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Dec    

Archives

  • December 2025
  • November 2025
  • September 2025
  • May 2025
  • April 2025
  • March 2025
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • March 2020
  • February 2020
  • November 2018
  • October 2018
  • January 2017

Categories

  • Business
  • computer
  • Computer & Technology
  • internet
  • internet marketing
  • Technology
  • Web Design

Recent Posts

  • From Discussion to Action: Enhancing Meeting Outcomes with Employee Monitoring Software
  • How AI and Machine Learning Eliminate Data Issues
  • Wigs for Patients Designed for Natural Beauty
  • Aluminum Fence Installation Port St. Lucie: Elegance, Security, and Lasting Durability
  • The Changing Job Roles in Silicon Valley with AI

Fiverr

Fiverr Logo   

BL

Seedbl

Seedbacklink

Tags

2021 Acura Rdx Technology Package 2021 Acura Tlx Technology Package 2022 Acura Mdx Technology Package Align Technology Stock Applied Racing Technology Artificial Intelligence Technology Solutions Inc Assisted Reproductive Technology Battery Technology Stocks Benjamin Franklin Institute Of Technology Chief Technology Officer Color Star Technology Craft Design Technology Definition Of Technology Definitive Technology Speakers Element Materials Technology Health Information Technology Salary Ice Mortgage Technology Information Technology Definition Information Technology Degree Information Technology Salary Interactive Response Technology International Game Technology Lacrosse Technology Atomic Clock La Crosse Technology Weather Station Luokung Technology Stock Marvell Technology Stock Price Maytag Commercial Technology Washer Microchip Technology Stock Micron Technology Stock Price Mrna Technology History Mrna Vaccine Technology Nyc College Of Technology Penn College Of Technology Recombinant Dna Technology Rlx Technology Stock Robert Half Technology Science And Technology Sharif University Of Technology Smart Home Technology Stevens Institute Of Technology Ranking Symphony Technology Group Technology In The Classroom Technology Readiness Level Technology Stores Near Me Thaddeus Stevens College Of Technology

PHP 2026

ilchiodofisso
roxannecullar

You may have missed

From Discussion to Action: Enhancing Meeting Outcomes with Employee Monitoring Software
  • Technology

From Discussion to Action: Enhancing Meeting Outcomes with Employee Monitoring Software

Lisa H. Shelton December 1, 2025 0
How AI and Machine Learning Eliminate Data Issues
  • Technology

How AI and Machine Learning Eliminate Data Issues

Lisa H. Shelton November 26, 2025 0
Wigs for Patients Designed for Natural Beauty
  • Technology

Wigs for Patients Designed for Natural Beauty

Lisa H. Shelton September 9, 2025 0
Aluminum Fence Installation Port St. Lucie: Elegance, Security, and Lasting Durability
  • Technology

Aluminum Fence Installation Port St. Lucie: Elegance, Security, and Lasting Durability

Lisa H. Shelton September 3, 2025 0
charmnailspa.com | MoreNews by AF themes.

WhatsApp us