๐ Table of Contents
- โจ Features
- ๐ฏ Use Cases
- ๐ Quick Start
- ๐ Documentation
- ๐จ Examples
- ๐๏ธ Architecture
- โ๏ธ Configuration
- ๐งช Testing
- ๐ Performance
- ๐ Security
- ๐บ๏ธ Roadmap
- ๐ค Contributing
- ๐ License
- ๐ Acknowledgments
โจ Features
๐ฏ Core Features
- โ Multiple Rate Limiting Algorithms - Token bucket, fixed window, sliding window, concurrency control
- โ Ban Management - IP ban, automatic ban, ban priority
- โ Quota Control - Quota allocation, quota alerts, quota overdraw
- โ Circuit Breaker - Automatic failover, state recovery, fallback strategy
โก Advanced Features
- ๐ High Performance - Latency < 200ฮผs P99
- ๐ Secure and Reliable - Memory safety, SQL injection protection
- ๐ Multi-Storage Support - PostgreSQL, Redis, in-memory storage
- ๐ฆ Easy to Use - Macro support, clean API
๐จ ็นๆงไบฎ็น
graph LR
A[่ฏทๆฑ] --> B[ๆ ่ฏ็ฌฆๆๅ]
B --> C[้ๆตๆฃๆฅ]
B --> D[ๅฐ็ฆๆฃๆฅ]
B --> E[้
้ขๆฃๆฅ]
C --> F[ๅณ็ญ้พ]
D --> F
E --> F
F --> G[ๅ
่ฎธ/ๆ็ป]
style A fill:#e1f5ff
style B fill:#b3e5fc
style C fill:#81d4fa
style D fill:#81d4fa
style E fill:#81d4fa
style F fill:#4fc3f7
style G fill:#29b6f6
๐ฏ Use Cases
use ;
async
async
Suitable for enterprise applications requiring high concurrency and reliability.
use flow_control;
async
Suitable for protecting API services from abuse and DDoS attacks.
use ;
use MockBanStorage;
use Arc;
async
Suitable for web applications that need to prevent malicious users and crawlers.
๐ Quick Start
Installation
๐ฆ Cargo
[]
= { = "0.1", = ["macros"] }
๐ง Features
[]
= { = "0.1", = ["postgres", "redis", "macros"] }
Feature Flags
๐๏ธ ๅฏ้็นๆง้ ็ฝฎ
Limiteron ไฝฟ็จ feature flags ๆฅๆงๅถๅ่ฝๅฏ็จ๏ผ้ป่ฎคๅชๅฏ็จๅ ๅญๅญๅจ๏ผ
้ขๅฎไน็ปๅ
# ๆๅฐๅ๏ผไป
ๆ ธๅฟ้ๆต
= { = "0.1", = ["minimal"] }
# ๆ ๅ๏ผๆ ธๅฟ + ๅบ็ก้ซ็บงๅ่ฝ
= { = "0.1", = ["standard"] }
# ๅฎๆด๏ผๆๆๅ่ฝ
= { = "0.1", = ["full"] }
ๅ็ฌ็นๆง
# ๅญๅจๅ็ซฏ
= { = "0.1", = ["postgres", "redis"] }
# ้ซ็บงๅ่ฝ
= { = "0.1", = ["ban-manager", "quota-control", "circuit-breaker"] }
# ๅฎๆฏๆ
= { = "0.1", = ["macros"] }
| ็นๆง | ๆ่ฟฐ | ้ป่ฎค |
|---|---|---|
memory |
ๅ ๅญๅญๅจ | โ |
postgres |
PostgreSQL ๅญๅจ | โ |
redis |
Redis ๅญๅจ | โ |
ban-manager |
ๅฐ็ฆ็ฎก็ | โ |
quota-control |
้ ้ขๆงๅถ | โ |
circuit-breaker |
็ๆญๅจ | โ |
macros |
ๅฎๆฏๆ | โ |
telemetry |
้ฅๆตๅ่ฟฝ่ธช | โ |
monitoring |
Prometheus ๆๆ | โ |
Basic Usage
๐ฌ 5-Minute Quick Start
Step 1: Add Dependency
[]
= { = "0.1", = ["macros"] }
Step 2: Use Macro
use flow_control;
async
use ;
async
๐ Documentation
๐ Additional Resources
- ๐ User Guide - Detailed tutorial
- ๐ง API Reference - API documentation
- โ FAQ - Frequently asked questions
- ๐ Troubleshooting - Common issues and solutions
๐จ Examples
๐ก Practical Examples
๐ Example 1: Basic Rate Limiting
use ;
async
Request 0 โ
Request 1 โ
...
Request 9 โ
Request 10 โ
...
Request 14 โ
โ
First 10 requests allowed, remaining rate limited
๐ฅ Example 2: Using Macro
use flow_control;
async
async
Processing request for user123
โ
Macro automatically handles rate limiting
๐๏ธ Architecture
System Overview
graph TB
A[User App] --> B[API Layer]
B --> C[Governor]
C --> D[Identifier Extraction]
C --> E[Decision Chain]
D --> F[Matchers]
E --> G[Limiters]
E --> H[Ban Management]
E --> I[Quota Control]
E --> J[Circuit Breaker]
G --> K[L2/L3 Cache]
H --> K
I --> K
K --> L[Storage Layer]
L --> M[PostgreSQL]
L --> N[Redis]
L --> O[Memory]
style A fill:#e1f5ff
style B fill:#b3e5fc
style C fill:#81d4fa
style D fill:#4fc3f7
style E fill:#4fc3f7
style F fill:#29b6f6
style G fill:#29b6f6
style H fill:#29b6f6
style I fill:#29b6f6
style J fill:#29b6f6
style K fill:#0288d1
style L fill:#0277bd
style M fill:#01579b
style N fill:#01579b
style O fill:#01579b
| Component | Description | Status |
|---|---|---|
| Governor | Main controller, end-to-end flow control | โ Stable |
| Matchers | Identifier extraction (IP, User ID, Device ID, etc.) | โ Stable |
| Limiters | Multiple rate limiting algorithms | โ Stable |
| Ban Management | IP ban, automatic ban | โ Stable |
| Quota Control | Quota allocation, quota alerts | โ Stable |
| Circuit Breaker | Automatic failover, state recovery | โ Stable |
| Cache | L2/L3 cache support | โ Stable |
| Storage Layer | PostgreSQL, Redis, in-memory | โ Stable |
โ๏ธ Configuration
๐๏ธ Configuration Options
Basic Configuration
[]
= "100/s"
= "10000/m"
= 50
[]
= 10000
= 100000
Advanced Configuration
[]
= "100/s"
= "10000/m"
= 50
[]
= "redis"
= "redis://localhost:6379"
[]
= true
= true
| Option | Type | Default | Description |
|---|---|---|---|
rate_limit |
String | "100/s" | Rate limit |
quota_limit |
String | "10000/m" | Quota limit |
concurrency_limit |
Integer | 50 | Concurrency limit |
l2_capacity |
Integer | 10000 | L2 cache capacity |
l3_capacity |
Integer | 100000 | L3 cache capacity |
storage_type |
String | "memory" | Storage type |
enable_metrics |
Boolean | false | Enable metrics |
enable_tracing |
Boolean | false | Enable tracing |
๐งช Testing
# Run all tests
# Run specific test
# Run integration tests
# Run benchmarks
๐ Performance
โก Benchmark Results
Note: The following data represents actual benchmark results from comprehensive testing (2026-01-19).
Throughput
| Limiter Type | Actual | Target | Achievement |
|---|---|---|---|
| TokenBucket | 12M+ ops/s | 500K ops/s | โ 24x |
| FixedWindow | 20M+ ops/s | 300K ops/s | โ 66x |
| ConcurrencyLimiter | 12M+ ops/s | 200K ops/s | โ 60x |
Latency
| Percentile | TokenBucket | FixedWindow |
|---|---|---|
| P50 | < 100ns | < 100ns |
| P95 | < 200ns | < 150ns |
| P99 | < 1ยตs | < 500ns |
Concurrency Test Results
| Test Item | Result | Status |
|---|---|---|
| Data Consistency | 100% | โ Pass |
| High Concurrency Stability | 50/100 concurrent | โ Pass |
| Rate Limit Correctness | 1000/1000 | โ Pass |
# Run performance tests
Sample output:
ๅ่ฝๆต่ฏ: 7/7 Pass (100%)
TokenBucket: 12,088,759 ops/s
FixedWindow: 19,920,188 ops/s
ConcurrencyLimiter: 11,891,237 ops/s
ๅนถๅๆต่ฏ: 100% ๆฐๆฎไธ่ดๆง
๐ Security
๐ก๏ธ Security Features
Security Measures
- โ Memory Protection - Rust memory safety guarantees
- โ Input Validation - IP address, User ID, MAC address validation
- โ SQL Injection Protection - Using parameterized queries
- โ Password Protection - Using secrecy library for sensitive data
- โ Audit Logging - Complete operation tracking
Reporting Security Issues
Please report security vulnerabilities through GitHub Issues.
๐บ๏ธ Roadmap
๐ฏ Development Plan
gantt
title Limiteron Roadmap
dateFormat YYYY-MM
section Phase 1
Core Features :done, 2026-01, 2026-03
section Phase 2
Feature Extensions :active, 2026-03, 2026-06
section Phase 3
Performance Optimization :2026-06, 2026-09
section Phase 4
Production Ready :2026-09, 2026-12
โ Completed
- Core rate limiting
- Ban management
- Quota control
- Circuit breaker
- Unit and integration tests
- Macro support
- PostgreSQL and Redis storage
๐ง In Progress
- Performance optimization
- Monitoring and tracing improvements
- Documentation completion
- Example code additions
๐ Planned
- Lua script enhancements
- Custom matcher extensions
- Additional storage backends
- Web UI management interface
๐ก Future Ideas
- Distributed rate limiting
- Machine learning-driven rate limiting
- Additional rate limiting algorithms
- Community plugin system
๐ค Contributing
๐ Welcome Contributions!
๐ Report Issues
Found a bug? Create Issue
๐ก Feature Requests
Have a suggestion? Start Discussion
๐ง Submit Code
Want to contribute? Fork & PR
How to Contribute
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/limiteron.git - Create a branch:
git checkout -b feature/amazing-feature - Make your changes
- Test your changes:
cargo test --all-features - Commit your changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Create a Pull Request
Code Style
- Follow Rust standard coding conventions
- Write comprehensive tests
- Update documentation
- Add examples for new features
๐ License
This project is licensed under Apache 2.0:
๐ Acknowledgments
Built with Excellent Tools
Special Thanks
-
๐ Dependencies - Built on these excellent projects:
-
๐ฅ Contributors - Thanks to all contributors!
-
๐ฌ Community - Special thanks to community members
๐ Contact & Support
Stay Connected
โญ Star History
๐ Support This Project
If you find this project useful, please consider giving it a โญ๏ธ!
Built with โค๏ธ by Kirky.X
ยฉ 2026 Kirky.X. All rights reserved.