Environment
- Spring Boot 3
- PostgreSQL (10M rows)
- Redis
- k6 load testing
- 100 concurrent virtual users
- 60-second sustained load
- Local machine benchmark
All numbers below are real metrics.
Load Configuration
export const options = {
vus: 100,
duration: '60s'
};Scenario A — No Cache (Baseline)
| Metric | Value |
|---|---|
| RPS | 630 req/s |
| Avg Latency | 158 ms |
| P95 | 169 ms |
| Max | 519 ms |
| Errors | 0% |
Observations:
- DB-bound performance
- Stable latency distribution
- Predictable tail behavior
Scenario B — Proper Redis Cache
| Metric | Value |
|---|---|
| RPS | 9,333 req/s |
| Avg Latency | 10.5 ms |
| P95 | 14.9 ms |
| Max | 537 ms |
| Errors | 0% |
Improvements:
- ~15x throughput increase
- ~15x latency reduction
- DB load drastically reduced
Cache hit ratio is effectively high.
Scenario C — Misconfigured Cache
| Metric | Value |
|---|---|
| RPS | 1,130 req/s |
| Avg Latency | 88 ms |
| Median | 152 ms |
| P95 | 157 ms |
| Max | 674 ms |
| Errors | 0% |
Key insight:
- Average improved
- Median and P95 are nearly identical to baseline
- Mixed fast and slow requests
- Inconsistent performance behavior
This suggests partial cache effectiveness or a high miss rate.
Technical Interpretation
1. Throughput Behavior
Baseline → 630 req/s
Proper Cache → 9,333 req/s
Bad Cache → 1,130 req/s
Improper caching gives only ~1.8x improvement over baseline.
2. Latency Distribution
Scenario C shows:
- Avg = 88 ms
- Median = 152 ms
This indicates skewed distribution:
- Some requests are extremely fast
- Many still slow
This is a red flag in production systems.
3. Risks of Improper Caching
- Serialization overhead
- Memory bloat
- Increased GC pressure
- Low hit ratio
- Unstable tail latency
Recommendations
- Never evaluate cache using average latency alone.
- Always monitor P95 and P99.
- Track cache hit ratio.
- Stress test with realistic concurrency.
- Benchmark with large datasets (10M+ rows).
Conclusion
Caching is not a silver bullet.
In this benchmark:
- Proper configuration → massive improvement
- Misconfiguration → unstable system
- No cache → slower but predictable
Performance decisions must be data-driven.
These results were measured on a local machine under controlled load and reflect real execution metrics.
Source Code & Full Benchmark Project
The complete Spring Boot project, Docker setup, load test scripts, and raw benchmark results are available on GitHub:
GitHub Repository
GitHub – nithidol/project-cache-pe
Contribute to nithidol/project-cache-pe development by creating an account on GitHub.
This repository includes:
- Full Spring Boot source code
- Docker Compose configuration
- Redis + PostgreSQL setup
- k6 load test script
- Prometheus & Grafana monitoring configuration
- Real benchmark results (100 VUs, 60s load)



