Getting slower results using CloudFlare Workers and WebPageTest

I tried to create few tests for case when CF is in front of Client Solution based on last Twitch session (at first I wanted to test preload for background image that is LCP, but when I saw results that I didn’t expect I changed Worker just to proxy request and result is the same - much slower load), and each time results were worse then without it. Does anyone have any hint what might be the problem?

I’ve read some articles that there should be gain from performance perspective when CF is used just as proxy.

1 Like

I’ve read some articles that there should be gain from performance perspective when CF is used just as proxy.

Depends on what you already have in place, I suspect. Do you have any tests you can share?

1 Like

Only in private message. :neutral_face:

1 Like

By definition adding any proxy between a client and server is adding “work”. Therefor generally adding latency.

One benefit of TLS termination at the edge is that the TLS handshake will be faster if the round trip time to a closer physical location is faster than a far away origin server. This was more important in the early years of CloudFlare when HTTP/1.1 was the majority traffic. With HTTP/2 this is not nearly as much of a benefit as fewer TLS handshakes will be performed (perhaps as low as only 1 for an optimized site). Also this will be more apparent when testing from locations far away from your origin and may not improve things when testing locally close to your origin server.

The latency for adding a proxy can also be offset using content caching in cloudflare (1st visit still slower, subsequent visits faster). This was the original benefit of CloudFlare in its earliest years: edge caching. For this to work your content must be cacheable with the correct cache control headers set from your server.

CloudFlare also developed a bunch of creative ways to reduce latency between the cloudflare edge and your origin server.

CloudFlare created “RailGun” for optimizing the connection between web hosting companies and cloudflare edge. This works for webhosts that are cloudflare partners.

CloudFlare also created another paid option with “Argo” which can gather resources from your origin with the optimal cloudflare network route and then tiering down to other locations. I havent used this one, but hear it is good too.

And then recently CloudFlare also released CloudFlare “Pages” for hosting static websites on CloudFlare. This is even faster as your origin is now inside CloudFlare! My website is hosted on CloudFlare Pages and is rather fast. There are now a lot of CMS packages that can generate to static output.

Last but not least, CloudFlare is not a magic solution to eliminate all other web optimization work! Just as you can’t buy a pill for an overnight beach body, you can’t buy a quick fix for a poorly optimized website.

You must still follow all the basic best practices, such as those recommended by google lighthouse. Reducing or eliminating render blocking requests, removing unused JS/CSS, serving sensibly sized images in modern efficient formats, etc. Combine good web optimization, with edge caching, and you can acheive excellent results!

Feel free to run my site through webpagetest if you want to analyze the webperf stuff.

1 Like

Seems that Cloudflare workers might have some overhead. E.g. KV store might have a “cold start” overhead, which will be mostly felt for rarely visited urls + rare user location combination. CF will need to request data from remote node if it wasn’t recently requested in particular location.

1 Like

Its reasonable that this action means adding “work” and still I expected better results because client is currently using HTTP 1.1.

I also played a with CF settings, tried to guess if there are non-documented settings for http prioritization, polish and rocket loader. But this was without any success.

@tkadlec So, message form Twitch session would be to compare CF Workers as proxy with CF Workers with perf improvements (as adding preload for LCP image or similar)?

1 Like

So, message form Twitch session would be to compare CF Workers as proxy with CF Workers with perf improvements (as adding preload for LCP image or similar)?

Yeah, absolutely. If you’re using workers to apply optimizations, then use a worker proxied tests without those optimizations as your baseline for comparison.

2 Likes