Spring Boot Redis Benchmark — 15× Faster or Not?

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)

MetricValue
RPS630 req/s
Avg Latency158 ms
P95169 ms
Max519 ms
Errors0%

Observations:

  • DB-bound performance
  • Stable latency distribution
  • Predictable tail behavior

Scenario B — Proper Redis Cache

MetricValue
RPS9,333 req/s
Avg Latency10.5 ms
P9514.9 ms
Max537 ms
Errors0%

Improvements:

  • ~15x throughput increase
  • ~15x latency reduction
  • DB load drastically reduced

Cache hit ratio is effectively high.


Scenario C — Misconfigured Cache

MetricValue
RPS1,130 req/s
Avg Latency88 ms
Median152 ms
P95157 ms
Max674 ms
Errors0%

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

  1. Never evaluate cache using average latency alone.
  2. Always monitor P95 and P99.
  3. Track cache hit ratio.
  4. Stress test with realistic concurrency.
  5. 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

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)