Request Limits (Hard Rules)
This system enforces strict limits to prevent OOM and service instability.
Important: 120s is a hard safety cap, not a design target.
1. Hard Safety Caps (Server-Enforced)
| Setting | Limit | Notes |
|---|---|---|
| PHP-FPM request timeout | 120s | Requests beyond this may be terminated |
| PHP max execution time | 120s | Safety cap to prevent stuck workers |
| PHP memory per request | 256MB | Prevents runaway memory usage |
✅ These caps protect production stability.
❌ These are not recommended targets for normal web requests.
2. Web Request Design Targets (Developer Rules)
All HTTP requests must be designed to complete quickly.
Recommended Targets
| Request Type | Ideal | Max |
|---|---|---|
| Public pages | 200ms – 2s | 10s |
| APIs | < 1s | 5–10s |
| Forms/auth flows | < 2s | 10–15s |
| Admin actions (rare) | < 5s | 30s (absolute max) |
If a request cannot reliably complete within these limits, it must be moved to a queue job.
3. Queue / Background Jobs (Where Heavy Work Belongs)
Heavy processing is allowed only in background jobs.
| Work Type | Where | Typical Timeout |
|---|---|---|
| Reports/exports | Queue job | 120–300s (split if needed) |
| Bulk processing | Queue job | 120–300s |
| Image/video processing | Queue job | 120–300s |
Required Pattern
- HTTP request should:
- Validate input
- Dispatch job
- Return immediately (Accepted / Processing)
- Job should:
- Run with memory/time caps
- Be retry-safe and idempotent
4. Strictly Forbidden in Code
Runtime overrides that bypass safety caps are not allowed:
php
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 100000);
ini_set('upload_max_filesize', '2G');
ini_set('post_max_size', '2G');
Campus On Click