Performance: Why JWT matters for APIs
MEDIUM IMPACT
This affects API response time and server load by how authentication tokens are verified and managed.
Use JWT tokens that carry user info and are verified via signature without DB calls.Use server-side sessions stored in database for every API request authentication check.
| Pattern | DB Calls | CPU Usage | Response Latency | Verdict |
|---|---|---|---|---|
| Server-side sessions | 1 DB call per request | Higher due to DB I/O wait | Increased by 10-50ms | [X] Bad |
| JWT tokens | No DB calls per request | Lower CPU for signature check | Minimal added latency (~1-2ms) | [OK] Good |