Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Datadog Engineering 13 min read Case study mediumAdept

How we migrated a live routing system using AI-assisted refactoring

Datadog migrated Stream Router, the control plane that tells metrics producers and queriers which Kafka cluster, topic and partitions to use, from a FoundationDB key-value model to a relational schema. PostgreSQL backs the write path and DuckDB the in-memory read path. The KV model forced the app to rebuild relationships in-process and hit transaction size limits, and simply swapping in Postgres with the same access patterns was estimated at 45 minutes for the heaviest operations. The team designed the schema by hand, then used Claude and Cursor in a tightly scoped, test-driven loop: map the intent of the old code into markdown docs, stub one Controller method, feed in the failing end-to-end tests, and iterate until they pass. A blue/green validator compared live responses every 30 seconds for weeks before cutover. The models produced correct but suboptimal SQL, so batching, UNNEST and CTE optimizations needed human input, and broad prompts performed poorly. The project went from design to production in about 3 months.

Assumes: Kafka basicsrelational schema designend-to-end testing

Related posts

  • Leveraging Change Data Capture For Database Migrations At Scale

    Squarespace Engineering mediumAdept

    Squarespace migrated many PostgreSQL databases to CockroachDB without write downtime by streaming changes through a CDC pipeline: pgoutput logical decoding feeds per-table Debezium connectors into Kafka (Avro), and per-table Apache Beam pipelines on Dataflow upsert batched events into CRDB with checkpointing and backpressure. A reverse changefeed into a separate Kafka queue gave a rollback path to Postgres, and a homegrown diffing tool validated data before cutting over via a proxy. Snapshots reached about 60k rows/s and most systems were over 99.99% fresh at cutover, though some needed brief write pauses. Foreign-key failures across independent per-table writers, including cyclic constraints CRDB can't defer, were handled by disabling constraints during the isolated migration and restoring them before cutover.

  • Scaling SaaS security: Reco’s migration from Postgres to ClickHouse Cloud

    ClickHouse mediumAdept

    Reco, a SaaS security platform ingesting 10-12 billion JSON events weekly, moved over 90% of its workload from Postgres to ClickHouse Cloud. Running both databases synced via CDC had made schema migrations, updates, deletes and VACUUM painful. Reco replaced RDBMS features with ReplacingMergeTree and CollapsingMergeTree for upserts and deletes, idempotency and eventual consistency instead of transactions, and tenant-level atomic materialized view refreshes via REPLACE PARTITION. Further gains came from compute-compute separation, spill-to-disk settings, parallel_distributed_insert_select=2 (cutting resource needs by a third) and data-skipping indexes, plus using the EmbeddedRocksDB engine as a streaming state store in place of Spark state and Redis.

  • 5 Billion Records, 10 Terabytes, Four Weeks: A Real Data Migration Playbook

    Wix Engineering mediumAdept

    Wix's large live-system migrations dropped from months or years to weeks mainly by tackling recurring problems before the migration starts, not through new tooling. Profile the source database first with a read-only dry run to find corrupt legacy records. Find V1/V2 parity gaps early using E2E suites through the API proxy, LLM analysis of production traffic and shadow compare mode. Decide up front how CDC/Kafka handles a failing record: blocking retries, skip-and-log, or a dead letter queue. Size Kafka partitions and database capacity so eager migration outruns the incoming change rate; contacts needed 350 partitions for 100,000 RPM plus sharding a 14 TB single-master MySQL into eight shards.

  • Evolving the Backend Storage for Platform Metrics

    Heroku Engineering mediumAdept

    Heroku migrated the time-series store behind MetaaS, its internal metrics service, from self-managed Apache Cassandra to AWS DynamoDB without user-visible impact. MetaaS ingests a couple hundred thousand observations per second into Kafka and aggregates them with stream-processing jobs, writing tens of thousands of points per second to the database. The migration used parallel dual-writes from Kafka and GitHub Scientist-style shadow reads, ramped to 100% of traffic, to catch edge cases. TTL-based retention meant no data backfill was needed: they waited for old Cassandra data to expire, then incrementally cut reads over. p99 query latency dropped from a variable 20–80 ms to a steady 15 ms, and costs fell.

  • Breaking up a monolith: How we’re unwinding a shared database at scale

    Datadog Engineering mediumAdept

    Datadog is splitting its large shared Postgres database into independently owned instances through a three-phase plan: logical separation into per-domain private schemas with explicit ACLs, access reduction so only owning teams query their tables directly, and physical separation onto managed OrgStore instances. Domain boundaries came from clustering Database Monitoring query samples and validating them with 30+ teams. Inter-domain foreign keys were replaced with CDC or Postgres replication. A homegrown PG Proxy lets teams migrate at their own pace and makes cutover a dynamic config change, with write downtime under five seconds and reverse replication kept for rollback. The platform investments that made this feasible, the Rapid service framework, OrgStore and PG Proxy, are presented as prerequisites, and each phase has concrete progress metrics.

The quest for software engineering knowledge.

Look:
Layout: