Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/tahmid-saj/rate-limiter-service
- Owner: tahmid-saj
- Created: 2024-10-07T03:04:25.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-18T00:41:14.000Z (2 months ago)
- Last Synced: 2024-10-22T01:01:18.279Z (2 months ago)
- Topics: dynamodb, gin, go, rate-limiter, sliding-window-log
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
#### Similar services
### 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"
}
}
}
]
}
}
```