Redis Cache-aside: Student GET 85ms DB → 2ms Redis | Java 17 + Spring Boot 2.6.6
Backend service proving Redis caching with measurable performance gains.
| Layer | Technology |
|---|---|
| Backend | Java 17, Spring Boot 2.6.6, Spring Web, Spring Data JPA |
| Cache | Redis with Jackson JSON + @Cacheable |
| Database | H2 in-memory for dev/testing |
| Ops | Docker Compose, Timing logs, Spring Boot Actuator |
Before Redis: Student GET 85ms DB query
After Redis: Student GET 2ms cache hit
Speedup: 42.5x faster with @Cacheable on service layer
Proof method: System.currentTimeMillis logs in console
@Cacheable(value = "student-cache", key = "#id")
@Transactional(readOnly = true)
public Student getstudentById(Long id) {
long start = System.currentTimeMillis();
Student student = studentRepository.findById(id).orElse(null);
System.out.println(
"DB hit for ID " + id + ": "
+ (System.currentTimeMillis() - start)
+ "ms"
);
return student;
}Spring Boot Actuator was used for application monitoring and observability.
Monitoring endpoint:
/actuator/metrics/http.server.requests?tag=uri:/student/students
Collected metrics:
- HTTP request count
- Total processing time
- Maximum latency
- HTTP methods
- URI performance
- HTTP status codes
Example monitoring result:
COUNT: 5015 requests
TOTAL_TIME: 16.48 seconds
MAX: 0.026 seconds
Add screenshot:
docs/screenshots/actuator-http-server-requests.png
ApacheBench (ab) was used to test the student endpoint under concurrent load.
Command:
ab -n 5000 -c 100 https://<application-url>/student/students| Parameter | Result |
|---|---|
| Total Requests | 5000 |
| Concurrent Users | 100 |
| Failed Requests | 0 |
| Metric | Value |
|---|---|
| Requests per second | 82.68 |
| Average request time | 1209 ms |
| 50% requests completed within | 595 ms |
| Maximum request time | 9900 ms |
Add screenshot:
docs/screenshots/load-test-apachebench.png
Student endpoint successfully tested:
GET:
/student/students
Response:
[
{
"id": 1,
"studentName": "John Doe",
"email": "john@test.com",
"regDate": "2026-07-18",
"courseName": "Computer Science"
}
]Add screenshot:
docs/screenshots/student-api-response.png
docker compose up -d
mvn spring-boot:runApplication:
http://localhost:8080
- Add Redis cache load test comparison
- Compare database performance vs Redis cache hits
- Add JVM and memory Actuator metrics
- Add Prometheus/Grafana dashboard (if required)
- Add final performance comparison screenshots
Required screenshots:
Browser URL:
/actuator/metrics/http.server.requests?tag=uri:/student/students
File:
actuator-http-server-requests.png
Browser URL:
/student/students
File:
student-api-response.png
Codespace terminal showing:
ab -n 5000 -c 100 ...
Requests per second: 82.68
Failed requests: 0
File:
load-test-apachebench.png
git add README.md docs/screenshots
git commit -m "Add actuator monitoring and load testing evidence"
git push