AWS Lambda Adds Availability Zone Metadata to Cut Cross-AZ Latency

Functions can now identify their Availability Zone and use that information to favor nearby cache, database and container resources.

AWS Lambda Adds Availability Zone Metadata to Cut Cross-AZ Latency panumas nikhomkhai

AWS Lambda now lets functions determine which Availability Zone (AZ) their execution environment is running in, giving developers a way to favor nearby resources and reduce cross-zone network traffic. The new metadata endpoint returns an AZ ID, such as use1-az1, through an HTTP request from the function’s execution environment.

The change addresses a gap in Lambda’s automatic placement across multiple AZs. That distribution supports resilience, but previously a function could not identify its own zone and might send a request to a cache or database in another one. AWS says cross-AZ requests add network latency and can incur data transfer costs.

For teams running latency-sensitive workloads, AZ awareness can help keep frequent reads on a shorter network path. AWS says the feature is available at no extra cost in all commercial AWS Regions where Lambda is available.

How developers can use the AZ ID

A function can use its AZ ID to select a same-zone endpoint for services that expose per-AZ resources. AWS describes an ElastiCache setup with nodes in three AZs: because Lambda placement and cache-node placement are independent, roughly two out of three invocations may otherwise reach a node in another zone. AWS says a same-AZ round trip typically takes single-digit milliseconds; cross-AZ delays can add up on heavily used paths.

The same routing approach can apply to Amazon RDS and Aurora read replicas, or to read replicas in Amazon MemoryDB. For MemoryDB, AWS cautions that reads requiring the latest write should go to the primary, because replicas can lag. Functions calling services on Amazon EKS or ECS can also pair their AZ ID with topology-aware routing to keep traffic within a zone.

Runtime support and availability

The endpoint works across Lambda runtimes, including custom runtimes and container images. AWS says it is compatible with SnapStart, provisioned concurrency and functions running in a virtual private cloud. Developers can retrieve the AZ ID with Powertools for AWS Lambda or call the endpoint directly.

The metadata does not itself route requests or guarantee that a same-AZ resource is available; developers use the AZ ID to implement their own endpoint selection and fallback behavior. AWS also presents AZ-specific fault-injection testing as another use for the metadata.

This report draws on information from Amazon Web Services.

Editorial checks passed Facts, figures and quotes checked against 1 source

Add Blogging News as a preferred source on Google

Related stories