This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This remote online store will let you interact with remote feature server. At this moment this only supports the read operation. You can use this online store and able retrieve online features `store.get_online_features` from remote feature server.
This remote online store lets you interact with a remote feature server. You can use this online store to retrieve online features via `store.get_online_features()` from a remote feature server.
## Examples
Expand All
@@ -25,6 +25,128 @@ auth:
`cert` is an optional configuration to the public certificate path when the online server starts in TLS(SSL) mode. This may be needed if the online server is started with a self-signed certificate, typically this file ends with `*.crt`, `*.cer`, or `*.pem`.
## Connection Pooling Configuration
The remote online store uses HTTP connection pooling to improve performance by reusing TCP/TLS connections across multiple requests. This significantly reduces latency by avoiding the overhead of establishing new connections for each request.
### Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `connection_pool_size` | int | 50 | Maximum number of connections to keep in the pool. Increase for high-concurrency workloads. |
| `connection_idle_timeout` | int | 300 | Maximum time in seconds a session can be idle before being closed. Set to `0` to disable idle timeout. |
| `connection_retries` | int | 3 | Number of retries for failed requests with exponential backoff. |
### Example with Connection Pooling
{% code title="feature_store.yaml" %}
```yaml
project: my-local-project
registry: /remote/data/registry.db
provider: local
online_store:
type: remote
path: http://feast-feature-server:80
# Connection pooling configuration (optional)
connection_pool_size: 50 # Max connections in pool
connection_idle_timeout: 300 # Idle timeout in seconds (0 to disable)
connection_retries: 3 # Retry count with exponential backoff
entity_key_serialization_version: 3
auth:
type: no_auth
```
{% endcode %}
### Use Cases
**High-throughput workloads:**
```yaml
online_store:
type: remote
path: http://feast-server:80
connection_pool_size: 100 # More connections for high concurrency
- High-frequency feature retrieval in real-time inference pipelines
- Batch processing with many sequential `get_online_features()` calls
- Services with authentication enabled (reduces token refresh overhead)
### Session Cleanup
The HTTP session is automatically managed with idle timeout, but you can also explicitly close it when your application is shutting down or when you want to release resources.
#### Using FeatureStore context manager (recommended)
The recommended way to ensure proper cleanup is to use the `FeatureStore` as a context manager:
```python
from feast import FeatureStore
# Session is automatically closed when exiting the context
with FeatureStore(repo_path=".") as store:
features = store.get_online_features(
features=["driver_hourly_stats:conv_rate"],
entity_rows=[{"driver_id": 1001}]
)
```
#### Explicit cleanup
You can also explicitly close the session by calling `close()` on the `FeatureStore`:
```python
from feast import FeatureStore
store = FeatureStore(repo_path=".")
try:
features = store.get_online_features(
features=["driver_hourly_stats:conv_rate"],
entity_rows=[{"driver_id": 1001}]
)
finally:
store.close() # Closes HTTP session and releases resources
```
#### Direct session management
For advanced use cases, you can directly manage the HTTP session via `HttpSessionManager`:
```python
from feast.permissions.client.http_auth_requests_wrapper import HttpSessionManager
# Close the cached HTTP session
HttpSessionManager.close_session()
```
## How to configure Authentication and Authorization
Please refer the [page](./../../../docs/getting-started/concepts/permission.md) for more details on how to configure authentication and authorization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from feast.infra.online_stores.helpers import _to_naive_utc
from feast.infra.online_stores.online_store import OnlineStore
from feast.permissions.client.http_auth_requests_wrapper import HttpSessionManager
from feast.protos.feast.types.EntityKey_pb2 import EntityKey as EntityKeyProto
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import FeastConfigBaseModel
Expand Down
Expand Up
@@ -51,6 +52,18 @@ class RemoteOnlineStoreConfig(FeastConfigBaseModel):
""" str: Path to the public certificate when the online server starts in TLS(SSL) mode. This may be needed if the online server started with a self-signed certificate, typically this file ends with `*.crt`, `*.cer`, or `*.pem`.
If type is 'remote', then this configuration is needed to connect to remote online server in TLS mode. """
# Connection pooling configuration
connection_pool_size: int = 50
""" int: Maximum number of connections to keep in the pool (default 50).
Increase for high-concurrency workloads. """
connection_idle_timeout: int = 300
""" int: Maximum time in seconds a session can be idle before being closed (default 300 = 5 minutes).
Set to 0 to disable idle timeout. """
connection_retries: int = 3
""" int: Number of retries for failed requests with exponential backoff (default 3). """
class RemoteOnlineStore(OnlineStore):
"""
Expand Down
Expand Up
@@ -544,6 +557,20 @@ def teardown(
):
pass
async def close(self) -> None:
"""
Close the HTTP session and release connection pool resources.
This method is called automatically when FeatureStore.close() is invoked.
It cleans up the cached HTTP session used for connection pooling.
Note: Since the session is shared globally, calling close() will affect
all RemoteOnlineStore instances in the same process. This is typically
fine for SDK usage where there's usually one FeatureStore per process.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add HTTP connection pooling for remote online store client #5895
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
feat: Add HTTP connection pooling for remote online store client #5895
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.