The fastest and simplest way to protect your Python app from traffic spikes
Project description
FlowShield
The fastest and simplest way to protect your Python app from traffic spikes
Stop crashes | Control traffic | Stay fast
Why FlowShield?
Most rate limiters are either heavy, complex, or too slow for latency-sensitive APIs.
FlowShield is built for one job: protect your app fast.
- Ultra-fast in-memory checks (O(1))
- Lightweight architecture
- One-line Flask integration
- Fair per-IP control (optional)
- Memory-safe cleanup (TTL)
- Thread-safe core
10-Second Setup
pip install flowshield
If you are running from source before PyPI publication:
pip install -r requirements.txt
pip install -e .
from flask import Flask
from flowshield import protect_app
app = Flask(__name__)
protect_app(app) # That's it
@app.route("/")
def home():
return "Hello World"
How It Works
Request -> FlowShield -> Allow or Reject -> App
| Traffic Level | Behavior |
|---|---|
| Normal | Allow instantly |
| High | Return 429 with retry hint |
| Extreme | Protect app from overload |
Performance
| Tool | Typical Latency |
|---|---|
| Flask-Limiter | ~8-10ms |
| SlowAPI | ~5-8ms |
| FlowShield | ~1ms |
FlowShield targets a 5-10x faster path for common Flask rate-limiting use cases.
Features
- Ultra-fast in-memory engine
- Crash-prevention focus
- Global mode and per-IP mode
- Memory growth control via ip_ttl
- Thread-safe with locking
- Built-in stats (get_stats())
- Flask support today
Advanced Usage
protect_app(
app,
limit=100,
per_ip=True,
ip_ttl=600,
)
Example 429 Response
{
"status": "busy",
"message": "Rate limit exceeded",
"retry_after": 1,
"limit": 100,
"mode": "per-ip"
}
Use Cases
- Public APIs
- Flash sales and traffic spikes
- Exam or results portals
- Multi-tenant SaaS backends
Philosophy
Do not only scale servers. Control traffic intelligently at the app layer.
What FlowShield Is Not
- Not a CDN
- Not a load balancer
- Not an edge DDoS network
FlowShield is a lightweight protection layer inside your Python app.
Roadmap
- Flask support
- Per-IP limiting
- Thread safety
- TTL cleanup for inactive IPs
- FastAPI/ASGI support
- Django integration
- Redis mode for distributed limits
Contributing
PRs are welcome. Keep contributions:
- Simple
- Fast
- Lightweight
See CONTRIBUTING.md.
Quick Validation
python -m pytest test_flowshield.py -v
python benchmark.py
License
MIT License. See LICENSE.
Assets Setup
Create this structure in the repository:
assets/
flowshield-banner.png
logo.png
Then replace the badge placeholders by changing mani1028 in README badge URLs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flowsh-1.0.0.tar.gz.
File metadata
- Download URL: flowsh-1.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86ee5eacaf1229c77a900d351cbb5e88ff2de547e15d14fe5425a556b98ba056
|
|
| MD5 |
c8f17f0b5347ede7330f0efdeb8f063c
|
|
| BLAKE2b-256 |
e833b51cdde3250fc2e4929e4ce751a04e04de6b72ef19a5489c503805ad642b
|
Provenance
The following attestation bundles were made for flowsh-1.0.0.tar.gz:
Publisher:
publish.yml on mani1028/Flowsheild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flowsh-1.0.0.tar.gz -
Subject digest:
86ee5eacaf1229c77a900d351cbb5e88ff2de547e15d14fe5425a556b98ba056 - Sigstore transparency entry: 1130412405
- Sigstore integration time:
-
Permalink:
mani1028/Flowsheild@ea61885d7cfad20e0473b4a732143be1ee7ffc3c -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/mani1028
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea61885d7cfad20e0473b4a732143be1ee7ffc3c -
Trigger Event:
release
-
Statement type:
File details
Details for the file flowsh-1.0.0-py3-none-any.whl.
File metadata
- Download URL: flowsh-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff4a97785ca7b238d179049241ff8636af4d562d88efce6807926d7f994ff47b
|
|
| MD5 |
64f785b5dd67fb9aad2dde0665b38626
|
|
| BLAKE2b-256 |
d9a5763afa73912e1869992bc095307db9c26830b53a763fa62249972f342a1d
|
Provenance
The following attestation bundles were made for flowsh-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on mani1028/Flowsheild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flowsh-1.0.0-py3-none-any.whl -
Subject digest:
ff4a97785ca7b238d179049241ff8636af4d562d88efce6807926d7f994ff47b - Sigstore transparency entry: 1130412548
- Sigstore integration time:
-
Permalink:
mani1028/Flowsheild@ea61885d7cfad20e0473b4a732143be1ee7ffc3c -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/mani1028
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea61885d7cfad20e0473b4a732143be1ee7ffc3c -
Trigger Event:
release
-
Statement type: