Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ai-research): align ML key store defaults with production (#101423)

Robbie30007ac54ced
diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/config.ts b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/config.ts
index 7c696bf71b89..bd27b494c1ee 100644
--- a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/config.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/config.ts
@@ -221,9 +221,9 @@ export function getDefaultMlMirrorConfig(): MlMirrorConfig {
AI_RESEARCH_REPLAY_KEY_TABLE: '',
AI_RESEARCH_REPLAY_KMS_KEY_ARN: '',
AI_RESEARCH_REPLAY_AWS_REGION: 'us-east-1',
- AI_RESEARCH_REPLAY_KMS_REQUESTS_PER_SECOND: 100,
- AI_RESEARCH_REPLAY_KEY_CACHE_MAX: 10_000,
- AI_RESEARCH_REPLAY_KEY_CACHE_LIFETIME_MS: 60_000,
+ AI_RESEARCH_REPLAY_KMS_REQUESTS_PER_SECOND: 150,
+ AI_RESEARCH_REPLAY_KEY_CACHE_MAX: 100_000,
+ AI_RESEARCH_REPLAY_KEY_CACHE_LIFETIME_MS: 1_800_000,
AI_RESEARCH_REPLAY_IMAGE_FETCH_V2_DYNAMODB_TABLE: '',
AI_RESEARCH_REPLAY_S3_PREFIX: 'rrweb_2',
SESSION_RECORDING_ML_METADATA_PREFIX: 'block-metadata',
diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/crypto.ts b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/crypto.ts
index 937573464124..b4a84849cd77 100644
--- a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/crypto.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/crypto.ts
@@ -36,10 +36,10 @@ export class MlKeyEncryption {
constructor(
private readonly kms: Pick<KMSClient, 'send'>,
private readonly masterKeyArn: string,
- maxKeys = 10_000,
- cacheLifetimeMs = 60_000,
+ maxKeys = 100_000,
+ cacheLifetimeMs = 1_800_000,
concurrency = 8,
- private readonly requestsPerSecond = 100
+ private readonly requestsPerSecond = 150
) {
this.cache = new LRUCache({ max: maxKeys, ttl: cacheLifetimeMs })
this.concurrency = pLimit(concurrency)
diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/key-store.ts b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/key-store.ts
index 4f3c4fc7a74d..fbc4e21332de 100644
--- a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/key-store.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror/keys/key-store.ts
@@ -15,7 +15,7 @@ import {
teamBlockId,
} from './schema'
-// Commits retry transient DynamoDB and KMS failures; the budget counts the re-reads as well as the waits and stays under the consumer's 60 s loop stall threshold.
+// Commits retry transient DynamoDB and KMS failures; the budget counts the re-reads as well as the waits and stays under the consumer's loop stall threshold.
const COMMIT_ATTEMPTS = 10
const COMMIT_BUDGET_MS = 45_000
const COMMIT_BACKOFF_BASE_MS = 100