I’ve just started experimenting with Lambda.
nderground
1

Serving Images from AWS Lambda

Moving image storage and display off your web server sounds like a good place to start. AWS Lambda can yield significant cost savings in many cases.

I don’t know the exact details of your situation but these are my suggestions.

Image Storage

AWS added support for Binary Data to API Gateway late last year. This makes it possible to return images from API Gateway. But, unless you are processing images on the fly, using another service is probably a better option.

Despite today’s Amazon S3 outage, I would suggest using Amazon S3 to host and display images. Amazon S3 is great for static assets like images. This will shift the load of storing and displaying images off your web server to Amazon S3.

If you want to take it to the next level, you can use Amazon CloudFront to cache your images at edge locations. This would improve performance for users access the images via a slow link by reducing the latency.

Cold Starts

You cannot pay Amazon to keep a function warm. But there are some techniques people use to try keep functions warm.

One method of keeping your Lambda function warn is using a CloudWatch event to invoke your function on a schedule. This acts as a keep alive which should keep your function warm in theory.

The AWS Lambda pricing is based on number of invocations and the execution time x memory level (GB-seconds). Trying to keep your function warm would cost a small amount due to the extra invocations and GB-seconds. But in reality, this cost would be miniscule.

Be aware that AWS reserves the right to kill your containers at any time. You will not be able to completely avoid cold starts. But, they are likely less of a problem than you think. This post on linkedin and this article by iopipe are worth reading.

I hope that helps. Let me know if you have any other questions.

Show your support

Clapping shows how much you appreciated John McKim’s story.