How to Use Feast with AWS Lambda for Serverless Feature Serving
Deploy a fully serverless feature store by configuring Feast's AWS Lambda feature server to expose online features via HTTP without managing EC2 instances or containers.
Feast (the feast-dev/feast repository) supports AWS Lambda serverless feature serving through its built-in feature server configuration. This deployment model automatically scales with request volume and eliminates persistent compute costs. The implementation uses the Lambda compute engine to handle both batch materialization and online serving, configured through feature_store.yaml and deployed via the standard feast apply workflow.
Architecture of the AWS Lambda Feature Server
The serverless architecture consists of four integrated components that work together to serve features at low latency.
- Feature Store Definition – Feature views and entities defined in Python files.
- Feature Server Configuration – The
feature_serversection infeature_store.yamlenables the Lambda HTTP server. - AWS Resources – An IAM execution role (
execution_role_name) granting the Lambda function permissions to read the registry, query the online store (DynamoDB or Redshift), and write CloudWatch logs. - Deployment Phase –
feast applycreates the Lambda function using the Docker image defined for the materialization engine and registers the endpoint in the Feast registry.
During the serving phase, clients call the endpoint returned by feast endpoint with a JSON payload containing entity keys. The Lambda function reads from the online store and returns feature values.
Key Implementation Files
| Component | Source File | Purpose |
|---|---|---|
| Lambda Compute Engine | sdk/python/feast/infra/compute_engines/aws_lambda/lambda_engine.py |
Creates the Lambda function via LambdaComputeEngine.update() and handles invocation retries through invoke_with_retries. |
| Engine Registration | sdk/python/feast/repo_config.py |
Registers "lambda" as a valid compute-engine type. |
| Feature Server Resolver | sdk/python/feast/repo_config.py |
Resolves the configuration class AwsLambdaFeatureServerConfig and validates the server configuration. |
| CLI Commands | sdk/python/feast/cli/cli.py |
Implements feast apply for deployment and feast endpoint for retrieving the serving URL. |
Prerequisites and Configuration
Required AWS Resources
Before deploying, ensure you have:
- Feast version ≥ 0.14 (Lambda feature server is experimental).
- AWS credentials configured in
~/.aws/credentialsor via environment variables. - Docker image for materialization containing the batch materialization logic.
- IAM execution role with permissions to access the online store (DynamoDB/Redshift), S3 registry, and CloudWatch Logs.
- Feature flags enabled:
alpha_features: trueandaws_lambda_feature_server: true.
feature_store.yaml Configuration
Configure the feature server in your feature_store.yaml (or feast.yaml):
project: dev
registry: s3://feast/registries/dev
provider: aws
online_store:
region: us-west-2
offline_store:
cluster_id: feast
region: us-west-2
user: admin
database: feast
s3_staging_location: s3://feast/redshift/tests/staging_location
iam_role: arn:aws:iam::{aws_account}:role/redshift_s3_access_role
flags:
alpha_features: true
aws_lambda_feature_server: true
feature_server:
enabled: true
execution_role_name: arn:aws:iam::{aws_account}:role/lambda_execution_role
The feature_server block enables the AWS Lambda deployment, while execution_role_name specifies the IAM role ARN that grants the Lambda function necessary permissions.
Deploying the Lambda Feature Server
Deploy the serverless infrastructure using the Feast CLI:
# Install Feast
pip install feast
# Deploy the configuration and create the Lambda function
feast apply
During execution, feast apply triggers LambdaComputeEngine.update() in sdk/python/feast/infra/compute_engines/aws_lambda/lambda_engine.py, which creates the Lambda function using the specified Docker image and IAM role. The CLI output includes:
Creating lambda function feast-materialize-dev, 1234abcd-...
Waiting for function feast-materialize-dev to be active
Retrieve the serving endpoint after deployment:
feast endpoint
Example output:
https://xxxxxx.execute-api.us-west-2.amazonaws.com/prod/
This URL is registered in the Feast registry and remains stable for client requests.
Querying Features from the Server
Send HTTP POST requests to the Lambda endpoint to retrieve online features. The request format matches Feast's standard feature server API:
import requests
import json
endpoint = "https://xxxxxx.execute-api.us-west-2.amazonaws.com/prod/"
payload = {
"entity_rows": [
{"driver_id": 1001},
{"driver_id": 1002},
],
"features": [
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate"
]
}
response = requests.post(endpoint, json=payload)
print(response.json())
The Lambda function processes the request by reading from the configured online store (DynamoDB or Redshift) and returns the feature values in JSON format. This client code works identically against local feature servers, enabling seamless migration from development to serverless production environments.
Summary
- Feast AWS Lambda serverless feature serving eliminates infrastructure management by deploying features to an auto-scaling HTTP endpoint.
- Configuration requires enabling
alpha_featuresandaws_lambda_feature_serverflags infeature_store.yaml, plus specifying an IAMexecution_role_name. - The
feast applycommand deploys the Lambda function viaLambdaComputeEngine.update(), whilefeast endpointretrieves the serving URL. - Clients query features via standard HTTP POST requests to the Lambda endpoint, with the same JSON schema used by local feature servers.
Frequently Asked Questions
What IAM permissions does the Lambda execution role require?
The IAM role specified in execution_role_name requires permissions to read the Feast registry from S3, query the online store (DynamoDB or Redshift), and write CloudWatch Logs for monitoring. Specifically, it needs dynamodb:GetItem or redshift:GetClusterCredentials depending on your online store, plus s3:GetObject for the registry and logs:CreateLogGroup for logging.
How does the Lambda feature server handle high traffic volumes?
The Lambda feature server leverages AWS Lambda's native auto-scaling capabilities. As implemented in sdk/python/feast/infra/compute_engines/aws_lambda/lambda_engine.py, the invoke_with_retries method handles throttling by implementing exponential backoff. However, for sustained high-throughput workloads, consider using provisioned concurrency or migrating to the Kubernetes feature server to avoid Lambda cold start latency.
Can I use the Lambda feature server with offline stores other than Redshift?
Yes, the Lambda feature server primarily serves online features from the configured online store (typically DynamoDB when using AWS provider). The offline store configuration (Redshift, Snowflake, BigQuery, etc.) determines where batch data is materialized from, but the Lambda server itself reads from the online store specified in your feature_store.yaml. Ensure your online store is configured appropriately for your latency requirements.
What is the difference between the Lambda compute engine and the Lambda feature server?
The Lambda compute engine (sdk/python/feast/infra/compute_engines/aws_lambda/lambda_engine.py) handles batch materialization—ingesting data from offline stores and writing to online stores via Lambda functions. The Lambda feature server is a configuration option that deploys an HTTP API on Lambda to serve online features to clients. While both use AWS Lambda, they serve different purposes in the Feast architecture: materialization versus online serving.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →