Skip to main content

The Proxy Switch That Slowed the Page Down

Updated 3 min readMarkdown

The site lived on a server in Hong Kong, and most of its readers were in mainland China. A direct connection from those readers to the server was short, and a page came back in under half a second. Cloudflare's CDN proxy was switched on to make things faster still: nearby nodes would hand out cached files, and the server's real address would sit behind Cloudflare's front door.

Direct to Hong Kong was already fast

Hong Kong is close to the readers. A request went straight from a reader to the origin server, and the answer came straight back. There was no middle stop to speed up, because the trip itself was already short.

The Cloudflare switch looked like free speed

Turning Cloudflare's proxy on for the main domain and its www subdomain meant visitors would first reach a node in Cloudflare's network, and that node would fetch from the origin only when it had nothing cached. Overseas visitors stood to gain the most, since their direct trip to Hong Kong was long. Domestic visitors were expected to gain nothing much, and to lose nothing either.

The page got slower instead

After the switch, a full page took several seconds to finish, and individual API calls dragged. The direct address was still fast, so the slowdown lived on the proxy path. Something about the route through Cloudflare was costing more than the direct trip it replaced.

The nearest node was on another continent

The free plan had no node available in mainland China, so Cloudflare's anycast routing sent mainland traffic to a node on the US East Coast. From there it crossed the Pacific again to reach the Hong Kong origin, then came all the way back. The response header named the node that had handled the request, which is how the detour showed up: the traffic had gone halfway around the world to reach a server next door. The earlier expectation had been that domestic visitors would at most gain nothing. The measurement said they lost a lot.

DNS only, and what that gives up

I set the records back to DNS only. Cloudflare now only answers the question of where the site lives, and traffic goes straight to the origin. Domestic speed came back with that change. The trade is plain: overseas visitors are back to the long direct haul, the origin address is visible again, and there is no front door filtering requests before they arrive. That trade was worth it because the readers are mostly domestic. Before judging a CDN proxy switch, check where the traffic actually goes — the response header answers that in a minute, and it answers it better than the switch label does.

About the author

  • Writing about ebook technology.

No comments yet. Be the first to comment.