Offloading Image Optimization from Next.js SSR to Cloudflare Edge for High-Traffic Sales
During high-traffic events such as Black Friday, the Next.js /_next/image endpoint can become a CPU and memory bottleneck, since libvips processing of resizing and format conversion can drive Node.js pods to 100% CPU and trigger Kubernetes OOMKills. The article argues that handling heavy binary transformations inside the SSR runtime is an architectural anti-pattern. It proposes moving image transformation to Cloudflare Images and Cloudflare Image Resizing at the Anycast edge, so the application server only generates HTML. Implementing a custom Next.js loader translates Next's width and quality parameters into Cloudflare's transformation syntax. The approach aims to preserve Time to First Byte at e-commerce scale with millions of SKUs.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in