# The tracing exporter that took the site down

> A hosted tracing backend accepted connections and never answered. Each sampled request hung for 40 seconds, the worker pool filled, and an order form went down.

Source: https://ebrahimsameh.com/blog/observability-took-the-site-down/
Updated: 2026-11-25

The thing that took a client's order form down was the tracing. The OpenTelemetry PHP SDK exports spans from a shutdown handler, and under Apache mod_php that handler runs before the response is sent. When the hosted tracing backend started accepting connections and then saying nothing, every sampled request hung for 40.66 seconds. At normal traffic that needs about 106 Apache workers, and there were 64. A 500 ms export timeout brought the worst case down to about 7 workers. Then I went looking for every other outbound call with no timeout, and there were a lot of them.

## What broke

The site is a PHP app on Apache, two containers, each running the prefork MPM with `MaxRequestWorkers 32`. One day the buyer-facing order form stopped loading.

This kind of failure is confusing to look at. CPU and memory are idle, because the workers aren't doing anything. They're each blocked on a socket. Requests past the worker limit aren't refused, either: prefork parks them in the listen backlog, so the whole site seems to hang instead of returning errors. And a readiness check that doesn't touch the slow dependency keeps answering through all of it.

## How the 40 seconds happened

The tracing backend's ingest endpoint accepted the TCP connection and then returned nothing. No refusal and no reset, just an open socket that never answered.

The export budget came entirely from defaults, because nothing in the app set one:

- `OTEL_EXPORTER_OTLP_TIMEOUT` defaults to 10,000 ms per attempt.
- The HTTP transport makes 4 attempts, the first plus 3 retries, with about 100, 200 and 400 ms of jittered backoff between them.

That's 4 × 10 s plus about 0.7 s of backoff, or 40.7 seconds. The worst case observed in production was 40.66 s.

And because the export ran in a shutdown handler that runs before the response is flushed under mod_php, the user waited for all of it. The request had finished its own work and sat there with no headers sent.

## The math that explains the outage

The number to run is "requests per second that hit the slow call × how long each one hangs". It gives you the number of workers tied up.

Peak traffic was 26 requests per second. Tracing sampled 10% of requests, so 2.6 per second opened a connection to the backend. The other 90% never queued a span or touched the network, so they were fine on their own. But they shared a worker pool with the ones that hung.

| Export hang | Workers tied up | Of 64 available |
| --- | --- | --- |
| 40.66 s (defaults) | 2.6 × 40.66 = 106 | saturated, site down |
| ~2.7 s (500 ms timeout) | 2.6 × 2.70 = 7 | about 11% |

At 106 needed and 64 available, the pool fills and stays full.

## The fix, in steps

First, tracing was turned off in production. That was done during the incident by registering new task definitions by hand with `OTEL_PHP_AUTOLOAD_ENABLED=false`. That stopped the outage, but it left a trap: the Terraform module still said `true`. The mitigation lived only in two hand-made revisions, so the next `terraform apply` for any reason would have turned tracing back on and brought the outage back. Making the "off" state explicit in Terraform was the most urgent part of the follow-up.

Second, I clamped the timeout. The retry count isn't configurable. `maxRetries = 3` is a hardcoded constructor default, with no environment variable behind it. So the per-attempt timeout is the only client-side control over the total. Setting `OTEL_EXPORTER_OTLP_TIMEOUT=500` makes the same total collapse cost 4 × 0.5 s plus backoff, about 2.7 seconds.

One trap here: `OTEL_BSP_EXPORT_TIMEOUT` looks like it should help. The batch span processor accepts it as a constructor argument and validates it, but never stores it, and the final flush waits with no deadline. Setting it looks like a fix and does nothing.

Third, tracing went back on once the backend was answering again, with the 500 ms clamp live on every environment. Only sampled requests are exposed, and their worst case is now bounded.

Fourth, the export had to come off the request path. I added an OpenTelemetry Collector sidecar behind a flag. With it on, the app posts spans to `127.0.0.1:4318`, the collector acknowledges at once, and the collector owns retries and queueing. PHP can't do that part itself: after the response there's no process left to retry in. The loopback timeout drops to 250 ms, which bounds a wedged sidecar at about 1.4 seconds. The flag ships off, and turning it on needs a separate credential for the collector. Until it's on, the 500 ms clamp is the protection.

A wedged collector would cause the same failure, just locally, so the clamp stays in place after the sidecar too. The complete fix is `fastcgi_finish_request()`, which sends the response before shutdown work runs, and that needs php-fpm instead of mod_php. That's a bigger decision and it's still open.

## The audit: every outbound call, not only tracing

Next I went through every outbound HTTP client on the request path, looking for anything else that could hold a worker. The tracing exporter at least had a 10-second timeout. Several others had worse.

- The AWS SDK had no timeouts at all. Its legacy defaults mode never fills in connect or request timeouts, and the app's config only set TLS verification, so the HTTP client waited indefinitely, with three SDK retries on top. Worse, the app registered the S3 stream wrapper, so every `file_exists()` or `file_get_contents()` on an `s3://` path was an unbounded network call. The route that serves public images did one on every hit. The fix was a 2-second connect and a 10-second total. One caller that invokes a Lambda function synchronously, with a 60-second function timeout, got its own 70-second ceiling and zero retries, so the rest of the app didn't inherit a one-minute ceiling.
- The mailer fetched attachments from the app itself. It pulled each attachment over HTTP from the app's own PDF routes, with 120-second connect and total timeouts, in a loop. That's a worker making a blocking call to another worker in the same 32-slot pool. The busier the pool, the longer the inner request waits and the longer the outer one holds its slot, so it gets worse under load instead of recovering. Web requests now get a 5-second connect and a 30-second response ceiling, and cron keeps 120 seconds for its long monthly exports.
- The mail provider's client had no connect timeout. It passed a 30-second total, but the underlying Guzzle client left `connect_timeout` at 0, which means "use the OS default", about 130 seconds of SYN retries on Linux. It now sets 10 seconds.
- The shipping API client set no timeouts at all. `set_time_limit(60)` doesn't help, because it counts CPU time and a process blocked in `recv()` uses none. This call ran first in the payment capture flow, so a hung shipping API stalled the whole settlement, leaving a payment the gateway saw as captured and the database hadn't marked paid. It now has a 5-second connect and a 30-second total.
- The error tracker sent events synchronously at shutdown, on SDK defaults of 5 seconds per event. A request that logged N errors could block for N × 5 seconds, and a request logging many errors is the one most likely to happen while the error backend is having problems. It now uses 1 second and 0.5 seconds to connect, which loses nothing, since the SDK already swallows send failures.
- Search requests inherited a bulk-sync timeout. The search client defaulted to 60 seconds, which suited the nightly bulk sync and nothing on the request path. The default is now 5 seconds, and the one bulk caller asks for 60 explicitly.

## What to check in your own system

- List every outbound call a request can make, including telemetry, logging and error reporting. For each one, find the connect timeout, the total timeout and the retry count. "Not set" usually means "forever" or "the OS default".
- Multiply the rate of requests that hit each call by its worst-case hang, and compare that to your worker count. If the result is bigger, one slow dependency can take the whole site down.
- Find out when your telemetry SDK exports. If it runs before the response is flushed, your users are waiting on your monitoring vendor.
- Watch for mitigations that live outside your infrastructure code. A setting changed by hand gets undone by the next deploy.
