Lambda - seanremenyi/Notes_aws_developer GitHub Wiki
Serverless Compute Run your code in AWS without provisioning any servers Labda takes care of everything required to run your code, including the runtime environment Supported Languages Java, Go, PowerShell, Noda.js, C#, Python and Ruby Upload your code to lambda and you are good to go. Enterprise Features. Auto-scaling and high availability are already baked-in to the Lambda service
You are charged based on the number of requests, their duration and the amount of memory used by your lambda function
Requests first 1 million requests per month are free then $0.20 per month per 1 million requests Duration You are charged in millisecond increments The price depends on the amount of memory you allocate to your lambda function Price per GB-second $0.00001667 per GB-second a function that uses 512 MB and runs for 100ms 0.5Gbx 0.1 s = 0.05 GB-s, we would be charged $0.0000000083 first 400,000GBs per month are free Event driven architecture
Event driven Lambda functions can be automatically triggered by other AWS services or called directly from any web or mobile app Triggered by events These events could be changes made to data in an s3 bucket, or Dynamodb table Triggered by User Requests. You can use API Gateway to configure an HTTP endpoint allowing you to trigger your function at any time using an HTTP request AWS services that can invoke Lambda functions. dynamoDB, Kinesis, SQS, Application Load Balancer, Api gateway, Alexa, Cloudfront, S3, SNS, SES, Cloudformation, CloudWatch, CodeComomit, CodePipeline
Extremely cost effective Pay only when your code executes Continuous Scaling Lambda scales automatically Event Driven Lambda functions are triggered by an event or action Independent Lambda functions are independent. Each event will trigger a single function it is Serverless technology know triggers
Lambda versions When you create a Lambda function, there is only one version: $LATEST When you upload a new version of the code to Lambda, this version will become $LATEST You can create multiple versions of your function code and use aliases to reference the version you want to use as part of the ARN e.g. In a development environment you might want to maintain a few versions of the same function as you develop and test your code And alias is like a pointer to a specific version of the function code
if your application uses an alias, remember to update the ARN that you are using if you want to use the new code
Use Lambda versioning and aliases to point your applications to a specific version if you don't wnat to use $LATEST If your application uses an alias, instead of $LATEST remember tht it will not automatically use new code when you upload it
Concurrent Executions There is a concurrent execution limit for lambda Safety feature to limit th number of concurrent executions across all functions in a given region per account default 1000/s per region TooManyRequestsException HTTP status code: 429 Request throughput limit exceeded you can request for a higher limit reserved concurrency guarantees a set number of concurrent executions are always available to a critical function
If you have many Lambda functions running in the same region and you suddenly start seeing new invocation requests being rejected, then you many have hit you limit At ACG, daily usage is around 6.5m Lambda invocaion per day in us-east-1 Request increase on this limit by submitting a request to the AWS Support Center Reserved concurrency guarantees that a set number of executions which will always be available for your critical function, however also acts as a limit
Know tht the limit exists, 1000 concurrent executions per second If you are running a serverless website like ACG, it's likely you will hit the limit at some point If you hit the limit you will start to see invocations being rejected - 429 HTTP status code The remedy is to get the limit raised by AWS support Reserved Concurrency guarantees a set number of concurrent exectutions are always available to a critical function
Lambda accessing your VPC resources by default your lambda will not be able to acess resources in a private VPC To enable this, you need to allow the function to connect to the private subnet Lambda needs the following VPC Configuration information so that it can connect to the VPC: Private subnet ID Security group ID (with required access) Lambda uses this information to set up ENIs using an availablet IP address from your private subnet
You add VPC information to your lambda function config using the vpc-config parameter aws lambda update-function-configuration --function-name my-function --vpc-config SubnetIds=subnet-1122aabb,SecurityGroupIds=sg-51530134