AWS Lambda

You are here:
< All Topics

Serverless Services in AWS include:


API Gateway
Kinesis Data Firehose
Aurora Serverless
Step Functions


exam tests heavily on serverless knowledge!


AWS Lambda




virtual functions – server to manage
limited by time – short execution processes
runs on demand only, only billed when you are actually using it
the scaling is automated


the benefits of Lambda:


easy pricing – pay per request and compute time


free tier covers 1 million lalbda requests and 400k of GB compute time


integrated with all AWS services and programming languages
easy monitoring via CloudWatch
easy to allocate more resources per functions –
up to 10GB of RAM! possible


also, increasing RAM improves CPU and network


language support:


node.js – javascript
java 8
c .net core
c powershell
custom runtime api eg rust


lambda container image — this must implement the lambda runtime api


ecs and fargate are preferred for running arbitrary docker images



lambda integrates with


api gateway


cloudwatch events and eventbridge


cloudwatch logs
sns and sqs
cognito – reacts when a user logs in eg to a database


lambda use case:


thumbnail image creation


new image uploaded to s3 then triggers a lambda function to generate a thumbnail of the image
this is pushed to s3 and meta data to dynamo db.


another example:


a serverless CRON job to run jobs


but for cron you usually need to have a server running, but with lambda you can do this without a server!


eg cloudwatch events or eventbridge every hour triggers a lambda function, this is instead of the cronjob!


pricing for lambda:


pay per calls first 1mill requests are free


then 20c per 1 mill requests


pay per duration in increments of 1 ms


400k GBseconds of compute time per month is free, charges thereafter on rising scale


very cheap to run lambda so it is very popular



you can run jobs using many different program languages


you enter your code in lambda web console and lambda then runs the code for you.


you can have lambda respond to events from various sources – eg data processing, streaming analytics, mobile or iot backends


lambda takes care of scaling for your load, you don’t have to do anything here!
ie seamless scaling



to create a lambda function you have 4 possibilities:


author from scratch
use a blueprint – these are pre configured functions
container image
browse serverless app repository



Lambda Limits per region
important for exam…




mem allocation 128 mb to 10 gb in 1mb increments


max exec time is 900 secs


env variables 4kb


disk capacity in the function container in /tmp is 512 mb


concurrency executions 1000 – can be increased




function deployment size compressed .zip is 50mb


size of uncrompressed deployment code plus dependencies is 250mb


can use the /tmp to load other files at startup


size of env variables is 4kb


the exam may ask you question to see if you think lambda can be used or not acc to the requirement for the task… you need to know these above limits in order to judge suitability of lambda for the task.





if you are deploying a CloudFront cdn and you want to deploy lambda globally


how to implement request filtering


you can use lambda@edge for this


you deploy it alongside each region in your cloudfront cdn


you can use lambda to modify the viewer/origin requests and responses of cloudfront:


this can be:


after cloud front receives a request – viewer request
before cloud front forwards the request to the origin – origin request


after cloudfront receives the response from the origin – origin response
before cloudfront forwards the response to the viewer – viewer response


you can also generate responses to viewers without having to send a request to the origin!


important to know this high level overview for exam.


use cases:


website security/privacy


dynamic web application at the Edge


intelligent routing across origins and data

bot mitigation at the Edge


real-time image transformation
a/b testing
user authentication and authorization


user prioritization
user tracking and analytics


Table of Contents