AJAX - Concurrency Limits & Backoff / Retry Strategies


1. What Is Concurrency in AJAX?
Concurrency means:
How many AJAX requests are sent at the same time from a client (browser/app) to a server.
Example:
-
Page loads
-
10 API calls fire together (profile, notifications, messages, ads, analytics)
If not controlled → problems occur.
2. What Are Concurrency Limits?
Concurrency limits are restrictions on:
-
How many requests a browser can send at once
-
How many requests a server allows from one client
These limits exist to:
-
Protect servers
-
Prevent overload
-
Ensure fair usage
3. Where Do These Limits Come From?
Browser Limits
-
Browsers limit concurrent connections per domain
-
Prevent network flooding
Server Limits
-
APIs often limit requests per user/IP
-
Example: 100 requests per minute
If exceeded → server responds with:
HTTP 429 – Too Many Requests
4. Problems Without Concurrency Control
If many requests are fired blindly:
❌ Server overload
❌ Requests fail randomly
❌ UI becomes slow or unstable
❌ Users see errors
This is common in:
-
Search autocomplete
-
Infinite scrolling
-
Dashboards
5. What Is Retry Strategy?
A retry strategy means:
Trying the same request again if it fails temporarily.
Used when failure is due to:
-
Network issue
-
Temporary server overload
-
Rate limiting (429)
Retrying blindly is dangerous.
6. Why Simple Retry Is Bad
Bad approach:
Request fails → retry immediately → fails → retry again
This causes:
-
More server load
-
Infinite loops
-
App crashes
So we use Backoff.
7. What Is Backoff Strategy?
Backoff means:
Waiting for some time before retrying a failed request.
Each retry waits longer than the previous one.
This gives:
-
Server time to recover
-
Network time to stabilize
8. Exponential Backoff (Most Important)
In Exponential Backoff, delay increases exponentially.
Example delays:
1st retry → wait 1 second
2nd retry → wait 2 seconds
3rd retry → wait 4 seconds
4th retry → wait 8 seconds
This is the industry standard.
9. Combining Concurrency Limits + Backoff (Best Practice)
Step-by-step flow:
-
Send limited number of requests at once
-
If request fails:
-
Check error type
-
-
Retry only if:
-
Error is temporary
-
-
Apply exponential backoff
-
Stop after max retries
10. Simple Conceptual Example (No Heavy Code)
Search Input Case
-
User types quickly
-
Old requests are cancelled
-
Only latest request is allowed
-
If server replies 429:
-
Wait
-
Retry with backoff
-
This prevents:
-
Server abuse
-
Wrong UI updates
11. HTTP Status Codes You Must Remember (Exams)
| Status Code | Meaning |
|---|---|
| 429 | Too Many Requests |
| 503 | Service Unavailable |
| 504 | Gateway Timeout |
These are retry-eligible errors.
12. When Should You NOT Retry?
❌ 400 Bad Request
❌ 401 Unauthorized
❌ 403 Forbidden
❌ Validation errors
These mean:
-
Client mistake
-
Retrying will not help
13. Exam-Friendly Definitions
-
Concurrency Limit:
The maximum number of simultaneous AJAX requests allowed by a browser or server.
-
Retry Strategy:
A controlled mechanism to resend failed requests under specific conditions.
-
Backoff Strategy:
A technique where retry attempts are delayed progressively to reduce server load.
-
Exponential Backoff:
A retry method where the waiting time doubles after each failed attempt.
14. Real-World Applications
-
Payment gateways
-
Cloud APIs
-
Search suggestions
-
Social media feeds
-
Mobile apps
Almost every large system uses this.
15. Why This Topic Is Important for Students
-
Frequently asked in AJAX / API theory
-
Shows understanding of scalable systems
-
Important for interviews
-
Prevents common real-world bugs