Coders Packet

Rate Limiter using Java, Spring and Redis

By Alwis Guru K V

A Rate limiting Web app to limit the number of client requests allowed to be sent over a specified period.

TITLE: RATE LIMITER WEB APP

This Rate Limiter web app limits the number of requests allowed to be sent to 10 for a period of 1 minute. The web app was developed using Spring Boot and Redis for the database.

BUILD TOOLS:

# Java

# Spring

# Maven

# Redis

# Spring MVC

# Spring Boot

# Spring Redis Data

# Thymeleaf

SYSTEM REQUIREMENTS:

Redis Server (See the official Website to install Redis based on your OS distro and make sure it is active during execution)

Redis Status

DESCRIPTION:

This web app implements the MVC design pattern. All the services are implemented based on the interface pattern. It limits the requests sent by the client to 10 per minute.

# REPOSITORY

This web app has a repository to maintain the number of requests sent by the client and expire the key to prevent the storage of unwanted keys in the database.

# SERVICE

The service retains the business logic of the web app. The key for the request is created from the request's IP address and the request's time. The keys are expired after a specific period.

# CONTROLLER

The controller handles the request and responds to the quota. If the percentage is exceeded, it returns a quota-exceeded reaction.

STEPS TO RUN:

# Deploy the Redis server in your OS/system (Follow the instructions on the official Website).

# Open the project folder

# LINUX/Mac

./mvnw spring-boot:run

# Windows

mvnw.cmd spring-boot:run

# Open any browser and paste the link

http://localhost:8080/api-get

Try to get a response more than ten times in a minute.

# SCREENSHOTS

rate_limiterexceeded

keyExpire key

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Alwis Guru K V (kvalwis)

Download packets of source code on Coders Packet