Skip to main content

The execution flow for image and video resizing

In basic form, the way image and video resizing is implemented involves using 'serverless' cloud functions. This doesn't mean an eldritch horror creature performs them, but simply that you don't have a dedicated server waiting to run them; you request to run your function on demand, and then the service provider allocates a server to run it.

Reasons you don't want to be resizing media on your webservers

CPU Load

Webservers are poorly suited to handle heavy processing tasks. They are there to serve web traffic, not perform image transformations - handling image resizing there will slow a website down very quickly.

Available code libraries and performance

Webservers often do not have efficient libraries for processing, resizing and re-encoding media efficiently or quickly. A common example of an image manipulation library on webservers is Imagick, which is not regarded as particularly efficient.

Concurrency and scaling

Using cloud functions allows for performing many image resizes concurrently, reducing the time needed to perform many resizes of one image. You can't really do this with webservers, and certainly not in a way that won't impact performance.

The basic execution flow for media resizing

The basic execution flow looks like this:

image.png

It's the same for videos, but with a longer processing time.