Before a relay could sit in front of a real shop, it had to meet criteria written down in advance. One of them was about speed. It failed on the first measurement by a wide margin, and a result like that could have pushed the project onto a different platform. This is the record of that measurement, and of the six separate things that went wrong on the way to the first working connection.

The criteria

The proof-of-concept design fixed its pass conditions before any code ran against a client. Two of them matter here.

CriterionDefinition
Bypass paths are untouchedFor checkout and account paths, the response through the relay is byte-identical to the response from the origin
LatencyThe 95th-percentile time to first byte through the relay is within 100 ms of the same measurement without it

Both are checked by one script. It reports the 95th percentile and not the mean. It compares bodies by hash. And before comparing anything it fetches the origin twice, because some pages are not deterministic: a page that embeds a timestamp or a rotating banner differs from itself. Those pages are reported as not comparable, not as failures.

The failure

The first latency run missed the 100 ms criterion by several hundred milliseconds.

A result like that invites large decisions. If a Worker adds most of a second, the candidates are a paid plan with better routing, or abandoning the edge platform for a self-hosted proxy in the client’s region. The postmortem says so directly: had the place of measurement not been doubted, one of those decisions would have been made, and it would have been wrong.

Finding it

Two bands. Measured from the office line: a probe on an office connection in Seoul reaches an edge Worker, because this line was routed to a data centre across the Pacific, which then fetches the origin in Korea, with a result far outside the plus 100 millisecond criterion. Measured from a host in the region: a probe on a cloud host in Seoul reaches an edge Worker served from the Seoul data centre, which fetches the origin in Korea, with a result inside the criterion. A note: same zone, same code, different data centre; which edge location answers depends on the network the request comes from; one command shows it, since the trace endpoint reports the location that served the request; the fix was to the measurement, not to the Worker.
Figure 1. Two measurements of the same Worker. From the office connection, requests were served by an edge location across the Pacific and crossed the ocean twice. From a host in the region, they were served locally.

Cloudflare exposes a trace endpoint on every zone that reports, among other things, which edge location served the request. One line shows it.

$ curl -s https://<host>/cdn-cgi/trace | grep colo
colo=LAX        # from the office connection
colo=ICN        # from a cloud host in Seoul

The office’s internet provider was being routed to a location on the west coast of the United States. The origin is in Korea. Every measured request went from Seoul to Los Angeles to reach the Worker, back to Korea to reach the origin, back to Los Angeles with the response, and back to Seoul. The Worker was being timed on two Pacific crossings.

Measured again from a cloud host in Seoul, where requests were served by the Seoul location, the criterion passed.

Nothing in the Worker changed. The fix was to the measurement. The runbook gained a rule: a result from one vantage point is not a conclusion.

What the relay does cost

A later analysis on a second site separated the Worker’s cost from the path’s.

ComponentFinding
Worker CPUOne to three milliseconds per request
Wall timeAlmost all of it is waiting for the origin
Counting visitsSuspected and cleared. The counter is written after the response is returned, so it does not delay it
The structural costOne more TLS handshake per request, between the edge and the origin. It is paid on every request and no change to the Worker’s code removes it

There is a lever on the last row: TLS session resumption on the origin would shorten the repeated handshake. It was deliberately left alone. The setting belongs to a certificate tool’s managed configuration, and changing it trades away some forward secrecy.

Six failures before the first connection

The latency scare was one episode among several. The first attempt to connect a host, the company’s own shop, failed six times and was rolled back. The second attempt, a day later, worked.

#What went wrongCauseWhat changed
1The relay would have fetched itselfThe origin address in the site config pointed at a name that resolved back to the relayThe origin value was corrected to a name that does not pass through the relay. The loop guard, which answers 502 with a reason header, was already in place
2Requests on the custom host returned 522The Worker’s route matched only the service’s own hostname, not custom hostnamesThe route became a wildcard over every host
3A route fixed in the dashboard disappeared, twiceThe deploy command overwrites routes from the config fileRoutes live in the config file only
4The certificate stayed pendingThe wildcard route made the Worker intercept the certificate authority’s validation request/.well-known/ is passed through before any site config is read
5DNS validation never matchedThe validation record’s value changed each time it was viewedValidation moved off that method
6Delegated validation could not work at allThe domain’s DNS provider answered for the delegation target itselfHTTP validation, which issued the certificate in about a minute

Three of the six became permanent tests: the validation path always passes, a custom host is recognised by the loop guard, and a config that cannot be read falls back to defaults that keep the loop guard active. The 403 incident described on the edge relay page happened on the same connection and became a fourth.

What changed in the process

  • A question added to onboarding: where is your domain’s DNS managed? The answer decides the certificate method before anyone touches a record.
  • A checklist per host: the origin name does not pass through the relay, the host is registered with the loop guard, routes are set in the file, the DNS record’s time to live is lowered the day before where the provider allows it, a baseline is measured first, and the connection starts with injection disabled.
  • A check that the injection is where readers are. On one site the relay sat on the www host while the pages’ canonical address was the bare domain. AI crawlers followed the canonical address and never saw the injected content. The runbook now starts by asking which address AI actually reads.

Failure modes

What happensWhat is done
A latency number looks alarmingThe edge location is checked first, then the measurement is repeated from inside the region
A page is not deterministicIt is reported as not comparable and left out of the byte comparison
A percentile rests on few samplesIt is labelled as such and measured again after a few days
A connection goes wrongThe DNS record is restored, and the record’s time to live bounds the outage. One managed DNS fixes that value at 30 minutes

Limits

  • Latency has no automated regression test. It is measured with the probe script before and after a connection, by a person.
  • Small samples. A 95th percentile over twenty requests is decided by one slow request.
  • The extra handshake remains. It is a property of putting a relay in the path.
  • Vantage points are few. Two locations settled this question. Visitors on other networks may be routed elsewhere, and only the edge provider’s own analytics show the full distribution.