skip to content

In SageMaker Feature Store, what happens in each store when PutRecord sends a record whose event time is older than the stored one?

level: middleimportance: should knowfreq 7%

answer

  1. record identifier plus event time
  2. online keeps one record per identifier
  3. offline is append-only history
  4. equal or newer event time overwrites
  5. GetRecord still returns the newer one

basics

~20 s

The offline store appends it, because it keeps every record. The online store ignores it, because it keeps only the latest event time per record identifier; an equal or newer event time would overwrite. GetRecord keeps returning the newer record.

solid answer

~40 s

A SageMaker feature group names a record identifier feature and an event time feature, and `PutRecord` writes to whichever stores the group has. The online store, which is not created unless you enable it, keeps only the record with the latest event time per identifier. An older event time changes nothing there, while an equal or newer one overwrites. The offline store is append-only Parquet in your S3 bucket, registered in the Glue Data Catalog, so the older record is added beside the newer one. A backfill therefore never disturbs serving, `GetRecord` keeps returning the newest record, and training reads both rows through an Athena query you write yourself. Two settings change the picture: an `InMemory` feature group has no offline store at all, and a `TtlDuration` counts from the record's event time.

code

python · 19 lines
python
import boto3

runtime = boto3.client("sagemaker-featurestore-runtime")

# Backfill a September value for learner 4711 (older than the live October record)
runtime.put_record(
    FeatureGroupName="learner-dropout-features",
    Record=[
        {"FeatureName": "learner_id", "ValueAsString": "4711"},
        {"FeatureName": "EventTime", "ValueAsString": "2026-09-01T00:00:00Z"},
        {"FeatureName": "lessons_completed_7d", "ValueAsString": "3"},
    ],
)

# Online read: still the record with the latest event time (October)
latest = runtime.get_record(
    FeatureGroupName="learner-dropout-features",
    RecordIdentifierValueAsString="4711",
)

go deeper

for a junior

Remember the two required names, record identifier and event time, and that the online store holds only the newest record per identifier.

for a middle

Explain the write rule per store: the online store compares event times, the offline store appends everything. Then say how each store is read: GetRecord online, an Athena query offline.

for a senior

Diagnose a correction that never appears online by checking its event time against the stored record. Plan backfill capacity, and avoid InMemory when training needs history.

for a principal

Weigh SageMaker's split of latest-online and append-only S3 history against how much as-of query logic your team will own in Athena.

## The two names every feature group needs In **Amazon SageMaker Feature Store**, features live in a **feature group**, a table-like resource. Every feature group is created with two names that point at features in its own definitions: - the **record identifier name** — the feature that identifies a record, such as `learner_id`; - the **event time feature name** — the timestamp you supply for when the record's event happened, as an ISO-8601 UTC string or as fractional seconds since the Unix epoch. The record identifier and the event time together uniquely identify a record. The feature group's storage configuration decides which stores exist. An **online store** is a low-latency store for real-time lookup, and the SDK does not create one unless you enable it. An **offline store** is history kept as Parquet in an S3 bucket you name, registered as an AWS Glue table (`Glue` by default, `Iceberg` recommended) so Athena can query it. ## Two stores, two write rules `PutRecord` is the synchronous ingestion call, used for streaming updates and batch backfills alike. The same record is then treated differently by each store: | Store | Keeps | When the incoming event time is older than the stored one | When it is equal or newer | |---|---|---|---| | Online | Only the record with the latest event time per identifier | Nothing happens; the stored record stays | The record is overwritten | | Offline | Every record ever ingested (append-only) | The record is appended | The record is appended | The documentation spells out the default exactly. In the offline store the new record is appended. In the online store, an event time *less than* the existing one changes nothing, and *greater than or equal to* overwrites. ## Tracing a backfill Suppose the learner-dropout team re-computes `lessons_completed_7d` for September and writes those rows with September event times, while live traffic has already written October values: 1. The online store compares event times, finds the October record newer, and keeps it. 2. The offline store appends the September record beside the October one. 3. A `GetRecord` for that learner still returns the October values. 4. A training query over the offline store now sees both rows, and choosing the right row for each label time is the query's job. The backfill therefore never disturbs serving, and serving never hides the backfill from training. ## Reading the data back - **Online:** `GetRecord` with `RecordIdentifierValueAsString` returns the latest record. `BatchGetRecord` takes up to 100 records and can span up to 100 feature groups in one call. Asking for a subset of features still costs read capacity for the whole record. - **Offline:** the Python SDK's `athena_query()` returns a query object for the group's Glue table. You `run()` your SQL with an S3 output location and load the result with `as_dataframe()`. SageMaker does not build the point-in-time training set for you; you write that query yourself. ## Settings that change the picture - **`InMemory` storage type:** it supports online-only feature groups. There is no offline store and no online-to-offline replication, so a backfilled older record has nowhere to land. - **`TtlDuration`:** unset by default (`null`), so a record stays online until it is overwritten. When it is set, the record is hard-deleted from the online store after `EventTime + TtlDuration` and added to the offline store. A backfilled record with an old event time can therefore be due for expiry already. - **`Provisioned` throughput:** writing historical records consumes extra write capacity, so AWS advises provisioning twice the recent peak WCU before a backfill. Otherwise it is throttled. - **`Iceberg` table format:** the event time feature must be of type `String`, or the feature group cannot be created. - **`Standard_V2` storage type:** it adds partial updates with `UpdateRecord` and uses each update's `EventTime` to detect and reject out-of-order writes, so a stale update cannot overwrite newer values. ## What to check when an online value looks wrong If a corrected value never shows up online, compare its event time with the stored record's. A correction written with the original, older timestamp loses to the newer record by design. A correction meant to win online must carry an event time at least as new as the record it replaces. In the offline store it simply becomes one more row to choose from.

  • What changes if that feature group uses the InMemory online storage type?
    `InMemory` supports online-only feature groups, so there is no offline store and no replication to one. The older record is not kept anywhere: the online store already holds a newer one. A team that needs training history must use `Standard` or `Standard_V2` with an offline store, or keep history elsewhere.
  • A group runs in Provisioned throughput mode; what should you do before a large historical backfill?
    Raise write capacity first. AWS notes that writing historical records consumes additional write capacity, and advises provisioning about twice the recent peak WCU for backfills or bulk ingestion. Otherwise `PutRecord` calls are throttled. Provisioned mode does not auto-scale, so you change the capacity yourself with `UpdateFeatureGroup`.

  • An older PutRecord overwrites the online record because it arrived last.
  • A backfill through PutRecord overwrites the live online values with history.
  • The offline store keeps only the latest record per identifier, like the online one.
  • GetRecord can be asked for the record as of an earlier event time.
  • Every feature group gets an online store unless you disable it.