Amazon Lambda functions

Amazon took AWS to the next level of granularity with the introduction of Lambda functions. They initially started with the IaaS (and still the leader), made it easier to create, deploy & manage your apps using Beanstalk.  Now with Lambda, they just said, it need not be any full-fledged app or website, it could be just functions. If you wrote a function and you want that executed / running for production or otherwise, you can create it as a lambda function and set it to run on AWS infrastructure. You don’t have to worry about any server / machine / VM – zip –nada. This is primarily an event-driven architecture (push & pull). The function can be triggered by any event happening in your aws infrastructure (an incoming email, a click stream, a notification, a file dropped in a specific s3 bucket, database trigger) or it can even be scheduled to run at a specific time or at regular intervals.  There are myriad possibilities / use cases. Let’s say you have a website that you hosted using Beanstalk and that you don’t have access to a server where you can have a cron job or a windows task scheduler, you can write a lambda function and have it run. AWS has enough samples that they call blueprints that you can start with.  These are pretty much templates and you can change and add your logic.

Currently, the lambda functions could be written in Python 2.7, node.js or Java.  Now, let us see couple of use cases.

Use Case1:

Let us say you have servers (EC2 instances) in AWS and some of them are for demo or staging. If it is staging, it might be that the users are accessing them only during office hours (9 to 5 or pick a time range). If it is demo, the sales person probably needs the demo system for the meeting, 12- 2 or 9 to 11:30. You can create a lambda function that starts your specific instances (instance id) and another function that stops your specific instance(s). Then you can have a scheduler using the cloudwatch to have the specific lambda function to be called at the specified time interval. You could get better and add more logic into one function that runs every hour, checks the uptime of the instance(s) and have them start or stop after so many hours. There are many ways to skin the cat and this is one way that I wrote it as a lambda function using AWS Boto3 library in Python. Like every other service, the pricing is low. The first 300,000 GB-seconds of running of lambda function is free. For complete pricing

Use Case2:

This one is close to my heart. I believe the cheapest way to host a webapp and I’m in the process of doing this. Create your html5 and Javascript application that is rendered & executed on the browser, create lambda functions and expose them as http endpoints. The lambda functions in turn will access any database that is needed. You can have your database as RDS. Now, you can call these lambda functions from the webpages through javascript. If you are a starting up and don’t have much to spend, you want to test your idea, here you go. This is the cheapest option to have a website up and running. Host the html/js files in S3 using static hosting. The lambda functions are used only when someone clicks on the link that access the database or executes a serverside logic and you pay only when it gets executed unlike having a server which you have to pay when it is up! Please drop me a line if you want to share or know more. Thanks!

For more visit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: