Skip to content

Commit dbdbf64

Browse files
First commit
Signed-off-by: Elena Kolevska <elena@kolevska.com>
0 parents  commit dbdbf64

27 files changed

+4065
-0
lines changed

.env.example

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Redis Connection Configuration
2+
REDIS_HOST=localhost
3+
REDIS_PORT=6379
4+
REDIS_PASSWORD=
5+
REDIS_DATABASE=0
6+
REDIS_CLUSTER=false
7+
REDIS_CLUSTER_NODES=
8+
REDIS_SSL=false
9+
REDIS_SSL_CERT_REQS=required
10+
REDIS_SSL_CA_CERTS=
11+
REDIS_SSL_CERTFILE=
12+
REDIS_SSL_KEYFILE=
13+
REDIS_SOCKET_TIMEOUT=5.0
14+
REDIS_SOCKET_CONNECT_TIMEOUT=5.0
15+
REDIS_MAX_CONNECTIONS=50
16+
REDIS_RETRY_ATTEMPTS=3
17+
REDIS_RETRY_DELAY=0.1
18+
REDIS_EXPONENTIAL_BACKOFF=true
19+
20+
# Test Configuration
21+
TEST_CLIENT_INSTANCES=1
22+
TEST_CONNECTIONS_PER_CLIENT=10
23+
TEST_THREADS_PER_CLIENT=4
24+
TEST_DURATION=
25+
TEST_TARGET_OPS_PER_SECOND=
26+
TEST_WORKLOAD_PROFILE=basic_rw
27+
TEST_OPERATIONS=SET,GET
28+
TEST_OPERATION_WEIGHTS=
29+
TEST_KEY_PREFIX=test_key
30+
TEST_KEY_RANGE=10000
31+
TEST_VALUE_SIZE_MIN=100
32+
TEST_VALUE_SIZE_MAX=1000
33+
TEST_READ_WRITE_RATIO=0.7
34+
TEST_USE_PIPELINE=false
35+
TEST_PIPELINE_SIZE=10
36+
TEST_ASYNC_MODE=false
37+
TEST_PUBSUB_CHANNELS=
38+
TEST_TRANSACTION_SIZE=5
39+
40+
# Logging Configuration
41+
LOG_LEVEL=INFO
42+
LOG_FILE=
43+
44+
# Metrics Configuration
45+
METRICS_ENABLED=true
46+
METRICS_PORT=8000
47+
METRICS_INTERVAL=5
48+
PROMETHEUS_SCRAPE_INTERVAL=5s
49+
OTEL_EXPORT_INTERVAL=5000
50+
GRAFANA_REFRESH_INTERVAL=5s
51+
52+
# OpenTelemetry Configuration
53+
OTEL_ENABLED=true
54+
OTEL_SERVICE_NAME=redis-py-test-app
55+
OTEL_SERVICE_VERSION=1.0.0
56+
OTEL_EXPORTER_OTLP_ENDPOINT=
57+
OTEL_EXPORTER_OTLP_HEADERS=
58+
OTEL_EXPORTER_OTLP_TIMEOUT=10
59+
OTEL_EXPORTER_JAEGER_ENDPOINT=
60+
OTEL_RESOURCE_ATTRIBUTES=service.name=redis-py-test-app,service.version=1.0.0
61+
62+
# Output Configuration
63+
OUTPUT_FILE=
64+
QUIET=false
65+
CONFIG_FILE=

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/__pycache__
2+
/.env
3+
/.env.docker
4+
.idea
5+
/lettuce-test-app

DOCKER_SETUP.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Redis Test App - Docker Setup
2+
3+
Simple Docker-based setup for running the Redis testing application with full monitoring capabilities.
4+
5+
## 🚀 Quick Start
6+
7+
### Prerequisites
8+
- Docker and Docker Compose installed
9+
- At least 4GB RAM available
10+
11+
### Run Everything
12+
```bash
13+
./setup.sh
14+
```
15+
16+
That's it! The script will:
17+
- Build the Redis test application
18+
- Start Redis database
19+
- Start monitoring services (Prometheus, Grafana, Jaeger)
20+
- Run the test workload
21+
22+
## 📊 Access Points
23+
24+
After running `./setup.sh`, you can access:
25+
26+
- **Application Metrics**: http://localhost:8000/metrics
27+
- **Grafana Dashboards**: http://localhost:3000 (admin/admin)
28+
- **Prometheus**: http://localhost:9090
29+
- **Jaeger Tracing**: http://localhost:16686
30+
- **Redis Database**: localhost:6379
31+
32+
## 🔧 Customization
33+
34+
### Change Test Workload
35+
Edit `docker-compose.yml` and modify the command section:
36+
37+
```yaml
38+
command: >
39+
python main.py
40+
--workload-profile basic_rw # Change workload type
41+
--duration 1800 # Change duration (seconds)
42+
--target-ops-per-second 500 # Change target throughput
43+
```
44+
45+
Available workload profiles:
46+
- `basic_rw` - Basic read/write operations
47+
- `high_throughput` - High-performance testing
48+
- `list_operations` - List-based operations
49+
- `pubsub_test` - Pub/Sub testing
50+
- `transaction_test` - Transaction testing
51+
52+
### Restart with New Configuration
53+
```bash
54+
docker-compose restart redis-test-app
55+
```
56+
57+
## 📝 Management Commands
58+
59+
### View Logs
60+
```bash
61+
# All services
62+
docker-compose logs -f
63+
64+
# Just the test app
65+
docker-compose logs -f redis-test-app
66+
67+
# Just Redis
68+
docker-compose logs -f redis
69+
```
70+
71+
### Check Status
72+
```bash
73+
docker-compose ps
74+
```
75+
76+
### Stop Services
77+
```bash
78+
docker-compose down
79+
```
80+
81+
### Complete Cleanup
82+
```bash
83+
# Stop services only
84+
./cleanup.sh
85+
86+
# Stop and remove data
87+
./cleanup.sh --remove-data
88+
89+
# Stop, remove data and images
90+
./cleanup.sh --remove-data --remove-images
91+
```
92+
93+
## 🎯 Use Cases
94+
95+
### Local Development
96+
- Test Redis performance
97+
- Debug connection issues
98+
- Monitor application metrics
99+
- Analyze traces
100+
101+
### Performance Testing
102+
- Run long-duration tests
103+
- Monitor memory usage
104+
- Track performance over time
105+
- Detect memory leaks
106+
107+
### Cloud Deployment
108+
The same Docker setup can be deployed to:
109+
- AWS ECS/EKS
110+
- Google Cloud Run/GKE
111+
- Azure Container Instances/AKS
112+
- Any Docker-compatible platform
113+
114+
## 🔍 Monitoring
115+
116+
### Key Metrics Available
117+
- **Operations per second** by operation type
118+
- **Latency percentiles** (50th, 95th, 99th)
119+
- **Error rates** and error types
120+
- **Connection health** and reconnections
121+
- **Memory and CPU usage**
122+
123+
### Grafana Dashboards
124+
Pre-configured dashboards show:
125+
- Redis operation performance
126+
- Application health
127+
- Error tracking
128+
- Resource utilization
129+
130+
### Distributed Tracing
131+
Jaeger provides detailed traces for:
132+
- Individual Redis operations
133+
- Connection management
134+
- Error propagation
135+
- Performance bottlenecks
136+
137+
## 🛠️ Troubleshooting
138+
139+
### Services Won't Start
140+
```bash
141+
# Check Docker is running
142+
docker info
143+
144+
# Check logs for errors
145+
docker-compose logs
146+
147+
# Restart everything
148+
./cleanup.sh && ./setup.sh
149+
```
150+
151+
### High Resource Usage
152+
- Reduce test duration or throughput
153+
- Adjust metrics retention in Prometheus
154+
- Scale down monitoring services if needed
155+
156+
### Port Conflicts
157+
If ports are already in use, modify `docker-compose.yml`:
158+
- Change `8000:8000` to `8001:8000` for metrics
159+
- Change `3000:3000` to `3001:3000` for Grafana
160+
- etc.
161+
162+
## 📚 Next Steps
163+
164+
1. **Run the setup**: `./setup.sh`
165+
2. **Open Grafana**: http://localhost:3000
166+
3. **Monitor your tests**: Watch the dashboards
167+
4. **Customize workloads**: Edit docker-compose.yml
168+
5. **Deploy to cloud**: Use the same configuration
169+
170+
The application is designed for both short-term testing and long-term monitoring to detect performance degradations and memory leaks across different Redis versions.

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Multi-stage build for Redis Python test app
2+
FROM python:3.11-slim as builder
3+
4+
# Install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
gcc \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Set working directory
10+
WORKDIR /app
11+
12+
# Copy requirements and install dependencies
13+
COPY requirements.txt .
14+
RUN pip install --no-cache-dir --user -r requirements.txt
15+
16+
# Production stage
17+
FROM python:3.11-slim
18+
19+
# Install runtime dependencies
20+
RUN apt-get update && apt-get install -y \
21+
curl \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
# Create non-root user
25+
RUN useradd --create-home --shell /bin/bash app
26+
27+
# Set working directory
28+
WORKDIR /app
29+
30+
# Copy installed packages from builder
31+
COPY --from=builder /root/.local /home/app/.local
32+
33+
# Copy application code
34+
COPY --chown=app:app . .
35+
36+
# Make sure scripts are executable
37+
RUN chmod +x /app/*.py
38+
39+
# Switch to non-root user
40+
USER app
41+
42+
# Add local packages to PATH
43+
ENV PATH=/home/app/.local/bin:$PATH
44+
45+
# Expose metrics port
46+
EXPOSE 8000
47+
48+
# Health check
49+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
50+
CMD curl -f http://localhost:8000/metrics || exit 1
51+
52+
# Default command
53+
CMD ["python", "main.py", "--help"]

0 commit comments

Comments
 (0)