💫 High-performance database proxy built with Rust to prevent expensive database upgrades.
Query Shield is a sidecar proxy that sits between your application and database, implementing intelligent query optimization to reduce database load and prevent costly upgrades.
- Query Deduplication: If 100 requests arrive within 10ms with the same query, the proxy sends only 1 query to the DB, sharing the result with others (prevents Thundering Herd).
- Rate Limiting per Query: Blocks "garbage" queries that spike database CPU to 100%.
- Slow Query Monitoring: Identifies and logs performance bottlenecks with detailed statistics and query pattern tracking.
- Connection Pooling: Efficient connection management using Rust's async runtime.
The easiest way to run Query Shield is using Docker. We provide pre-built images on Docker Hub.
# 1. Pull the latest image
docker pull sofyan-solutions/query-shield:latest
# 2. Setup your configuration
# Copy the example config and customize it
cp config/config.example.toml config/config.toml
# 3. Run with Docker Compose
docker-compose -f docker-compose.prod.yml up -dTo validate Query Shield with a realistic workload, you can use our Sample App. This setup starts the proxy, a MySQL database, and a Go-based application that implements dual-connection strategy (reads via proxy, writes direct).
# Start the full stack (Proxy + Sample App + MySQL)
docker-compose -f docker-compose.sample-app.yml up -d
# Check sample app health
curl http://localhost:18080/healthQuery Shield can be configured via config/config.toml. Key features like deduplication, rate limiting, and monitoring can be toggled and tuned there.
To enable performance monitoring, update your config.toml:
[query_monitoring]
enabled = true
slow_query_threshold_ms = 100 # Log queries slower than 100ms
statistics_window_seconds = 3600 # Keep stats for the last hour
enable_query_pattern_tracking = trueThe proxy will periodically log structured JSON summaries of query performance to the tracing logs.
MIT