Use the Left and Right arrow keys, or swipe, to move between sections.

Serverless Image Processor

A serverless service on AWS that resizes, blurs and crops images when an app asks. It shows how to build an image pipeline that grows with demand and only uses computing power while it works.

Role
Sole engineer, university cloud computing course project
Built
January to April 2024
Tools
AWS Lambda, Step Functions, API Gateway, S3, CloudFormation, Python
Status
Code public

The problem

Many apps need to change images. Online stores, social apps and content sites all resize, blur or crop pictures every day. Keeping a server running all day for this wastes money, because the work comes in bursts. Most of the time that server would sit idle, waiting for the next image.

I built this for my cloud computing course to show a better way. It is a service that photographers, businesses and developers can call over the web. Every part is pay per use, so the processing only runs when there is work.

How it works

Client appAPI GatewayStep FunctionsAWS BackupS3 bucketImage LambdasSNS email123456
  1. The app sends a JPEG image to the API.
  2. API Gateway saves the image straight into S3, with no extra code in between.
  3. The app then asks for an edit, such as resize, blur or crop, and API Gateway starts a Step Functions workflow.
  4. The workflow reads the request and hands it to the matching Lambda function, retrying up to 3 times if AWS has a hiccup.
  5. The Lambda edits the image with Pillow and saves the result in its own folder in S3.
  6. If the request asks for an edit the service does not offer, SNS sends me an email alert.

Decisions

  • Chose Step Functions to send each job to the right function over one big Lambda full of if and else checks, or AWS Glue

    Step Functions shows the whole flow as a picture and has retries and error handling built in. Glue is made for heavy data jobs, which this is not.

  • Chose three small Lambdas, one per edit over one Lambda that does every edit

    Each function does one job, so a bug in crop cannot break resize or blur. Adding a new edit takes one new function and one new line in the workflow.

  • Chose one CloudFormation file for the whole stack over setting things up by clicking through the AWS console

    Anyone can read the file and build the exact same stack. Deleting the stack removes everything at once, so nothing is left running up a bill.

By the numbers

AWS services working together
6
Template that builds the whole stack
1
Automatic retries when a step fails
3

Where it is now

This was a term project and it is no longer running. It lived in a student AWS account that has since closed.

The code, the template and the full write up are public on GitHub. The next steps I listed at the time were more image effects, live processing, and automatic testing and deployment.

Code on GitHub