Course contentsShow
← Cloud and Infrastructure
Lesson 469 of 2,9899. Serverless ComputeFree lesson

Function Timeouts and Limits

Learn about execution time limits, memory constraints, and payload size restrictions.

Function Timeouts and Limits

What you'll learn: How cloud providers constrain serverless functions through execution time, memory, and payload size restrictions.

Why Functions Need Guardrails

Since serverless functions run on shared infrastructure and you pay per use, cloud providers enforce strict limits to prevent runaway processes, ensure fair resource allocation, and protect both you and other customers from excessive costs or resource exhaustion.

Three Core Constraints

Execution Time Limits set the maximum duration a function can run before being forcibly terminated. AWS Lambda defaults to 3 seconds but allows up to 15 minutes, while Azure Functions supports up to 10 minutes (Consumption plan) or unlimited (Premium/Dedicated plans). Google Cloud Functions permits up to 9 minutes (1st gen) or 60 minutes (2nd gen). If your function exceeds its timeout, it stops mid-execution—no cleanup, no graceful exit.

Memory Constraints define how much RAM your function can allocate, typically ranging from 128 MB to several gigabytes. Higher memory also increases allocated CPU proportionally. Choosing too little memory causes out-of-memory errors; too much wastes money.

Payload Size Restrictions limit how much data you can pass into or return from a function. Request/response payloads typically max out at 6 MB (synchronous) or 256 KB (asynchronous events). For larger data, you must use external storage like object storage buckets and pass references instead.

Think of It Like a Restaurant

Imagine ordering from a restaurant with a strict 15-minute kitchen window, single-portion sizes, and a takeout bag that holds only three containers. You need to design your "order" (function) to work within these boundaries—break complex meals into multiple courses, store extras elsewhere, and finish cooking before time's up.

Key Takeaway: Serverless functions operate under strict execution time, memory, and payload constraints—design your functions to complete quickly, use memory efficiently, and handle large data through external storage references.