Introduction To AWS LAMBDA

12 / Mar / 2015 by Ankit Giri 1 comments

The next buzz in cloud computing is the event-driven computing service. The service in preview mode “AWS Lambda” brings the same to existence. Lambda makes the best of the concept of “pay-per-use” and “as a service” much further than it did in the case of EC2. It offers pay-per-millisecond computing, a service always available without delays, scalable power, no systems maintenance costs, response to events both from the rest of AWS services (such as a Kinesis stream or changes in DynamoDB) and events generated by your applications i.e. custom events (through API, the different SDK for programming languages or SDK for mobiles) .

If we talk specifically, we can use AWS Lambda (currently) to respond to table updates in Amazon DynamoDB, modifications to objects in Amazon S3 buckets, messages arriving in an Amazon Kinesis stream, AWS API call logs created by AWS CloudTrail, and custom events from mobile applications, web applications, or other web services.

Examples of using AWS Lambda

 1) Suppose, if we upload a photo (from a mobile device) to S3 bucket, it will trigger a Lambda-function that we have written. The function will extract meta-data from that photo and put it on DynamoDB and then it will trigger a function over all the streams of DynamoDB to figure out which of the meta-data function, for example place, location or user are trending. This can be further enhanced, by adding a function that notifies the customer if his/her photo is one of the trending-photos.


All of this can be done, without running any infrastructure or starting instances. So, it becomes really easy to build highly-reliable and concurrent application using Lambda.

2) Suppose, we have an use case where we have to create a function to automate the creation of thumbnails. When a user uploads a photo to a bucket, a thumbnail of the same photo is automatically created and stored in the same bucket. Now, when the user opens his account, only the thumbnails are loaded to show a preview rather than the actual photo (using a Lambda function on a web-app).


To describe Lambda in more generic terms, the beauty of it is that you get to focus on your business logic instead of passing around data. You define a directed acyclic graph of small, composable functions and the rest happens on its own. This is the promise of Event-Driven Computing and Lambda.

“Focus on business logic not infrastructure”

 Upload your code, Amazon Lambda handles:

• Capacity

• Scaling

• Fault tolerance

• Monitoring

• Logging

 Advantages of using AWS Lambda:


  • Each object uploaded to Amazon S3 is an event
  • Each event is a Lambda request
  • Lambda scales to match the event rate
  • Don’t worry about over or under-provisioning
  • Pay only for what you use


  • Price compute time by 100 ms  (so even short jobs make sense)
  • Low request charge
  • No hourly, daily, or monthly minimums 

 Is Lambda a game changer?

Lambda isn’t a particularly a new concept i.e. Databases have had triggers but doing this at the cloud level is game changing. Building multi-service, event-based triggers on our own would have been a massive task at hand – we’d have to assemble SQS, Kinesis, DynamoDB, and EC2 clusters just to do it properly. But now we get it as part of AWS (& as an service) . It enables us to run custom code in the cloud with zero administration and automatic scaling. Lambda runs our custom code on a high-availability compute infrastructure and administers all of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, code, and security patches.

What kind of code it supports?


Lambda is event-driven computing that supports code written in Node.js (JavaScript). Your code can include existing Node.js libraries, even native ones.

 How secure is Lambda?

Lambda isolates our code – Each AWS Lambda function runs in its own isolated environment, with its own resources and file system view. AWS Lambda uses the same techniques as Amazon EC2 to provide security and separation at the infrastructure and execution levels.

This is what AWS announced during the launch of AWS Lambda.

With Lambda, you simply create a Lambda function, give it permission to access specific AWS resources, and then connect the function to your AWS resources. Lambda will automatically run code in response to modifications to objects uploaded to Amazon Simple Storage Service (S3) buckets, messages arriving in Amazon Kinesis streams, or table updates in Amazon DynamoDB.”

Adding more to the cost-effectiveness of the service

From now on, it will be possible to calculate in the cloud asynchronously without having to provision infrastructure or adjust auto scale rules, and pay exclusively for the exact work required, all thanks to AWS Lambda.”

Use case

Initially, AWS changed the way computing used to be i.e. complete set of infrastructure to be managed programmatically just as operating Systems did provide abstraction over the hardware layer. Now, with AWS Lambda, this process of abstraction is further extended.

Abstraction Layer

Lambda can replace inefficient procedural systems and create a complete event-driven service for use that can be controlled by rules.

Application Management

Netflix is world’s leading Internet Television network with over 57 million members in nearly 50 countries (Source: and the content can be seen on any internet-connected screen.

So, let’s see the following use cases:

1) Encoding Media Files

Encoding media files

The studios pushe media files to S3, which is with Netflix. The media is chopped into chunks of 5 minute each & each chunk is encoded. The chunks are now re-packaged and deployed by Netflix & made available to the end-user.

The whole process and its monitoring and validation is done through Lambda’s Rules and Events. The Events are fired to track, aggregate, validate, tag and finally publish.

2) Backup for Disaster Recovery

In the production environment, hundreds of processes save or update database continuously (imagine the amount of data and relative updates!). With Lambda, we can decide the data rules & events that can trigger on the data update. Besides this, we can use it to trigger what needs to be backed up & copied to off-site storage & check and validate that it arrived safely. It can further re-make the copies, re-check & re-validate data. It can also raise alarms in case of failure.

Backup for DR

 3) Monitoring

Lambda includes monitoring features on its own Dashboard i.e. there is no need to configure alerts against each service, unlike our current practice.Monitoring enables us to validate the current state of our configuration and in case of failure, proper follow-up can take place accordingly.


* It generates logs in CloudWatch and they can be seen from the console.

For implementation and Demo, visit:


comments (1 “Introduction To AWS LAMBDA”)

  1. Pingback: AWS Lambda walk-through | TO THE NEW Blog

Leave a comment -