MongoDB

Description

The MongoDBarrow-up-right online store provides support for materializing feature values into MongoDB for serving online features.

circle-exclamation

Features

  • Supports both synchronous and asynchronous operations for high-performance feature retrieval

  • Native async support uses PyMongo's AsyncMongoClient (no Motor dependency required)

  • Flexible connection options supporting MongoDB Atlas, self-hosted MongoDB, and MongoDB replica sets

  • Automatic index creation for optimized query performance

  • Entity key collocation for efficient feature retrieval

Getting started

In order to use this online store, you'll need to install the MongoDB extra (along with the dependency needed for the offline store of choice):

pip install 'feast[mongodb]'

You can get started by using any of the other templates (e.g. feast init -t gcp or feast init -t snowflake or feast init -t aws), and then swapping in MongoDB as the online store as seen below in the examples.

Examples

Basic configuration with MongoDB Atlas

Self-hosted MongoDB with authentication

MongoDB replica set configuration

Advanced configuration with custom client options

The full set of configuration options is available in MongoDBOnlineStoreConfigarrow-up-right.

Data Model

The MongoDB online store uses a single collection per project with entity key collocation. Features from multiple feature views for the same entity are stored together in a single document.

Example Document Schema

The example shows a single entity. It contains 3 features from 2 feature views: "rating" and "trips_last7d" from Feature View "driver_stats", and "surge_multiplier" from "pricing" view. Each feature view has its own event timestamp. The "created_timestamp" marks when the entity was materialized.

Key Design Decisions

  • _id field: Uses the serialized entity key (bytes) as the primary key for efficient lookups

  • Nested features: Features are organized by feature view name, allowing multiple feature views per entity

  • Event timestamps: Stored per feature view to track when each feature set was last updated

  • Created timestamp: Global timestamp for the entire document

Indexes

The online store automatically creates the following index:

  • Primary key index on _id (automatic in MongoDB), set to the serialized entity key.

No additional indexes are required for the online store operations.

Async Support

The MongoDB online store provides native async support using PyMongo 4.13+'s stable AsyncMongoClient. This enables:

  • High concurrency: Handle thousands of concurrent feature requests without thread pool limitations

  • True async I/O: Non-blocking operations for better performance in async applications

  • 10-20x performance improvement: For concurrent workloads compared to sequential sync operations

Both sync and async methods are fully supported:

  • online_read / online_read_async

  • online_write_batch / online_write_batch_async

Functionality Matrix

The set of functionality supported by online stores is described in detail here. Below is a matrix indicating which functionality is supported by the MongoDB online store.

MongoDB

write feature values to the online store

yes

read feature values from the online store

yes

update infrastructure (e.g. tables) in the online store

yes

teardown infrastructure (e.g. tables) in the online store

yes

generate a plan of infrastructure changes

no

support for on-demand transforms

yes

readable by Python SDK

yes

readable by Java

no

readable by Go

no

support for entityless feature views

yes

support for concurrent writing to the same key

yes

support for ttl (time to live) at retrieval

no

support for deleting expired data

no

collocated by feature view

no

collocated by feature service

no

collocated by entity key

yes

To compare this set of functionality against other online stores, please see the full functionality matrix.

Last updated

Was this helpful?