Building Cloudflare Images in Rust and Cloudflare Workers
The text discusses the implementation of Cloudflare Images product using reusable Rust libraries and Cloudflare Workers. It explains how Image Resizing was developed in Rust, which is a web server that receives HTTP requests for images along with resizing options, fetches full-size images from the origin, applies resizing and other image processing operations, compresses, and returns the HTTP response with the optimized image. The text also mentions how Polish, another product developed in Golang, recompresses images in their cache and uses Image Resizing via a command-line tool for lossy compression or generating WebP images or animations. Furthermore, it explains how Cloudflare Images was built in Rust as a collection of Rust crates to be reused in other services running anywhere in the network. The text also delves into how Image Resizing works at the edge and is deployed on every server of the Cloudflare global network, and how Cloudflare Images work with its components including the core service that powers the public API to manage images assets, the Image Resizing service responsible for image transformations and caching, the Image delivery Cloudflare Worker responsible for serving images and passing corresponding parameters through to the Imaging Resizing service, and image storage. The text also explains how they store information on Cloudflare Images in several places including image metadata in Cloudflare's core data centers, variant definitions in Cloudflare's edge data centers, original images in core data centers, and optimized images in Cloudflare cache, physically close to eyeballs. It further discusses how they keep processed images up to date by purging the Cloudflare cache when necessary, and how they restrict access to Cloudflare Images using URL signatures with expiration. The text concludes by mentioning that the Cloudflare Images product runs on top of the Cloudflare global network and is built in Rust and Cloudflare Workers, which allows them to use Rust reusable libraries in several products such as Cloudflare Images, Image Resizing, and Polish.
Company
Cloudflare
Date published
Sept. 15, 2021
Author(s)
Yevgen Safronov
Word count
1373
Language
English
Hacker News points
3