Spring Boot | Kong | Rate Limiting

Using Kong to configure Rate Limiting to a Simple Spring Boot REST API

Configuring Rate Limiting plugin in Kong to manage the frequency of requests sent to Simple API endpoints

Ivan Franchin
Javarevisited
Published in
6 min readAug 17, 2023

--

Photo by Denny Müller on Unsplash

In this article, we’ll build a Simple Spring Boot REST API named Simple API. This application features two endpoints: /with-no-limits and /with-limits. To prevent the second endpoint from being excessively accessed by users, we’ll set a rate control mechanism. However, instead of coding the rate limiting logic directly into the Simple API, we’ll make use of Kong.

Introduction

Kong is an open-source API gateway that simplifies API management, provides security, scalability, and analytics for APIs and microservices. It acts as a single entry point for clients to access backend services, offering features like authentication, load balancing, and custom plugins.

Both Kong and Simple API will be executed as Docker containers. However, the Simple API’s 8080 port won’t be exposed to the host machine, meaning users cannot access it directly. To circumvent this, we will utilize Kong as a gateway.

--

--

Ivan Franchin
Javarevisited

Lead Software Developer with BS and MS in Computer Science. Writing about Java, Spring, software development in general, and emerging technologies.