For those of us that are used to server-based architectures, a platform like Amazon Lambda might seem unintuitive or downright useless.
- What the heck can we use it for?
- Why would anyone go through the hassle of learning this platform, when they could easy accomplish it with a more traditional architecture?
Turns out that server-less architectures can reduce the complexity of the systems we need to personally maintain, monitor, and scale.
Here are 3 quick uses for Amazon Lambda
1. Image Processing Tasks
Asynchronous image processing is a common need for many sites. Uploaded images often need to be resized (often several times), and eventually stored to a cloud storage provider like S3.
This sort of medium- to long-running task is one of the reasons why we add asynchronous task processing to our architecture.
The question is, are we really getting so many requests that it justifies keeping a daemon like Celery running at all times, just to process the occasional image upload?
Lambda code can be triggered by an S3 upload event, process the image however we want, then go back to sleep – all without the hassle of a self-managed asynchronous architecture.
The lambda environment is built with several popular image processing libraries, including Pillow for python, GhostScript, and similar packages for Node.
2. Cron Tasks
Regular tasks like clearing old sessions, running backups, warming up caches, and sending out daily emails are common and simple.
Use Lambda with the wonderful Zappa framework to easily run a task at scheduled intervals without the hassle.
3. Refactoring Existing Functionality into a Microservice
Want to start transitioning to using microservices?
Lambda provides a solid platform for refactoring some of your application’s existing functionality into a limited-scope microservice with a well-defined, language-agnostic interface.
Build a small service using python, java, or node, and allow your app’s components to communicate between themselves using REST!