The Python Feature Server is a FastAPI-based HTTP/gRPC service that exposes Feast's feature retrieval capabilities over network protocols. It provides REST and WebSocket endpoints for online feature serving, materialization, and feature pushing, wrapping the core FeatureStore functionality for remote access.
For information about other feature server implementations, see Java and Go Feature Servers. For serving on-demand transformed features, see Transformation Server. For MCP (Model Context Protocol) integration, the feature server can be configured with MCP-specific endpoints when the feature server type is set to mcp.
The Python Feature Server acts as a thin service layer over the FeatureStore class, enabling network-based access to feature data without requiring clients to directly instantiate a FeatureStore or manage registry state.
Sources: sdk/python/feast/feature_server.py158-226 sdk/python/feast/feature_store.py100-114
The server lifecycle uses FastAPI's lifespan context manager to initialize the FeatureStore and start asynchronous registry refreshing on startup, then cleanly shutdown on termination.
The get_app() function creates and configures the FastAPI application instance with all necessary endpoints and middleware.
Sources: sdk/python/feast/feature_server.py158-226
Key responsibilities:
threading.TimerFeastError exceptions to appropriate HTTP status codesThe server defines Pydantic models for all request payloads:
| Model | Purpose | Key Fields |
|---|---|---|
GetOnlineFeaturesRequest | Retrieve features for entities | entities, features, feature_service, full_feature_names |
GetOnlineDocumentsRequest | Vector search/document retrieval | query, query_string, top_k, api_version |
PushFeaturesRequest | Push streaming features | push_source_name, df, to (online/offline/both) |
MaterializeRequest | Trigger materialization | start_ts, end_ts, feature_views, disable_event_timestamp |
MaterializeIncrementalRequest | Incremental materialization | end_ts, feature_views |
WriteToFeatureStoreRequest | Direct online store write | feature_view_name, df, transform_on_write |
ChatMessage | Chat message for AI interactions | role, content |
ChatRequest | Chat request with message history | messages |
ReadDocumentRequest | Read document from file system | file_path |
SaveDocumentRequest | Save document to file system | file_path, data |
Sources: sdk/python/feast/feature_server.py61-123
Health check endpoint that returns 200 OK when the registry is loaded, 503 Service Unavailable otherwise.
Sources: sdk/python/feast/feature_server.py386-392
Retrieves online features for the provided entity keys. This is the primary endpoint for real-time inference.
Request Flow:
Sources: sdk/python/feast/feature_server.py228-257
Async Support: If store._get_provider().async_supported.online.read is True, the endpoint uses get_online_features_async() for better concurrency. Otherwise, it runs synchronously in a thread pool via run_in_threadpool().
Alpha endpoint for vector similarity search and document retrieval. Supports both vector embeddings (query) and keyword search (query_string with api_version=2).
Sources: sdk/python/feast/feature_server.py258-291
The v2 API supports keyword search via the query_string parameter for BM25-style text retrieval.
Ingests streaming feature data into the online and/or offline stores. The to parameter determines the destination.
Push Modes:
| Value | Constant | Description |
|---|---|---|
"online" | PushMode.ONLINE | Write to online store only |
"offline" | PushMode.OFFLINE | Write to offline store only |
"online_and_offline" | PushMode.ONLINE_AND_OFFLINE | Write to both stores |
Sources: sdk/python/feast/feature_server.py293-344 sdk/python/feast/data_source.py
Async Optimization: If the provider supports async writes and the target includes the online store, the endpoint uses store.push_async() for improved throughput.
Deprecated endpoint for writing directly to the online store for a specific feature view. Prefer using /push with to="online" instead.
Sources: sdk/python/feast/feature_server.py371-384
Triggers a materialization job to load features from the offline store into the online store for a specified time range.
Parameters:
start_ts, end_ts: Time range for materialization (required unless disable_event_timestamp=True)feature_views: Optional list of feature view names to materialize (defaults to all)disable_event_timestamp: If True, materializes all data using current timestampSources: sdk/python/feast/feature_server.py445-476
Materializes features from the last materialization timestamp up to the specified end_ts. This is the recommended approach for scheduled materialization jobs.
Sources: sdk/python/feast/feature_server.py478-491
Processes chat requests for AI-powered interactions. This endpoint accepts a list of chat messages and returns responses. Currently returns placeholder responses, but can be extended for integration with language models.
Request Flow:
Sources: sdk/python/feast/feature_server.py394-398
Reads document content from the file system. This endpoint allows clients to retrieve document data stored locally, useful for document-based feature engineering workflows.
Sources: sdk/python/feast/feature_server.py400-413
Saves document content to the file system. This endpoint enables clients to persist document data for later retrieval or processing.
Sources: sdk/python/feast/feature_server.py415-428
WebSocket endpoint for real-time chat interactions. Maintains a persistent connection for bidirectional communication, enabling streaming responses and interactive AI conversations.
WebSocket Flow:
Sources: sdk/python/feast/feature_server.py509-568
The feature server requires a feature_store.yaml configuration file. The server can be configured in two ways:
Option 1: Repository Path
Option 2: Base64-Encoded Config (Environment Variable)
The server supports receiving the configuration as a base64-encoded string via the FEAST_FEATURE_STORE_YAML_BASE64 environment variable. This is useful for containerized deployments.
Sources: sdk/python/feast/repo_operations.py382-396 sdk/python/feast/constants.py
The registry_ttl_sec parameter controls how frequently the feature server refreshes its cached registry state:
registry_ttl_sec seconds via a background timerstore.refresh_registry() for manual refresh)DEFAULT_FEATURE_SERVER_REGISTRY_TTL constantSources: sdk/python/feast/feature_server.py158-217 sdk/python/feast/constants.py34
The feature_store.yaml can specify a feature server configuration:
The server type is resolved via FEATURE_SERVER_CONFIG_CLASS_FOR_TYPE mapping, which currently supports:
local: Standard local feature server (LocalFeatureServerConfig)mcp: MCP (Model Context Protocol) feature server (McpFeatureServerConfig)When MCP is enabled, additional MCP-specific endpoints are automatically registered to the FastAPI application, enabling integration with AI agent frameworks that support the Model Context Protocol.
Sources: sdk/python/feast/repo_config.py108-111 sdk/python/feast/repo_config.py229-288 sdk/python/feast/feature_server.py190-192
The feature server integrates with Feast's permissions system for fine-grained access control.
Sources: sdk/python/feast/feature_server.py228-230 sdk/python/feast/permissions/action.py sdk/python/feast/permissions/security_manager.py
The server checks permissions for different operations:
| Endpoint | Actions Checked |
|---|---|
/get-online-features | AuthzedAction.READ_ONLINE |
/retrieve-online-documents | AuthzedAction.READ_ONLINE |
/push (online) | AuthzedAction.WRITE_ONLINE |
/push (offline) | AuthzedAction.WRITE_OFFLINE |
/push (both) | WRITE (both online and offline) |
/materialize | AuthzedAction.WRITE_ONLINE |
/write-to-online-store | AuthzedAction.WRITE_ONLINE |
Sources: sdk/python/feast/feature_server.py134-155 sdk/python/feast/feature_server.py296-327 sdk/python/feast/permissions/action.py
Sources: docs/reference/feature-servers/python-feature-server.md8-11
Containerized Deployment:
The feature server can be deployed as a Docker container. The official Feast Docker images include the feature server.
Sources: docs/roadmap.md62
Kubernetes Deployment:
The Feast Operator can deploy feature servers on Kubernetes via the FeatureStore custom resource. The operator manages the lifecycle of feature server deployments, including scaling, updates, and service exposure.
Sources: infra/feast-operator/README.md1-3
The feature server exposes Prometheus metrics for monitoring:
feast_feature_server_cpu_usage: CPU usage gaugefeast_feature_server_memory_usage: Memory usage gaugeMetrics are collected via psutil and can be scraped by starting a Prometheus HTTP server on a separate port using the prometheus_client library.
Sources: sdk/python/feast/feature_server.py52-57
The feature server can serve static files for web UI components. When configured, it mounts a static files directory at the /ui path, enabling browser-based feature store exploration.
Sources: sdk/python/feast/feature_server.py573-589
The feature server automatically uses async operations when the underlying provider supports them:
Online Read Async Support:
Online Write Async Support:
Sources: sdk/python/feast/feature_server.py242-247 sdk/python/feast/feature_server.py337-344
The feature server maintains a local cache of the registry to minimize latency:
Sources: sdk/python/feast/feature_server.py195-217
Cache Modes:
The registry itself supports two cache modes (configured in registry section of feature_store.yaml):
sync: Immediate refresh after each write operationthread: Asynchronous background refresh at TTL intervalsSources: sdk/python/feast/repo_config.py155-160
For providers without async support, the server uses FastAPI's run_in_threadpool() to prevent blocking the event loop. This allows the server to handle concurrent requests efficiently even with synchronous providers.
Sources: sdk/python/feast/feature_server.py245-247 sdk/python/feast/feature_server.py378-384
The feature server includes a global exception handler that converts Feast-specific exceptions to appropriate HTTP responses:
FeastError subclasses define their own HTTP status codes:
FeastObjectNotFoundException → 404FeastError → 500Sources: sdk/python/feast/feature_server.py493-507 sdk/python/feast/errors.py17-69
The feature server delegates all feature operations to the configured Provider:
Sources: sdk/python/feast/infra/passthrough_provider.py58-61 sdk/python/feast/infra/provider.py533-548
The server accesses online stores through the provider abstraction. Supported online stores include:
The online store configuration is specified in feature_store.yaml under the online_store section, and the server transparently delegates to the configured store implementation through the provider.
Sources: sdk/python/feast/repo_config.py68-88 sdk/python/feast/infra/online_stores/sqlite.py50-148 sdk/python/feast/infra/passthrough_provider.py69-75
The server reads feature metadata from the Registry to resolve feature references and perform schema validation. The registry can be backed by:
Sources: sdk/python/feast/feature_store.py155-176 sdk/python/feast/repo_config.py39-44
Refresh this wiki
This wiki was recently refreshed. Please wait 1 day to refresh again.