SwiftRoute
URL Shortener & Analytics Backend
p95 Latency Cut
93.3%
760.19 ms → 50.65 ms
Throughput Lift
3.61x
107.90 req/s (25 VUs, 70s)
Write Safety
0 collisions
Across 500 concurrent writes
Automated Tests
11 classes
JUnit 5, Mockito & @WebMvcTest
The Problem
Uncached relational redirect paths suffer heavy latency under concurrent traffic, while sequential IDs leak predictable URLs and synchronous analytics writes slow down 302 responses.
Architecture & Engineering Decisions
- Built a layered REST API with collision-safe Base62 short codes, custom aliases, stateless dual-token JWT HttpOnly cookie auth, and Swagger/OpenAPI docs; containerized with Docker and deployed on Render.
- Implemented cache-aside and write-through Redis caching with TTL expiration, @Async click logging, and HikariCP pool tuning, removing synchronous PostgreSQL reads and click writes from the 302 redirect path.
- Benchmarked with Grafana k6 (25 VUs, 70s, local JAR + cloud Supabase/Upstash), cutting p95 latency by 93.3% (760.19 ms to 50.65 ms vs. uncached DB), lifting throughput 3.61x (107.90 req/s), with 0 collisions across 500 concurrent writes.
- Built an automated test suite across 11 classes using JUnit 5, Mockito, and Spring MockMvc (@WebMvcTest) covering services, JWT security filters, Base62 encoding, and REST controllers.