generated from host-uk/core-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
Description
Description
The AuthenticateApiKey middleware calls recordUsage() synchronously on every authenticated request. This adds a database write to the critical path of every API call.
Location
- src/Api/Middleware/AuthenticateApiKey.php:79
The comment says non-blocking but the implementation is a synchronous database update in src/Api/Models/ApiKey.php:262-265.
Impact
- Latency: Every API request incurs a database write
- Database load: High-traffic APIs will hammer the database with updates
- Failure cascade: Database slowdowns affect all API requests
Recommended Fix
- Queue the update to a background job
- Batch updates using cache with periodic flushes
- Debounce with cache - only update if more than N seconds since last update
Priority
Medium - Impacts API latency and database load at scale.
Reactions are currently unavailable