Cloudflare Workers Outperforms Vercel in CPU-Intensive Tasks

Cloudflare Workers has narrowed the gap with Vercel in CPU-intensive tasks, thanks to significant improvements made by the company. The initial results showed Cloudflare Workers performing worse than Node.js on Vercel at various CPU-intensive tasks, with a difference of up to 3.5x.

However, after investigating and addressing several issues, Cloudflare has reported that Workers now performs on par with Vercel in every benchmark case except one based on Next.js. The company attributes this improvement to better tuning and heuristics for scheduling and garbage collection, as well as optimizing the performance of popular web frameworks like OpenNext.

One key issue was related to sharding and warm isolate routing, which caused latency and variability in benchmark results. Cloudflare has updated its algorithm to detect sustained CPU-heavy workloads earlier and bias traffic towards new isolates spinning up faster.

Additionally, the company found that V8 garbage collector tuning was affecting performance, particularly for short-lived objects. Cloudflare has since backed off on manual tuning and now allows V8 to pick its young space size more freely based on its internal heuristics.

The team also discovered issues with unnecessary buffer allocations and copies in OpenNext, which were causing significant delays. These have been addressed through pull requests, resulting in improved performance for Workers.

In a final note, Cloudflare acknowledges that benchmarks can be biased and highlights the importance of continuous testing and iteration to improve open-source infrastructure. The company plans to release further improvements, including more efficient scheduling algorithms, and will work with framework authors to reduce overhead in hot paths.

Source: https://blog.cloudflare.com/unpacking-cloudflare-workers-cpu-performance-benchmarks