Architecture

Embedded merchant analytics on Iceberg and a sub-second serving layer

The storage argument is settled. The serving layer is where teams still end up with two copies of the truth and a dashboard that disagrees with the report.

· 6 min read

Apache Iceberg has become a default table format for new lakehouse builds, and streaming engines can write into it with exactly-once semantics. That removes a whole category of separate batch pipeline.

What is not settled is how you serve a merchant-facing dashboard from it at interactive latency.

What Iceberg actually buys you here

Three properties matter for this use case specifically. Snapshot isolation means a reader sees a consistent view while writers commit, so a dashboard never renders a half-written partition. Schema evolution is metadata-only, so adding a column to a transaction table does not rewrite it. And because every commit produces a snapshot, a query can be pinned to one.

That last property is the quiet fix for the oldest argument in payments analytics. When the merchant dashboard and the finance report both read the same snapshot, 'the dashboard disagrees with the report' stops being a data problem and becomes a definition problem — which is tractable.

Hidden partitioning is worth knowing about too: the partition scheme is a property of the table rather than something every query has to restate, so a merchant filtering by date range gets partition pruning without knowing the layout.

The two wrong answers

Query the lake directly and accept seconds. Fine for an analyst, fatal for a dashboard a merchant opens twenty times a day.

Copy into a second store and accept drift. This is the one that produces the 'dashboard disagrees with the settlement report' ticket, and it is unfixable without removing the copy.

Freshness is a budget, not a goal

Streaming into Iceberg trades off commit frequency against file size. Commit every few seconds and you get freshness plus a small-files problem that degrades every subsequent read. Commit every few minutes and reads stay fast while the dashboard lags.

So state the number. A merchant watching a festival sale wants a different freshness from a finance team closing a month, and those can be different tables with different commit cadences rather than one compromise that serves neither.

Whichever you choose, compaction is not optional and it is not free. Schedule it, give it its own capacity, and monitor it — an unmaintained Iceberg table degrades quietly rather than failing.

What works

A serving engine that reads the same tables rather than a copy of them. ClickHouse is a common choice and performs well on high-cardinality drill-down; Druid, Pinot and StarRocks are reasonable alternatives depending on query shape. Vendor benchmarks in this space are generally run by the vendor, so weigh them accordingly.

Picking the engine before you know the query shapes is the most common sequencing mistake. Merchants ask a surprisingly narrow set of questions, and that set determines the answer.

Write the questions down before the evaluation. Top-N by decline reason over a date range, a time series at hourly grain, and a single-transaction lookup by reference are three different access patterns, and an engine that is quick at the first can be mediocre at the third. Benchmark against your own query shapes and your own cardinalities, because merchant counts and SKU counts move the result more than the engine choice does.

Tenancy belongs in the data

Row-level security enforced in the serving layer, with tenancy claims carried in a signed embed token. Not tenancy enforced in application code, where one careless query crosses it.

This is also the part that makes a security review easy. 'A query cannot cross a tenant boundary' is a much stronger statement than 'our code checks the merchant ID'.

Make it testable. A test that issues a query for merchant A with merchant B's token and asserts zero rows is worth more to an auditor than a paragraph of design documentation, and it keeps working after the people who wrote the design have moved on.

A semantic layer, early

Success rate means one thing in the dashboard, another in the monthly report and a third in the incident channel. A shared metric layer is unglamorous and it removes more arguments than any other single piece of this architecture.

The ambiguities are specific and worth settling in writing: does a retried payment count once or twice, does a refund reduce the numerator or the denominator, and is a customer-abandoned checkout a failure. Each is defensible either way. What is not defensible is two systems answering differently and nobody knowing which.

Want this applied to your system?

A 60-minute call with the engineers who wrote this. Bring the architecture, not the brief.