TemporalStore Deep Dive

A serving engine for temporal features, risk state, and online context.

Modern online decisions need more than latest-value lookups. They need fresh windows, filters, sequences, counters, distinct state, replay, and observability inside the request path.

The short version

TemporalStore is MatrixArk's online temporal serving engine. Its target is not the generic cache problem. Its target is the product gap between stream processing, feature stores, wide-column databases, and online caches.

Risk, fraud, ads, recommendation, marketplace trust, and LLM agent systems repeatedly ask questions such as: how many times did this device fail login in the last 30 minutes, which merchants did this card touch in the last 24 hours, which campaign impressions happened in the last hour, what did this user recently read, and what context should be placed into the next model call?

The product thesis: serve high-cardinality temporal features directly, without building a separate batch job, streaming job, cache layout, repair path, and custom serving service for every feature family.

Why cache plus pipelines breaks down

A common architecture starts cleanly: raw events go to a queue, a stream processor computes aggregates, Redis or another online store serves latest values, and offline jobs repair or backfill state. That is a strong architecture for stable feature sets.

It becomes expensive when temporal questions change every week. A risk team adds a new velocity check. An ads team changes a frequency cap. A recommender wants a different sequence slice. An agent product needs session state, tool-call history, policy counters, and user preferences in one context bundle. Each new question creates new stream logic, new keys, new TTL rules, and another place where serving behavior can drift from training behavior.

Traditional per-feature stack

Raw events Queue Stream job per feature family Online cache or KV Batch repair and backfill Custom serving logic Model, rule, or product decision

TemporalStore path

Raw or bucketed events TemporalStore data models Direct online query Model, rule, or product decision

What TemporalStore owns

The central design choice is to make the storage engine understand the online model. Instead of storing an opaque blob and forcing every caller to implement window logic, the engine exposes model-aware commands over entity-local state.

Temporal counters

Increment and query counts or sums over request-time windows, such as purchases in five minutes or impressions in one hour.

Filtered aggregates

Apply dimensions such as country, merchant, campaign, action type, category, or device class inside the serving object.

Distinct state

Track unique merchants, devices, accounts, IPs, campaigns, or sessions over a retained time range.

Sequence features

Serve recent ordered behavior events with limits, filters, and timestamps for ranking and personalization models.

Risk and frequency cap

Keep high-cardinality counters close to the request path instead of scattering bucket logic through application code.

Structured AI context

Store session timelines, tool events, memory metadata, policy counters, and state used to assemble LLM prompts.

Architecture

TemporalStore is organized as a metaserver plus data nodes. The metaserver owns namespace, table, partition, placement, and routing metadata. Clients or proxies use that metadata to route writes to primary partitions and route reads according to consistency and freshness policy.

Applications
risk, ads, recsys, agents
SDK or proxy
routing and compatibility
Metaserver
tables, partitions, placement
Data node
primary partitions
Data node
secondary partitions
Data node
secondary partitions
Memory objects
hot model state
Block cache
DRAM and SSD pages
Shared durable store
page, index, oplog streams

A partition is the core serving unit. It owns a slot range and contains the in-memory objects, model command executors, index, oplog, page store, block cache integration, background dump logic, and replica replay logic. Keys are hashed into slots; slots map to partition sets; partition sets contain a primary and optional secondaries.

Write workflow

A write is routed to the partition owner, applied to the model object in memory, logged as a replayable mutation, and later merged into persisted pages.

1. Client computes slot and resolves partition 2. Primary partition worker receives the command 3. Command executor selects the data model 4. Object manager loads or creates the object 5. Model mutates in-memory state 6. Oplog records the mutation 7. Dirty slot is marked for page dump 8. Background storage merges and dumps pages

This is why repeated updates to a hot entity can be efficient. The hot object is updated in memory while the storage layer can later dump merged object or slot state. In an LSM design, every update enters the write path and later participates in compaction. In TemporalStore's target design, the storage engine can reduce write amplification for entity-local serving state by merging hot updates before page persistence.

write failed_login_count:
  key = device_id
  dimensions = { country: "US", method: "password" }
  timestamp = now
  bucket = 10 seconds
  value += 1

query:
  key = device_id
  metric = failed_login_count
  filter country == "US"
  window = last 30 minutes

Read workflow

Hot reads are served from memory. Warm reads use an in-memory index to locate persisted pages and can hit the block cache. Cold reads go to the shared durable store, decode the page or object, refill cache, and then execute the model-specific query.

Query
window, filter, sequence, KV
In-memory index
slot to object/page metadata
Hot object
fast model compute
Block cache hit
DRAM or SSD page
Shared-store read
cold page
Decode and compute
return feature result

The query is not a full-table scan. The routing layer sends the request to the entity's partition, the index identifies slot and page metadata, and the model runs bounded logic over retained entity state. This is the right shape for high-cardinality online features, where there may be millions of sparse entity keys but each request usually asks about one entity or a small set of entities.

Storage layout: object, slot, page, zone, oplog

TemporalStore's storage vocabulary matters because it explains why the engine is different from a plain cache.

ConceptMeaningWhy it matters
ObjectThe model-aware state for a key, such as a hash, sequence, risk counter, or aggregate object.The engine can run domain operations against the object instead of returning an opaque blob.
SlotA hash-space unit that groups keys for partition ownership and dump/load bookkeeping.Dirty slots can be tracked and persisted without rewriting unrelated data.
PageA persisted unit containing encoded object or slot state.Cold or evicted state remains queryable through page reads and cache fills.
ZoneA stream/blob region used by page, index, or oplog storage.Zones make append, freeze, reclaim, and garbage collection visible to the storage layer.
OplogThe mutation stream used for recovery and replica replay.A replica can reconstruct recent updates by replaying mutations after a page/index checkpoint.
IndexIn-memory and persisted metadata mapping slots and objects to latest page locations.Reads follow the index to the latest known state instead of hunting through storage.

Replication and recovery

TemporalStore uses primary partitions and secondary replicas. A secondary reconstructs queryable state from durable page/index state plus oplog replay. In a shared-store deployment, secondaries can read persisted streams directly. In a primary-pull design, secondaries can pull stream data from the current primary.

Important engineering guardrail: oplog alone is not enough forever. Once old updates have been merged into pages and the oplog checkpoint advances, recovery needs page streams, index metadata, and oplog after that checkpoint.
Primary writes mutation Oplog append records the update Dirty slot is dumped into pages Index records latest page addresses Secondary loads base pages Secondary replays oplog after checkpoint Secondary becomes queryable when replay catches up

The roadmap hardens this with explicit primary lease or epoch fencing, freshness gates before promotion, secondary lag metrics, and recovery tests that include historical pages. Split-brain writers and stale replicas must be rejected before a deployment can be trusted for correctness-sensitive workloads.

Data model examples

The right model depends on the product question.

Use caseEntity keyModelExample query
Purchase velocityuser_idTemporalCounterCount purchases in the last 5 minutes.
Failed login riskdevice_idTemporalAggregate with dimensionsFailed logins by country and method in the last 30 minutes.
Card testingcard_idTemporalDistinctUnique merchants touched in the last 24 hours.
Chargeback monitoringmerchant_idTemporalAggregateChargebacks by channel in the last 7 days.
Frequency capcampaign_id + user_idComposite-key counterImpressions in the last hour, day, or campaign window.
Ranking sequenceuser_idSequenceRecent clicked items filtered by category and recency.
Agent contextsession_idSequence plus countersRecent tool calls, safety counters, and user preference deltas.

Why not just Redis or RocksDB?

Redis-style systems are excellent for simple strings, hashes, latest profiles, leader boards, queues, and many cache workflows. MatrixDB is the MatrixArk product direction for eventually consistent KV workloads that need both low-latency serving and offline or nearline query access. TemporalStore is different: it tries to put temporal semantics inside the serving engine.

RocksDB is a powerful embedded LSM engine and often the right local persistence layer. The tradeoff is that repeated updates create LSM write-path work and later compaction. For a hot entity receiving many small counter or sequence updates, TemporalStore's model is to update in memory, append replayable mutations, then dump merged pages when the storage manager decides to persist dirty state.

SystemGood atWhere TemporalStore differs
Redis-compatible cacheFast general data structures and latest-value serving.TemporalStore adds model-aware windows, filters, replayable feature state, and persisted pages.
RocksDB-backed KVDurable ordered local storage with mature LSM behavior.TemporalStore avoids treating every hot temporal update as a generic KV rewrite.
Feature storeRegistry, training sets, materialization, lineage, offline/online consistency.TemporalStore can act as the online serving engine underneath the registry.
Stream processorKnown transformations, joins, durable event-time processing.TemporalStore serves request-time entity windows when precomputing every window is too rigid.
Time-series databaseMetric series, analytics queries, monitoring workloads.TemporalStore is entity-serving-first, not dashboard-query-first.

Where it fits with feature platforms

TemporalStore should not try to replace every feature platform capability on day one. Systems such as Feast, Chronon, Fennel, and Featureform are strong at registry, definitions, lineage, transformation orchestration, training sets, and offline/online consistency. TemporalStore is strongest as the online temporal serving engine underneath or beside those platforms.

Feature registry
definitions, owners, lineage
Offline store
warehouse, lake, training data
Stream or batch compute
durable transforms
TemporalStore
fresh temporal state
MatrixDB
eventual KV, profiles, scans, exports
MatrixKV
strong consistency, metadata, transactions
Online model or rules engine
low-latency decision
Monitoring
lag, errors, cache, storage
Export path
training and audit

LLM context is a related, not identical, problem

TemporalStore is not a GPU KV-cache manager. It does not replace the transformer KV cache used by vLLM, SGLang, TensorRT-LLM, or LMCache-style systems. The LLM runtime still needs tensor layout, prefix matching, GPU memory management, token-position lifecycle, and attention-cache APIs.

The overlap is structured context and state. Agent systems need recent conversation events, tool calls, retrieved-document metadata, memory freshness, safety counters, user preferences, and policy state. Vector databases are good at similarity search. TemporalStore is useful for temporal and structured context that should be filtered, counted, ordered, replayed, or expired with serving semantics.

Operational design

A serving engine is not a product until it is observable. The current MatrixArk observability work exposes separate pages for TemporalStore, MatrixDB, MatrixKV, and a Prometheus-compatible metrics endpoint. For TemporalStore, the most important signals are partition health, primary placement, replica replay lag, oplog append latency, page dump progress, block-cache hit ratio, storage errors, and client retry visibility.

In a quick engineering environment, those pages can be served under the same HTTP port as the company site. That is useful for fast iteration, but it is not the production boundary. A production deployment should separate the public website from the authenticated operations console and keep raw metrics endpoints private.

matrixark.ai
public product site, blogs, docs
console.matrixark.ai
authenticated cluster console
private metrics plane
Prometheus, logs, node variables
Metaserver
routing, placement, node state
Data nodes
partitions, replicas, cache, storage
Cloud integrations
ASG, lifecycle hooks, CloudWatch

Partition and placement

Track primary owner, secondary owner, partition epoch, shard state, and table readiness.

Replication freshness

Report replay lag, missing reads, retry latency, oplog gap, and time-to-visible on secondaries.

Storage and cache

Track dirty slots, page dumps, old zone cleanup, SSD cache bytes, cache hit ratio, and cold reads.

Model correctness

Expose per-model request failures, encoding mismatches, query result shape, and guardrail tests.

Autoscale and rolling deployment design

Autoscaling should not mean that a new instance independently decides which partitions it owns. A new TemporalStore data node should boot from a versioned runtime package, discover its instance identity, register with the metaserver, and advertise capacity. The metaserver then assigns secondary replicas first, waits for catch-up, and only then moves read traffic or primary ownership.

ASG launches data node Runtime package starts service Node registers capacity with metaserver Metaserver marks node active Planner assigns replicas Replica catches up Routing table updates Reads or primaries move gradually

Scale-down needs the reverse workflow. The node should enter draining state, stop receiving new primary assignments, move primary partitions away, wait for replacement replicas to become healthy, and only then complete the cloud lifecycle termination. This protects the serving path from raw instance termination and makes rolling upgrades safer.

Runtime package requirement: release artifacts should include data server, metaserver, proxy, client tools, dynamic libraries, systemd units, health checks, registration scripts, drain scripts, metrics configuration, and version metadata. Autoscale only works cleanly when a new node can become useful without manual copying or shell repair.

Engineering snapshot

The current AWS test cluster used one metaserver/client/UI node and two data nodes. A Prometheus bridge scraped the metaserver and both data nodes through their runtime variables endpoint.

SignalLatest observed valueInterpretation
Prometheus sources3 sources: metaserver, data01, data02Live scrape path is wired for TemporalStore.
Service smoke1,525 iterations over 30 minutes for core modulesSTRING, COMMON, HASH, SET, FEATURE, IPS, and RISK stayed stable in that loop.
TemporalAggregateBlocked by response-size check in the deployed artifactThis is not yet a clean aggregate scale pass. It is an explicit P0 follow-up.
Two-replica table pathHit a condition-info load issue in the latest runtimeSecondary replication benchmarks should be rerun after table creation is fixed.

These numbers are engineering snapshots, not final product benchmarks. The useful signal is the shape of the system: live metrics, module-level smoke coverage, and clear correctness gaps to fix before stronger claims.

The product boundary

TemporalStore should be honest about what it is. It is not a full warehouse, not a full feature platform, not a vector database, and not a transformer KV-cache runtime. It is an online state engine for temporal features and context. MatrixDB handles eventually consistent KV serving, profiles, and offline-queryable state. MatrixKV handles strongly consistent transactional metadata. Together they form the MatrixArk platform.

  1. Use TemporalStore when the feature depends on recent events, windows, filters, distinct state, or sequences.
  2. Use MatrixDB when the workload is latest profile, large hash/profile KV, hot-key cache, tenant-scale service state, scans, exports, or offline/nearline query over persisted KV data and eventual consistency is acceptable.
  3. Use MatrixKV when the workload needs transactional KV, timestamp coordination, metadata correctness, or strong consistency.
  4. Use feature stores and warehouses for registry, training sets, lineage, offline truth, and backfills.