Server slower through Cloudflare, why?
I compare the time it takes to load a simple index.html file on both server, with and without cloudflare.
Both servers are configured the same, but are located in two different locations.
Server1 on west coast, server2 on east coast of the US.
When I access both of them through cloudflare, I am served with a cloudflare IP that is located in west coast (so closer to server1).
So both the nearest cloudflare datacenter and server1 are located west coast.
And indeed when I access server1 and server2 directly without cloudflare, using their IP addresses, I get a faster load time with server1, which makes sense since I am closer to it.
However, when I access them through cloudflare, server1 loads slower than server2, which to me doesn't make any sense.
How to explain the difference? What to do to solve the issue?
1 Reply
Cloudflare IPs don't have true locations, it's all anycast (you connect to the closest). Any of the "IP" locations you see on them are just because they have to be geolocated somewhere, but because they are anycast, you will be routed to the closest cloudflare colo (datacenter). If you go to <your-domain>.com/cdn-cgi/trace, the colo= is the airport code of the one you hit.
There's going to be some overhead in the connection, depends on how exactly you are being routed though, and how big the difference is.
Also, the way you are routed on the internet depends on a lot of factors, and isn't just the shortest route. The route you get to the west coast server unproxied might be fairly direct, but through cloudflare, maybe you go a bit further off to reach Cloudflare, and the route Cloudflare gets is a bit more suboptimal. It's hard to say without a bit more information on how big the difference is, and which colo you connect to/how close it is to you.