Hạn mức tốc độ mặc định
| Gói dịch vụ | Tốc độ tối đa (QPS) | Chính sách quá tải |
|---|---|---|
| Free / Starter | 10 requests / giây | HTTP 429 kèm Retry-After |
| Pro VIP | 60 requests / giây | HTTP 429 kèm Retry-After |
| Enterprise | 120 - 500 requests / giây | Cụm dedicated worker riêng |
Thuật toán gửi lại an toàn (Jitter Backoff)
// Thuật toán gửi lại an toàn khi gặp 429 hoặc timeout
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const res = await fetch(url, options);
if (res.status === 429) {
const retryAfter = Number(res.headers.get("Retry-After") || 2);
await new Promise(r => setTimeout(r, retryAfter * 1000));
continue;
}
return res;
} catch (err) {
if (attempt === maxRetries - 1) throw err;
const delay = Math.min(10000, 1000 * Math.pow(2, attempt) + Math.random() * 500);
await new Promise(r => setTimeout(r, delay));
}
}
}