Choosing Storage and Packaging for Data Processing Functions
This lesson explains the Lambda storage and packaging options for functions that need large libraries, temporary space for files or shared persistent storage, and how to stay within size limits.
Learning outcomes
After completing this lesson, you will be able to:
- Choose between /tmp, Amazon EFS and Amazon S3 for storage.
- Choose between .zip packages, layers and container images.
- Apply good practices for data processing functions.
Storage options
A function can use three kinds of storage. The /tmp directory is local disk space of 512 MB to 10 GB in each execution environment. It is fast but temporary and not shared, so it suits downloading a file, processing it and uploading the result within one invocation. Amazon EFS is a persistent file system shared by every invocation and every function that mounts it, which suits large reference data or ML models; the function must be connected to a VPC to reach it. Amazon S3 is durable object storage read and written through the SDK, and is where a pipeline's input and output data normally live. The following table summarises the options.
| Storage | Characteristics | Use for |
|---|---|---|
/tmp | 512 MB to 10 GB per execution environment; temporary | Downloading and processing files within one invocation |
| Amazon EFS | Persistent, shared across invocations and functions; the function must be in a VPC | Large reference data or models shared by many functions |
| Amazon S3 | Durable object storage, accessed through the SDK | Input and output data |
The following diagram shows where each kind of storage sits relative to a function.

Which Lambda storage?
Packaging options
Data processing functions often need large libraries, and the packaging choice depends on their size. A .zip package can hold up to 250 MB unzipped, including its layers, which is enough for most functions. Layers package shared libraries separately, up to five per function, so many functions can use, for example, the AWS SDK for pandas without each bundling it. When dependencies exceed 250 MB, such as pandas with PyArrow or an ML model, a container image of up to 10 GB is the answer. The following table summarises the options.
| Option | Limit | Use for |
|---|---|---|
| .zip package | 250 MB unzipped, including layers | Most functions |
| Layers | Up to five per function, within the 250 MB limit | Sharing libraries such as the AWS SDK for pandas |
| Container image | Up to 10 GB | Large dependencies such as pandas, PyArrow or ML models |
The following diagram shows the chosen packaging for a Lambda function that converts Excel workbooks to Parquet, and the alternatives a team considered.

250MB
Unzipped .zip package, including layers
10GB
Maximum container image
Packaging a function
Good practice
Lambda functions in data pipelines follow the same good practices as any Lambda function, with a few that matter especially for data. SDK clients and database connections are created outside the handler, so that every invocation in the same execution environment reuses them instead of reconnecting. Functions are deployed with AWS SAM or the AWS CDK, so their configuration is versioned with the rest of the pipeline.
Functions attached to a VPC have no internet access, so they need VPC endpoints or a NAT gateway to reach AWS APIs such as Amazon S3 and AWS Glue. Finally, functions must be idempotent, because event sources deliver events at least once and a function may process the same event twice.
A function that reconnects every time
Packaging pandas and PyArrow
A function converts small uploaded Excel files to Parquet with pandas and PyArrow. The .zip deployment fails because the libraries exceed 250 MB unzipped. The options compare as follows.
| Option | Result |
|---|---|
| Layer with the AWS SDK for pandas | Fits within the limit for many uses; managed by AWS |
| Container image | Up to 10 GB; any libraries; built and pushed to ECR |
| Moving the work to Glue Python shell | Possible, but slower to start for small files |
The team uses the AWS-provided layer for the AWS SDK for pandas, which includes pandas and PyArrow. Each file is downloaded to /tmp, raised to 2 GB for the largest workbooks, converted, and written to S3.
Several functions need the same files, which must persist between invocations. What should they use?
Show answer
Amazon EFS, mounted by functions connected to the VPC.
Exam Tips
Remember for the exam
- For shared, persistent files across functions, mount EFS, with the function in a VPC.
- Large dependencies such as pandas or ML models belong in a container image of up to 10 GB.
- To share libraries between functions, use layers.
- Ephemeral /tmp storage can be raised to 10 GB.
- Create clients and connections outside the handler.