Lambda Flashcards
Lambda Execution Context, and where does it reside?
The execution context is a temporary runtime environment that initializes any external dependencies of your Lambda function code, such as database connections or HTTP endpoints. This affords subsequent invocations better performance because there is no need to “cold-start” or initialize those external dependencies. Each execution context provides 512 MB – 10,240 MB of additional disk space in the /tmp directory.
What does Lambda use to poll services like DDB?
Event Source Mapping – a Lambda “resource” that uses permissions in the function’s execution role to read and manage items in the event source
Three components of Lambda pricing
Memory, Amount of compute time spent in execution, Number of executions
Sequence of invocation: Execution Context, Function Code (Handler, Logic)
Lambda launches the execution context. Within that context, it loads the code (logic) and then executes the handler, passing in the event object and the context object
How does one know where the log data from a Lambda function resides?
The “context” object provided by the Lambda runtime contains two pieces of information you can use to construct the log location: “logGroupName” and “logStreamName”
Where does the Lambda Execution Environment reside? What is its relationship to / tmp?
We don’t know where, but in a read-only file system. The execution environment takes advantage of ephemeral storage at / tmp (512 MB for free, up to 10,240) but that is a write-capacity file location, and is not where the execution environment resides.
Can I invoke a Lambda function via a dedicated HTTP(S) endpoint?
Yes. By using Lambda Function URLs, you can directly invoke your Lambda function using a simple HTTPS request without needing to set up additional services like API Gateway.
Ex: https://<url-id>.lambda-url.<region>.on.aws</region></url-id>
Does a Lambda version ever change? Does $Latest change?
No. It is immutable. It even has an ARN assigned.
$Latest changes, and as a consequence, it has an UNQUALIFIED ARN assigned to it
What is a Lambda Alias? Why is it useful?
A pointer to a Lambda version. Useful so that you never have to change an application to run a different Lambda version. Just point the application to an Alias. Then you can update the Alias to point to a different version as needed.
What is Lambda Alias routing?
You can create a percentage distribution of requests to different versions behind the Alias. So, 90% to Lambda v1, 10% to Lambda v2
What do I have to do to monitor Lambda with X-Ray?
Enable “Active Tracing” on the Lambda function
Describe a use case for Lambda Layers
Multiple slightly different Lambda functions, all using the same bulky libraries (e.g., numpy)
No point in zipping up 10 huge files to run this. Zip the small function files, and add the libraries to the /opt folder, where they can be used as if they were in the actual zip
If you need a particular library module in your Lambda code, where might it come from?
It could be in the default runtime environment (i.e., Python 3.8). If not, you could (a) include the libraries in your code and upload it to Lambda (“in the deployment zip”), or (b) put in in Lambda libraries