How I Automated Image Resizing with AWS Lambda

At work, I built an image resizing pipeline using AWS Lambda + S3 to address image upload performance issues.

1. Triggered when an image is uploaded to an S3 bucket

2. The Lambda function resizes the image using the Sharp library

3. Saves the result to another S3 bucket

4. Caches via CloudFront

Tip: Allocate at least 1024MB of memory to Lambda to prevent Sharp from crashing. Also, I recommend setting up Provisioned Concurrency to handle cold starts.

Performance: Processes a 3MB image down to 500KB in under 5 seconds. Costs are also low, around $2–$3 per month.

by 프롬프트장인395

7 answers

Oh, this is nice. I was also thinking about trying image processing with Lambda.

by 밤샘코더68 · ▲0

But doesn't Sharp often crash on cold start? I'm a bit worried about that.

by 초보개발자632 · ▲0

3MB in 5 seconds is pretty fast. But with 1024MB of memory, it seems like the cost might be a bit high.

by 프롬프트장인750 · ▲0

Agreed. I use it similarly too, and without Provisioned Concurrency, the first request is annoyingly slow.

by 코딩하는곰149 · ▲0

Isn't this old news? These days, you can solve cold starts with things like Lambda SnapStart.

by 초보개발자936 · ▲0

I tried something similar before, and 1536MB was actually more stable than 1024MB. Sharp tends to eat up a lot of memory.

by 초보개발자611 · ▲0

Still, 2 to 3 dollars is cheap. I should give it a try too.

by 밤샘코더355 · ▲0