Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tahmid-saj/rate-limiter-service

Rate limiter service to limit requests using a sliding window (with logging) approach and pre-defined rules. Developed with Go / Gin, DynamoDB.
https://github.com/tahmid-saj/rate-limiter-service

dynamodb gin go rate-limiter sliding-window-log

Last synced: 14 days ago
JSON representation

Rate limiter service to limit requests using a sliding window (with logging) approach and pre-defined rules. Developed with Go / Gin, DynamoDB.

Awesome Lists containing this project

README

        

# rate-limiter-service

Rate limiter service to limit requests using a sliding window (with logging) approach and pre-defined rules. Developed with Go / Gin, DynamoDB.




## Directory structure

The directory structure is as follows:

```
rate-limiter-service/
├── dynamodb/ # Code related to setting up and interacting with DynamoDB for request logs and rules
├── models/ # Contains data models for requests and rate-limiting rules
├── routes/ # API route definitions using Gin framework
├── sliding-window/ # Logic for the sliding window algorithm used to limit requests
├── utils/ # Utility functions (e.g., helpers for logging, error handling)
├── .gitignore # Specifies files to ignore in version control
├── README.md # Project overview, setup, and usage instructions
├── go.mod # Go module dependencies
├── go.sum # Hashes for Go module dependencies
└── main.go # Entry point for the rate limiter service

```




## Overview

### Design

The high level workflow of the rate limiter can be found below. Similar services can be found here and below:

#### Rate limiter workflow

image

#### Similar services

image

### Examples

#### Sample rule
```
{
"RuleName": {
"S": "chat-sigma-api-chat-message"
},
"Limit": {
"N": "1"
},
"ParamName": {
"S": "send-message"
},
"WindowInterval": {
"N": "1"
},
"WindowTime": {
"S": "minute"
}
}
```

#### Sample logged requests in sliding window
```
{
"RequestID": {
"S": "1044eb44-c478-4caa-ad8a-0ec43a4a8495"
},
"LogRequests": {
"L": [
{
"M": {
"ParamName": {
"S": "send-message"
},
"RuleName": {
"S": "chat-sigma-api-chat-message"
},
"Timestamp": {
"S": "2024-10-13T22:06:19.1614674-04:00"
}
}
},
{
"M": {
"ParamName": {
"S": "send-message"
},
"RuleName": {
"S": "chat-sigma-api-chat-message"
},
"Timestamp": {
"S": "2024-10-13T22:49:03.1318595-04:00"
}
}
}
]
}
}
```