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.
0regions
Global monitoring coverage
Key Takeaway: Mobile LLM apps require timeout values tuned to regional latency, not global averages. Set connection timeouts to 5–10 seconds, read timeouts to 15–30 seconds (depending on region), and total timeouts to 60–120 seconds. Monitor actual TTFB and TTFT from your user regions, and implement exponential backoff retry logic with 2–3 attempts to handle transient failures without cascading delays.
Timeout configuration journey
0%

Why Timeouts Matter for Mobile LLM Apps

developer coding
Photo by Mario Amé from Pexels

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:

  1. 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.
  2. 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.
  3. Users expect mobile responsiveness. They tolerate 2–3 second delays for complex operations, but anything longer triggers frustration and app abandonment.
  4. 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.
DNS Resolution Timeout
  • 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.
Request/Read Timeout (TTFB and TTFT)
  • 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.
Total Request Timeout (End-to-end)
  • 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
Medium Regions (Asia Pacific, South America)
  • TTFB: 300–800 ms
  • TTFT: 2–8 seconds
  • Total (short completion): 5–15 seconds
Slower Regions (Africa, Remote Asia)
  • TTFB: 800–2,000 ms
  • TTFT: 8–20 seconds
  • Total (short completion): 15–40 seconds
These are not provider failures, they are the cost of physical distance and routing through regional infrastructure. A 15-second TTFT from Lagos to an API in us-east-1 is not unusual; it is physics.
"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

app interface
Photo by Luis Quintero from Pexels

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
These values are deliberately high to avoid false failures in slower regions. They make requests from Tokyo or São Paulo nearly as fast as from New York. The tradeoff is that genuinely broken requests take longer to fail, increasing perceived latency during outages.

Optimized Settings by Region

If you can implement regional overrides (most practical for platform teams), use this matrix:

RegionConnectionTTFBTTFTTotal
US East5s5s3s60s
US West5s5s3s60s
Europe5s8s5s60s
Asia Pacific8s12s8s90s
South America8s12s8s90s
Africa / Middle East10s20s15s120s
Set these as defaults on the HTTP client at app startup, keyed to the user's detected region (via IP geolocation or user preference).

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.
For non-streaming completions:
  • 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

network diagram
Photo by Lukas Blazek from Pexels
Implementation phase
0%

Your progress is saved automatically in your browser.

Mobile Apps Calling LLMs: Timeout Settings That Work process
Figure 1: Mobile Apps Calling LLMs: Timeout Settings That Work at a glance.

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.

Do not retry on all errors:
  • 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

TTFB (Time to First Byte) is the time from sending the HTTP request to receiving the first byte of the response. TTFT (Time to First Token) is more specific to LLMs: the time until the first token of the completion is available. For streaming APIs, TTFT is usually what matters for user experience; for non-streaming, TTFB ≈ TTFT. On Observinio, we measure both separately so you can tune timeouts to the specific layer that matters for your use case.
If you ship to only one region (e.g., North America), a global timeout of 60–90 seconds works fine. If you're global, per-region timeouts are better but add complexity. Start with a conservative global timeout (90s) and monitor. Once you see actual regional variance (e.g., Africa regions consistently taking 20+ seconds), implement regional overrides. Observinio's daily probes from 21 regions let you identify which regions need tuning without building your own monitoring.
Users in slower regions or on slower networks experience frequent timeouts, even when the API is working fine. This triggers unnecessary retries, frustrating users and increasing load on the provider. You end up with worse latency, not better, because retries compound the delay. Set timeouts to 1.5–2× the 95th percentile latency for your traffic, not the mean.
Technically, yes, but do not. If a request hangs (network cable unplugged, server process crashed), the request waits forever, blocking the user. Timeouts are the backstop that ensures your app remains responsive. Even if you set them high (120+ seconds), always have a timeout.
Review quarterly if you're in a stable market. If you're expanding to new regions or your provider makes infrastructure changes, review immediately. Use Observinio's alerts and weekly summaries to spot degradation patterns early. If you see timeouts creeping up (p95 latency rising), increase timeout values before users start hitting them.

Putting It Together

Final configuration and monitoring
0%

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 Observinio

Additional Resources

Article complete
0%