Warehouse and streaming architectures
Start with a bookstore decision
A checkout system must record each order and update inventory correctly before confirming payment. A reporting system asks how sales changed over months. A fraud monitor may need a signal within seconds. These workloads share data, but not the same latency, access or consistency requirements. Keep checkout in an operational database (OLTP), copy committed changes to a durable stream or batch export, then build approved analytical tables (OLAP). Do not make a dashboard query a prerequisite for checkout. A daily report can use scheduled batch ingestion; a seconds-level alert may need streaming with a bounded delay. Neither mode guarantees that incoming facts are correct. Define source of truth, freshness target, acceptable late-data behavior and reconciliation first.
Warehouse execution and columnar storage
An operational database typically optimizes short indexed reads and transactions over a small number of records. A warehouse optimizes aggregations over many rows and selected columns. Column-oriented storage groups values of the same column so that projecting day and amount need not read all other attributes. Compression can reduce I/O, but effectiveness depends on data and encoding. Massively parallel processing (MPP) splits a query among workers: scan and filter locally, compute partial sums, redistribute by grouping or join key if needed, then combine results. A skewed key can overload one worker while others wait. A shuffle transfers data across workers and can spill to disk if memory is insufficient. Partition pruning skips irrelevant partitions; sorting or clustering can skip blocks; neither guarantees a fixed number of bytes. Inspect actual query plans, scanned bytes, shuffle, spill and queue times. A star schema connects fact rows (one order or line item, define the grain) to dimensions such as date and channel; joining a fact to a nonunique dimension can inflate revenue. Validate cardinality before publishing.
Execute a local SQL report
Run the SQL below with a fresh SQLite database, using the sqlite3 CLI or Python standard-library sqlite3. The dataset is fictional; cents are integers and ISO dates are strings. SQLite is row-oriented and this exercise checks SQL semantics, not a distributed execution plan or cloud speed. The primary key prevents duplicate order IDs. Filter before aggregation; explicit ORDER BY makes result ordering deterministic.
CREATE TABLE sales(id TEXT PRIMARY KEY, day TEXT, channel TEXT, cents INTEGER);INSERT INTO sales VALUES ('a','2026-01-01','web',300), ('b','2026-01-01','store',500), ('c','2026-01-02','web',200), ('d','2026-01-02','web',100);SELECT day, COUNT(*) AS orders, SUM(cents) AS revenue_centsFROM sales WHERE channel = 'web'GROUP BY day ORDER BY day;Expected rows (day, orders, revenue_cents):
2026-01-01 | 1 | 3002026-01-02 | 2 | 300The web subtotal is 600 cents over three orders; all channels total 1100 cents over four orders. Change the filter to store to obtain one order worth 500 cents. Removing the filter produces daily totals 800 and 300. COUNT counts rows here because one row represents one order. In a line-item fact table count distinct order IDs for order counts. SQL dialects, timestamp and numeric semantics differ; port and test explicitly.
Partitions, ordering and recovery
A stream is a sequence of retained records, not necessarily a single globally ordered log. Partition by stable business key when processing related events in order; an overloaded key can limit throughput. Kafka partitions have offsets; Kinesis shards have sequence numbers; Event Hubs partitions expose positions and checkpoints; Pub/Sub ordering is opt-in and key-scoped under its service conditions, not Kafka offsets. Do not equate any broker order with event-time order. A checkpoint records progress and may include processing state. Commit progress only after the output is durably accepted, or use an atomic state/output protocol; a crash between sink commit and checkpoint can replay a record, so use stable IDs or a transactional sink. Acknowledging too early risks loss. Replay needs retained source, compatible schemas and idempotent outputs. Separate a replay consumer or isolated target from the live path; compare totals before switching. A poison event needs controlled quarantine and ownership, not infinite retries.
Event time and backpressure
Event time is when a business action occurred; processing time is when a worker handles it. An event at second 8 can arrive after an event at second 12. A tumbling window [0,10) contains event times 0 through 9 for integer seconds; [10,20) contains 10 through 19. Sliding windows overlap, session windows group activity by gaps. A watermark estimates event-time progress; allowed lateness defines how long a window can accept corrections after its end. Triggers and accumulation modes decide when to emit updates. A delayed result can be corrected with upserts or retractions; too-late events can be quarantined and reconciled through batch. Do not claim a watermark guarantees no older arrivals. If input is 1200 events/s and processing sustains 900 events/s, backlog grows by 300 events/s, or 18,000 per minute. At 1500 events/s while arrivals remain 1200, clearing 18,000 needs 60 seconds under constant rates. Monitor lag age, partition skew, processing failures, sink throttling and watermark delay. Bound in-flight work, pause or slow producers when possible, and scale only when the actual bottleneck allows. Retention must cover outages plus catch-up and safety margin.
Compare provider service boundaries
| Provider | Analytical engine | Ingestion / streaming | Processing |
|---|---|---|---|
| AWS | Redshift (MPP, columnar) | Kinesis Data Streams; Amazon MSK for managed Kafka | Managed Service for Apache Flink or other stream consumers |
| Azure | Synapse dedicated SQL pool or serverless SQL pool; Fabric Warehouse as a distinct option | Event Hubs with Kafka-compatible protocol where supported | Fabric streaming/Spark or compatible consumers |
| Google Cloud | BigQuery | Pub/Sub or Managed Service for Apache Kafka | Dataflow for Beam pipelines |
Synapse serverless SQL queries lake data; dedicated SQL pool also ingests data into its warehouse. Fabric is a separate capacity and feature model; evaluate migration rather than assuming compatibility. Redshift and BigQuery differ in execution and billing models. Event Hubs Kafka compatibility is not identical to administering a Kafka cluster; check supported clients, APIs and tiers. Kinesis user-managed partition keys map to shards, but other distribution modes may change that relationship. Google Pub/Sub provides subscription and acknowledgment semantics distinct from Kafka consumer offsets. Confirm source/sink support, region, retention, throughput, identity and API versions before selection. Sources: Redshift architecture, Synapse architecture, Fabric Warehouse, Kinesis concepts, Amazon MSK, Event Hubs, Pub/Sub vs Kafka, Dataflow windows.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Warehouse and streaming architectures — knowledge check
Choose the best answer for each offline scenario.
Which system should confirm checkout?
Why can column projection reduce analytical I/O?
Where does Kafka define record ordering?
When can checkpointing alone cause loss?
What grows if arrivals exceed sustainable processing?