What is AWS Lambda?
AWS Lambda is a serverless computing service, that can be used to run codes in place of EC2 instances. The benefit of using Lambda in place of an EC2 instance is that Lambda is a managed service which means AWS takes care of a lot of the maintenance of computing resources like system maintenance, capacity provisioning, monitoring, auto-scaling, server and OS maintenance. By default, you can monitor the codes(Functions) in your lambda through AWS Cloudwatch.</br>
What is a Lambda Function?
When working with Lambda you configure and define the kind of code you want your Lambda to execute and that code is called a Lambda Function. Lambda Functions are stateless and are ready to run as soon as they are initiated. Lambda can quickly make copies of your Functions to handle requests as it scales.
Lambda is a very important service to utilize when working with an Event-Driven Architecture. You can set up event sources or other services that generate events so they can trigger your Lambda Function based on particular changes or events. Services that integrate well with Lambda are Amazon DynamoDB stream, Amazon Kinesis, Amazon SQS, Amazon SNS and Amazon S3. A typical example will be, to trigger a Lambda Function when an S3 file is altered or removed.
Key Benefits and Features of Using Lambda:
- Fully Managed Compute Service: You only worry about your functions and code AWS takes care of OS upgrades, patching and maintaining the underlying servers.</br>
- Built-in High-Availability and Fault Tolerance: AWS takes care of making sure that your server is by replicating those servers across different AZs so they are always available to handle the traffic.
- Fast Scaling: Lambda automatically scales as your traffic grows and it scales faster than regular auto-scaling of EC2 instances.
- Monitoring by Default: You can monitor your code(Functions) through CloudWatch which is connected to your Lambda service by Default.
- Pay only for used resources: Instead of over-provisioning or letting your EC2 instances keep running when it’s idle, you can use Lambda so that you only pay for the time your Lambda runs and it shuts down after handling your request.