Serverless - Lambda functions
Lambda
- All operational activities of applying patch, capacity provisioning, monitoring fleet health, code deployment etc is taken care by Lamda.
- Best suited for use cases which are event based, such as changes to S3 buckets, serverless processing of streaming data, updates to Dynamo DB table or custom event generated by apps/devices.
- All code uploaded to Lambda is encrypted.
- Each Lambda has built-in ephemeral storage of 512 MB.
- In-bound network connections are blocked by Lambda.
- Total Metrics, Account and Function level concurrency usage, latency and throttled requests are metrics shared by Lambda through Cloud Watch.
- Each Lambda function has a log group which can be traced in Cloudwatch logs.
- We can define the memory to be set for the function.
- Lambda function max execution time is 15 mins.
- Lambda can do polling of resources that do not publish events. Or it can be triggered basis events.
- S3 Integration - The S3 Bucket notifications can be sent to Lambda functions. Lambda can be used to Thumbnail images, transcode videos, index files, aggregate/filter data in real time.
- Dynamo DB Integration - The Dynamo DB stream can be associated with the Lambda function.
- Kinesis Integration - Lambda function can be linked with Kinesis streams.
- Lambda can be associated with SNS notifications by linking it to the SNS topic Likewise we can let Lambda be triggered based on SQS messages.
- Serverless Application Model is a specification for building serverless applications in AWS and it is referred in Cloudformation using resource type - 'serverless resources'.
- To invoke Lambda in a workflow we can use Step Functions. AWS Step Functions is an orchestration service that lets you connect your Lambda functions into serverless workflows, called state machines.
- AWS X-Ray can be enabled to trace lambda functions.
- Lambda can connect to relational databases using RDS Proxy.
- Using Cloudwatch events, we can trigger lambda function on schedule basis.
- Lambda can also be connected to EFS through EFS Access Point. Each function will have its own EFS file system. This would be best suited for use cases where some large amount of data needs to be accessed/processed.
- Lambda extensions are companion functions which runs along with the function, it gets triggered before the function and can after the function completion also. The extension can be used for triggering 3rd party tools to handle monitoring, observability, security and governance. They share the same execution space and hence could slow down the function execution if we have any code to be executed prior to the function execution.
- When a request lands at the origin from the Cloudfront, right before responding back to the user, if we want to perform any logic, it can be acheived using Lambda@edge functions. The execution happens at the edge location and basically any decisions on how the content should be served back based on the location, device, etc.
- Lambda has max concurrent executions per region per account and we can control function level max concurrent executions. When this throttle limit is exceeded it throws 429 error.
- When synchronously invoked calls fail, Lambda returns exception. For asynchronous it tries 3 times.
- Lambda functions are at VPC level. They can be connected to other VPC by peering. They can be provided internet connectivity by using NAT instance.
- When a function is invoked again while one is being processed, it creates a concurrent execution.
- The concurrency space available is common for all the functions in the region. By reserving concurrency for a function we ensure no other function can use that concurrency space. However this limits the ability to use the concurrency from open pool.
- Provisioned concurrency initializes number of execution environments and best suited for low latency use cases.
- We can use Application auto scaling to control the provisioned concurrency. This creates 2 cloudwatch alarms - the first triggers when there is a need to increase the provisioned concurrency. While the second checks to reduce the limits when usage is less. Scaling can be done on scheduled basis as well.
- Lambda layers are archive which contains libraries, dependencies, etc which can be included to a function. Layer is private by default however they can be made public or accessible to another account.
- Lambda function can be run daily with AWS Trusted Advisor to track service limits utilizations. It can be used with Service quotas every 5 minutes to track EC2 vCPU utilization. This data can be fed to Cloudwatch events which can push it to SNS for notifications.
- Lambda
- Memory is the amount of memory available to your Lambda function at runtime. You can increase or decrease the memory and CPU power allocated to your function using the Memory (MB) setting. To configure the memory for your function, set a value between 128 MB and 10,240 MB in 1-MB increments. At 1,769 MB, a function has the equivalent of one vCPU (one vCPU-second of credits per second).
- A Lambda alias is like a pointer to a specific function version. Users can access the function version using the alias Amazon Resource Name (ARN). By updating additional version weights on an alias, invocation traffic is routed to the new function versions based on the weight specified.
- You can now shift incoming traffic between two AWS Lambda function versions based on pre-assigned weights. This allows you to gradually shift traffic between two versions.
Comments
Post a Comment