DBRaven
Full ReviewModerate Readinessdraft

Architecture Review: Analytics Data Platform

An OLAP-oriented analytics architecture that ingests operational changes from PostgreSQL via WAL-based CDC into Kafka, then routes them to a columnar analytics store (ClickHouse or Snowflake) for product analytics, business intelligence, and operational reporting. The CQRS separation ensures analytical queries never degrade transactional write performance, and materialized views provide pre-aggregated query acceleration for the most expensive analytical patterns.

Evidence Confidence

Moderate

moderate

Executive Summary

Analytics Data Platform: moderate operational readiness (79% evidence confidence). 4 architectural strengths identified, 3 operational risks to manage. Primary concern: Hot Partition. Requires Advanced operational maturity.

Readiness Rationale

Overall moderate readiness across 8 dimensions. Limited: team maturity. Strong: operational, migration, observability.

Key Concerns

  • !Hot Partition
  • !Queue Backlog Accumulation

Key Strengths

  • +Analytics-heavy workloads pre-compute expensive aggregations and joins into materialized views, reducing repeated full-scan query…
  • +ClickHouse's columnar storage engine, vectorized query execution, and MergeTree family of table engines are specifically designed…
  • +Kafka is the standard downstream target for WAL-based CDC pipelines: Debezium captures database WAL records and publishes them to…
  • +CQRS separates the write model (normalized, ACID) from the read model; materialized views implement the read model by…

8

Assessments

2

Tradeoffs

6

Sections

11

Recommendations

Readiness Assessments

8

Architectural Tradeoffs

2

Recommendations

11
High

Monitor: Queue Backlog Accumulation

risk_monitoring

Message queue or event stream consumer processing rate falls below producer write rate, causing consumer lag to grow unboundedly: eventually leading to increased end-to-end latency, producer backpressure, data expiry, or queue resource exhaustion.

Affects 1 node. (Slow Consumer)

High

Monitor: Hot Partition

risk_monitoring

One partition (a database shard, a Kafka topic partition, a Redis hash slot) receives traffic so far above its peers that it saturates while the others sit idle. Aggregate capacity looks healthy, but the hot partition throttles or lags, and everything routed to it degrades. The cause is skew in how keys map to partitions, and the fix depends on whether the skew is spread across many keys or concentrated in one.

Affects 0 nodes

High

Implement: Monitor queue backlog signals

observability

Seed 'Queue Consumer Backlog' identifies 4 metrics relevant to queue_backlog_accumulation.

Metrics to instrument: queue_depth, consumer_lag_seconds, consumer_throughput

Moderate

Analytics queries running directly against PostgreSQL OLTP primary → Read replica serving analytics queries via polling ETL

migration_planning

Trigger: OLTP query p99 degrading during analytics reporting windows; reporting queries showing wait events (LockTimeout, I/O wait) in pg_stat_activity. Migrate from 'Analytics queries running directly against PostgreSQL OLTP primary' to 'Read replica serving analytics queries via polling ETL'. Polling ETL from a read replica is a practical first step. It separates analytics load from the primary without committing to Kafka infrastructure.

Read replica replication lag degrades freshness during heavy OLTP write periods; ETL polling creates a minimum latency floor; sub-minute freshness is not achievable

Moderate

Polling ETL from read replica to analytics store → WAL CDC → Kafka → ClickHouse streaming ingestion

migration_planning

Trigger: Sub-minute analytics freshness SLA required; ETL scheduling overhead growing; analytics volume exceeding what the read replica can serve under polling load. Migrate from 'Polling ETL from read replica to analytics store' to 'WAL CDC → Kafka → ClickHouse streaming ingestion'. This migration delivers streaming freshness and isolates analytics infrastructure from the OLTP layer. Validate CDC slot monitoring and alerting before migrating high-volume tables.

CDC setup requires PostgreSQL logical replication slot: mandatory monitoring obligation from day one; ClickHouse operational model (parts, merges, insert buffering) requires learning investment

Moderate

Prepare runbook for: Burst Traffic Cold Cache Stampede

simulation_preparedness

Simulation demonstrates critical degradation of redis, postgresql

Without a runbook, recovery from this failure mode will be ad-hoc

burst-traffic-cold-cache-stampede
Moderate

Prepare runbook for: Connection Pool Exhaustion with Horizontal User Scale

simulation_preparedness

Simulation demonstrates critical degradation of postgresql

Without a runbook, recovery from this failure mode will be ad-hoc

connection-pool-growth-with-user-scale
Moderate

Plan evolution: OLTP Analytics Queries → OLTP + OLAP Separation

evolution_planning

Evolution from Unified OLTP + Analytics on PostgreSQL → Separated OLTP (PostgreSQL) + OLAP (ClickHouse/Snowflake)

Migration complexity: medium. Rollback: always.

oltp-analytics-to-separated
Moderate

Plan evolution: PostgreSQL → Partitioned PostgreSQL

evolution_planning

Evolution from Single-Node PostgreSQL → Partitioned PostgreSQL

Migration complexity: high. Rollback: rarely.

postgresql-to-partitioned
Low

Monitor threshold: Tier 1: Consumer Lag and Freshness Degradation

scaling_monitoring

Signal: Kafka consumer group lag (bytes or offsets) growing for the analytics topic group; ClickHouse dashboard timestamps falling behind wall clock by > 60s; ClickHouse insert throughput < Kafka produce rate

Bottleneck: ClickHouse insert throughput insufficient for Kafka produce rate. Evolution: Tune ClickHouse insert buffer size and async_insert settings; increase consumer parallelism up to the Kafka partition count; batch inserts into ClickHouse using the Buffer engine or materialized views with merge trees

Low

Monitor threshold: Tier 2: Hot Partition and Skewed Consumer Load

scaling_monitoring

Signal: One Kafka partition offset growing significantly faster than others; one consumer instance CPU/network saturated while others are idle

Bottleneck: Skewed partition key distribution: high-cardinality entity routing the same high-volume key to one partition. Evolution: Add a secondary hash suffix to the partition key to distribute load; increase topic partition count (note: keyed ordering breaks for existing messages); re-evaluate partition key selection based on actual cardinality measurements

Scaling Pressure Signals

8

Kafka consumer group lag (bytes or offsets) growing for the analytics topic group; ClickHouse dashboard timestamps falling behind wall clock by > 60s; ClickHouse insert throughput < Kafka produce rate

Threshold

Tier 1: Consumer Lag and Freshness Degradation

Likely Bottleneck

ClickHouse insert throughput insufficient for Kafka produce rate

Recommended Evolution

Tune ClickHouse insert buffer size and async_insert settings; increase consumer parallelism up to the Kafka partition count; batch inserts into ClickHouse using the Buffer engine or materialized views with merge trees

Evidence:kafka-consumer-lag-cascadepartition-hotspot-amplification

One Kafka partition offset growing significantly faster than others; one consumer instance CPU/network saturated while others are idle

Threshold

Tier 2: Hot Partition and Skewed Consumer Load

Likely Bottleneck

Skewed partition key distribution: high-cardinality entity routing the same high-volume key to one partition

Recommended Evolution

Add a secondary hash suffix to the partition key to distribute load; increase topic partition count (note: keyed ordering breaks for existing messages); re-evaluate partition key selection based on actual cardinality measurements

Evidence:kafka-consumer-lag-cascadepartition-hotspot-amplification

ClickHouse system.parts shows parts_to_merge growing; SELECT queries showing slower p99 despite stable data volume; ClickHouse background merge thread CPU saturation

Threshold

Tier 3: ClickHouse Part Merge Backlog

Likely Bottleneck

Insert rate exceeding ClickHouse background merge throughput for the target table

Recommended Evolution

Reduce insert frequency by increasing batch size; tune parts_to_delay_insert and parts_to_throw_insert; consider a Buffer table as an insert intermediary

Evidence:kafka-consumer-lag-cascadepartition-hotspot-amplification

Business users reporting analytics figures inconsistent with OLTP dashboards; audit requirements necessitating exact match between operational and analytics figures

Threshold

Tier 4: Cross-Store Query Consistency Requirements

Likely Bottleneck

Fundamental eventual consistency gap between OLTP PostgreSQL and analytics store

Recommended Evolution

Introduce event sourcing with snapshot consistency markers to align store states; or accept the eventual consistency model and document the staleness SLA explicitly in analytics tooling

Kafka consumer group lag (bytes or offsets) growing for the analytics topic group; ClickHouse dashboard timestamps falling behind wall clock by > 60s; ClickHouse insert throughput < Kafka produce rate

Threshold

Escalation trigger: ClickHouse insert throughput insufficient for Kafka produce rate

Likely Bottleneck

Tier 1: Consumer Lag and Freshness Degradation

Recommended Evolution

Monitor: queue_depth, consumer_lag_seconds, consumer_throughput

One Kafka partition offset growing significantly faster than others; one consumer instance CPU/network saturated while others are idle

Threshold

Escalation trigger: Skewed partition key distribution: high-cardinality entity routing the same high-volume key to one partition

Likely Bottleneck

Tier 2: Hot Partition and Skewed Consumer Load

Recommended Evolution

Monitor: queue_depth, consumer_lag_seconds, consumer_throughput

ClickHouse system.parts shows parts_to_merge growing; SELECT queries showing slower p99 despite stable data volume; ClickHouse background merge thread CPU saturation

Threshold

Escalation trigger: Insert rate exceeding ClickHouse background merge throughput for the target table

Likely Bottleneck

Tier 3: ClickHouse Part Merge Backlog

Recommended Evolution

Monitor: queue_depth, consumer_lag_seconds, consumer_throughput

Business users reporting analytics figures inconsistent with OLTP dashboards; audit requirements necessitating exact match between operational and analytics figures

Threshold

Escalation trigger: Fundamental eventual consistency gap between OLTP PostgreSQL and analytics store

Likely Bottleneck

Tier 4: Cross-Store Query Consistency Requirements

Recommended Evolution

Monitor: queue_depth, consumer_lag_seconds, consumer_throughput

Migration Readiness

12

Migration Stages

3
Stage

Analytics queries running directly against PostgreSQL OLTP primary → Read replica serving analytics queries via polling ETL

info

Migration trigger: OLTP query p99 degrading during analytics reporting windows; reporting queries showing wait events (LockTimeout, I/O wait) in pg_stat_activity

Stage

Polling ETL from read replica to analytics store → WAL CDC → Kafka → ClickHouse streaming ingestion

info

Migration trigger: Sub-minute analytics freshness SLA required; ETL scheduling overhead growing; analytics volume exceeding what the read replica can serve under polling load

Stage

ClickHouse with raw event tables only → ClickHouse with materialized views and pre-aggregated summary tables

info

Migration trigger: Dashboard query p95 > 5s on frequently accessed aggregation queries; analyst-driven queries competing with dashboard queries for ClickHouse CPU

!

Risks

9
Risk

Read replica replication lag degrades freshness during heavy

warning

Read replica replication lag degrades freshness during heavy OLTP write periods

Risk

ETL polling creates a minimum latency floor; sub-minute fres

warning

ETL polling creates a minimum latency floor; sub-minute freshness is not achievable

Risk

CDC setup requires PostgreSQL logical replication slot: mand

warning

CDC setup requires PostgreSQL logical replication slot: mandatory monitoring obligation from day one

Risk

ClickHouse operational model (parts, merges, insert bufferin

warning

ClickHouse operational model (parts, merges, insert buffering) requires learning investment

Risk

Materialized views must be redesigned if source table schema

warning

Materialized views must be redesigned if source table schema changes

Risk

Stale materialized views (if refresh fails silently) mislead

warning

Stale materialized views (if refresh fails silently) mislead downstream consumers

Risk

Cross-service workflows that previously used database transa

critical

Cross-service workflows that previously used database transactions now require Saga orchestration. Mitigation: Design idempotent event handlers; implement compensating transactions for every multi-step workflow; test failure injection in staging

modular-monolith-to-event-driven

Risk

Consumer lag silently accumulates: a lagging consumer is not

critical

Consumer lag silently accumulates: a lagging consumer is not a failed consumer. Mitigation: Alert on consumer lag rate-of-change, not absolute depth; implement dead letter queues with alerting

modular-monolith-to-event-driven

Risk

Missing partition for current time window causes all INSERTs

critical

Missing partition for current time window causes all INSERTs to fail with 'no partition of relation found'. Mitigation: Create partitions 7-30 days in advance; alert when next partition does not exist before its time window opens

postgresql-to-partitioned

Review Sections

6

Referenced Intelligence

clickhousekafkapostgresqlburst-traffic-cold-cache-stampedeconnection-pool-growth-with-user-scalecqrs-projection-lag-expansioncross-region-stale-read-windowdistributed-cache-invalidation-failureevent-replay-storm-recoverykafka-consumer-lag-cascademulti-tenant-noisy-neighborpartition-hotspot-amplificationpostgresql-replication-lag-surgequery-cost-without-indexesread-amplification-n-plus-one-queriesredis-cache-collapse-stampederetry-storm-amplificationsplit-brain-during-network-partitionstorage-bloat-without-archivingstorage-cost-compounding-without-retentionwrite-heavy-bulk-import-saturationmodular-monolith-to-event-drivenoltp-analytics-to-separatedpostgresql-to-partitionedrabbitmq-to-kafkasingle-region-to-multi-regionarchitecture-evolutionauditabilitybtree-indexingcache-invalidationcap-theoremconsistency-modelscqrs-operationalevent-sourcingeventual-consistencykafka-consumer-lagmulti-tenancynormalizationoltp-vs-olappartition-hotspotsquery-planningqueue-backlogreplication-lagvector-databaseswrite-amplification