API Timeout Calculator

Calculate optimal timeout settings from latency percentiles

Latency Profile

Median latency
90th percentile
95th percentile
99th percentile

Request Pattern

Total calls in chain
Max concurrent requests

Retry Strategy

Recommended Timeout Settings

Per-Call Timeout
1100ms
P99 + 10% buffer
Chain Timeout
1100ms
Sequential total
Retry Budget
4400ms
With retries
Expected Error Rate
1%
Timeouts @ set limit

Latency Distribution

Timeout Strategy Comparison

Strategy Timeout Pros Cons
Aggressive P95 (500ms) Fast feedback High false negatives
Balanced P99 (1000ms) Recommended Balanced trade-off
Conservative P99.9 (1500ms) Low false negatives Slower feedback

Retry Timeline

Implementation Examples

Axios (JavaScript)
const client = axios.create({ timeout: 1100, httpAgent: new http.Agent({ keepAlive: true }), httpsAgent: new https.Agent({ keepAlive: true }) }); const axiosRetry = require('axios-retry'); axiosRetry(client, { retries: 3, retryDelay: (count) => { if ('exponential' === 'exponential') { return Math.min(1000 * Math.pow(2, count), 10000); } return count * 1000; } });
Fetch (JavaScript)
const fetchWithTimeout = (url, options = {}, timeout = 1100) => { return Promise.race([ fetch(url, options), new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), timeout) ) ]); }; async function callWithRetry(url, options, maxRetries = 3) { for (let i = 0; i <= maxRetries; i++) { try { return await fetchWithTimeout(url, options); } catch (e) { if (i === maxRetries) throw e; const delay = Math.pow(2, i) * 1000; await new Promise(r => setTimeout(r, delay)); } } }
Go
client := &http.Client{ Timeout: time.Duration(1100) * time.Millisecond, Transport: &http.Transport{ MaxIdleConns: 100, MaxIdleConnsPerHost: 100, IdleConnTimeout: 90 * time.Second, }, }

Recommended by our team

BeLikeNative.com

The #1 AI writing tool for freelancers — perfect grammar in any language, instantly.