[comment]: # (mdslides presentation.md --include media) [comment]: # (The list of themes is at https://revealjs.com/themes/) [comment]: # (The list of code themes is at https://highlightjs.org/) [comment]: # (markdown: { smartypants: true })
DevOpsTheHardWay
These are the slides we use in class, you're welcome to explore them. Enjoy your learning journey!
# AWS Lambda  By Alon Itach
### Today's agenda - What is AWS Lambda? - Scaling Lambda - Lambda Invocations
### Serverless architectures Serverless architectures involve building applications **without provisioning or managing servers** explicitly. Instead, some other provider handles the infrastructure for you. Just give your code and run. Code is executed in response to events, automatically scaling up or down as needed. Deploy an app in a serverless environment is simple and dramatically reduces maintenance. - Developers focus on code, not infrastructure management. - No server updates, patches, or scaling management. Serverless environments are commonly used in [event-driven](https://serverlessland.com/content/service/lambda/guides/aws-lambda-operator-guide/event-driven-architectures) architectures and [scheduled jobs](https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-tutorial.html) processing. **Don’t fool yourself, we are not going to leave the old, good, beloved, EC2 instances.** Both serverless and EC2 architectures have their strengths and weaknesses, making the choice dependent on the specific requirements and priorities of your application.
### What is AWS Lambda? - [Lambda is a compute service](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) that lets you run code without provisioning or managing servers. - Performs all of the administration of the compute resources: scaling, monitoring, logging - Supported runtimes: Node.js, Python, Ruby, Java, Go, .NET - Pay only for the compute time that you consume - Invoke the Lambda functions using an API, or in response to events from other AWS services.
### Lambda concepts - **Deployment package** - Your source code. Lambda supports two types: - A .zip file archive that contains your function code and its dependencies. - A container image (e.g. Docker) - **Runtime** - provides a language-specific environment that runs in an execution environment. - **Scale concurrency** - the number of requests that your function is serving at any given time. - **Destination** - an AWS resource where Lambda can send events from an invocation. You can configure a destination for events that fail processing.
### Scaling The first time you invoke your function, Lambda creates an instance of the function and run it. 
### Scaling When the function returns a response, it stays active and waits to process additional events. 
### Scaling If you invoke the function again while the first event is being processed, Lambda initializes another instance, and the function processes the two events concurrently. 
### Scaling As more events come in, Lambda routes them to available instances and creates new instances as needed 
### Scaling When the number of requests decreases, Lambda stops unused instances to free up scaling capacity for other functions  The [default regional concurrency](https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html) quota starts at 1,000 instances.
### Scaling - Reserved concurrency You can configure a [Reserved concurrency](https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html) setting for your Lambda functions to allocate a maximum concurrency limit for a function. 
### Scaling - Provisioned Concurrency You can reduce invocation latency by configuring [Provisioned Concurrency](https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html) for a function version or alias. 
### Scaling - Burst limit 
### Lambda Invocation With [synchronous invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-sync.html), you wait for the function to process the event and return a response. 
### Lambda Invocation With [asynchronous invocation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html), Lambda queues the event for processing and returns a response immediately. For asynchronous invocations, Lambda handles retries if the function returns an error or is throttled. 
### Destinations - For asynchronous invocation, you can configure Lambda to send invocation records to a queue, topic, function, or event bus. - You can configure separate destinations for successful invocations and events that failed processing. - The invocation record contains details about the event, the function's response, and the reason that the record was sent. 
# Thanks