Photo by cottonbro studio from Pexels
Mobile apps that depend on large language models face a unique latency challenge: network conditions are unpredictable, regional variance is real, and user expectations for responsiveness remain high. Unlike backend services that can lean on dedicated infrastructure and consistent uptime, mobile clients must handle everything from 4G variability to WiFi dropout to carrier-specific routing delays. The difference between a 3-second timeout and a 15-second timeout can mean the difference between a seamless user experience and frustrated users hitting the back button.
This article walks through how to set timeout values that actually work in production, not conservative guesses, but values grounded in real latency profiles from LLM API providers across multiple regions.
TL;DR
- Connection timeouts should be 5–10 seconds; LLM APIs rarely fail to respond faster. Set connection timeout separate from read timeout.
- Read timeouts (time to first token, TTFT) vary widely by region: 2–8 seconds for fast regions, 10–20 seconds for slower ones. Use 30 seconds as a safe global default, or implement regional overrides.
- Total request timeout (end-to-end, for short completions) should be 60–90 seconds. For streaming or longer generations, raise to 120+ seconds or disable per request.
- Monitor actual latency from your user regions using synthetic probes. Observinio tracks TTFB and TTFT across 21 regions so you can tune timeouts to your real traffic patterns.
- Retry logic matters more than timeout length: exponential backoff with 2–3 retries recovers transient failures better than aggressive retries.
Why Timeouts Matter for Mobile LLM Apps
Mobile apps are not servers. When your backend calls OpenRouter or OpenAI, it can afford to wait 30 seconds because the cost of that latency is borne by your infrastructure. When your user's phone makes that call, whether through your backend proxy or directly to the provider, that delay is their experience. A 20-second wait on a phone is perceived as failure. A 5-second wait feels snappy.
Timeout settings bridge the gap between the worst case (a request hangs forever) and the best case (instant response). But they also silently fail requests that are simply slow, slow due to regional network congestion, not provider failure.
The mobile context makes this worse:
- Network variability is extreme. A user on 4G in São Paulo has different latency characteristics than one on WiFi in Singapore. The same LLM request might take 2 seconds from one region and 15 from another.
- Provider latency is not uniform. OpenRouter's latency to Tokyo differs from its latency to Lagos. OpenAI's regional availability means some regions route through intermediaries.
- Users expect mobile responsiveness. They tolerate 2–3 second delays for complex operations, but anything longer triggers frustration and app abandonment.
- Timeout cascades. If you set a 5-second total timeout but the connection itself takes 3 seconds to establish, you have only 2 seconds for the actual API call. This leads to false failures and unnecessary retries.
Understanding Timeout Layers
Before setting numbers, understand the timeout stack:
Connection Timeout (TCP handshake)- Time to establish a TCP connection to the LLM API endpoint.
- Typical: 1–3 seconds. Rarely exceeds 5 seconds unless the network is severely degraded.
- If this times out, the request never reaches the API server.
- Time to resolve the API hostname to an IP.
- Typically part of connection timeout, but can be separate in some HTTP clients.
- Usual: 500 ms–2 seconds.
- Time from sending the HTTP request to receiving the first byte of response (TTFB).
- For LLM APIs, more importantly: time to receive the first token (TTFT).
- This is where real latency variance lives. Can be 500 ms in ideal conditions, 15+ seconds in congested regions.
- Time from initiating the request to receiving the complete response.
- For streaming responses, this might be "time to start streaming" (TTFT), not the full completion.
- For non-streaming, this includes the full generation time.
Real-World Latency Data Across Regions
Observinio monitors LLM API latency from 21 regions. Here's what typical TTFB and TTFT look like:
Fast Regions (US East, Europe Central)- TTFB: 100–300 ms
- TTFT: 500–2,000 ms
- Total (short completion): 2–5 seconds
- TTFB: 300–800 ms
- TTFT: 2–8 seconds
- Total (short completion): 5–15 seconds
- TTFB: 800–2,000 ms
- TTFT: 8–20 seconds
- Total (short completion): 15–40 seconds
"The app is designed for use on multiple devices, including Windows, Linux, and Android, though MacOS and iOS releases are not yet available.">, 7 Mobile Apps For Running Local LLMs (Offline)
This is relevant for mobile because local LLMs avoid network latency entirely, but they trade network latency for inference latency on device. Mobile apps calling remote LLMs must account for both.
Recommended Timeout Values for Mobile
Conservative Global Settings (Works Everywhere)
If you ship to a global audience and cannot optimize per-region, use these baseline timeouts:
- Connection timeout: 8 seconds
- Read/TTFB timeout: 15 seconds
- Total request timeout: 90 seconds
Optimized Settings by Region
If you can implement regional overrides (most practical for platform teams), use this matrix:
| Region | Connection | TTFB | TTFT | Total |
|---|---|---|---|---|
| US East | 5s | 5s | 3s | 60s |
| US West | 5s | 5s | 3s | 60s |
| Europe | 5s | 8s | 5s | 60s |
| Asia Pacific | 8s | 12s | 8s | 90s |
| South America | 8s | 12s | 8s | 90s |
| Africa / Middle East | 10s | 20s | 15s | 120s |
Streaming vs. Non-Streaming
For streaming completions (SSE or chunked transfer):- Connection timeout: same as above.
- TTFT timeout: 15–30 seconds (time to first chunk).
- Chunk timeout: 10 seconds (time between successive chunks).
- Total timeout: disable or set very high (300+ seconds) because the user might read slowly.
- Connection timeout: same as above.
- Read timeout: combine TTFB + generation time; use 60–90 seconds as safe default.
- If you know max completion length, estimate generation time: roughly 50–100 tokens/second for fast models, 20–50 for larger ones.
Implementation: Timeout Configuration Checklist
Your progress is saved automatically in your browser.
Code Example: Swift (iOS)
Here's a minimal example for iOS using URLSession:
import Foundation
let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = 90.0 // Total request
config.timeoutIntervalForResource = 300.0 // Full resource download
config.timeoutIntervalForConnectivity = 8.0 // TCP connection
config.waitsForConnectivity = true // Retry if network becomes available
let session = URLSession(configuration: config)
var request = URLRequest(url: llmAPIURL)
request.timeoutInterval = 30.0 // Per-request override for TTFB
let task = session.dataTask(with: request) { data, response, error in
if let error = error as NSError? {
if error.code == NSURLErrorTimedOut {
// Handle timeout specifically
print("Request timed out after 30 seconds")
}
}
}
task.resume()
Retry Logic and Backoff Strategy
Timeouts alone do not make requests reliable. Pair them with smart retry logic:
Exponential backoff with jitter:
delay = initial_delay * (2 ^ attempt) + random(0, jitter)
attempt 1: wait 100ms, retry
attempt 2: wait 100–300ms, retry
attempt 3: wait 200–600ms, retry
attempt 4: fail
This spreads retries across time, avoiding thundering herd when many clients retry simultaneously.
Idempotency key:
For completions and other non-idempotent operations, use an idempotency key (a unique request ID) so the API can deduplicate retries. This prevents double-billing if a request succeeds on attempt 2 but the response is lost due to network error.
- Timeout: retry with backoff.
- 4xx (bad request, auth failed): do not retry.
- 5xx (server error): retry with backoff, but limit to 1–2 retries.
- Network error (connection refused, DNS failure): retry with backoff.
Monitoring and Alerting
Set up alerts in Observinio or a similar tool to catch when your actual latencies exceed your configured timeouts:
- Alert if p95 TTFB > your read timeout × 0.8. This signals that real users are approaching timeout limits.
- Alert if timeout error rate > 1%. More than 1% timeouts usually indicates a provider issue, regional degradation, or misconfigured timeout.
- Weekly latency report. Review regional latency trends. If a region consistently slower, consider a timeout increase or alternative provider for that region.
FAQ
Frequently Asked Questions
Putting It Together
Timeout configuration is not a one-time setup; it is an ongoing dial that you tune based on real latency data. Start with conservative values (8s connection, 15s read, 90s total), instrument your app to measure actual latencies, and then tighten timeouts based on your regional performance profile.
The key is measuring: without visibility into your actual TTFB and TTFT across regions, you are guessing. Observinio provides that visibility by probing your LLM endpoints from 21 regions daily, comparing against baselines, and alerting you when latency degrades. This data lets you set timeouts that are aggressive enough to catch real failures but forgiving enough to avoid punishing users in slower regions.
For mobile apps, this balance is critical. Your users expect responsiveness, but they also expect your app to work reliably, even from halfway around the world.
Ready to Optimize Your LLM Timeouts?
Start monitoring your LLM API latency from multiple regions today. Set up Observinio to get daily regional latency probes and degradation alerts, then use that data to configure timeouts that actually reflect your real-world conditions.
Set Up ObservinioAdditional Resources
- 7 Mobile Apps For Running Local LLMs (Offline) - Sci Fi Logic - PocketPal is a straightforward, open-source mobile client designed to run GGUF-based models locally on your device. It doesn't rely on external services.
- Best LLM Observability Tools for Production Apps - Compare LLM observability tools for production. Covers LangSmith, Helicone, W&B, Arize, and OpenLLMetry for monitoring costs, quality, and performance.
- Integrating ChatGPT & LLMs into Your Mobile App: A 2025 Guide - Learn how ChatGPT integration can help your mobile app provide intelligent, responsive features while managing latency and costs effectively.
