Data Integration and the N² Problem
Maslow's Hierarchy of Data Needs
- Base: Capture all relevant data in uniform format
- Middle: Infrastructure for reliable data processing
- Top: Advanced modeling, analytics, prediction
Two Complications That Make This Hard
1. The Event Data Firehose — event data records things that happen (clicks, metrics, IoT) rather than things that are. This data is orders of magnitude larger than traditional OLTP volumes.
2. Explosion of Specialized Data Systems — modern infrastructure includes OLAP, Elasticsearch, Cassandra, Hadoop, graph analysis, Redis, monitoring/metrics. Each system needs data. Naive solution: connect every system to every other system = O(N²) pipeline problem.
Log-Structured Data Flow — The Solution
Architecture:
- Central Log — all organizational data flows through one central log
- Logical Data Sources — each source (application events, DB tables) modeled as its own log
- Subscribers — each downstream system reads the log at its own pace, applies records to its own store, advances its own offset
The log acts as "a kind of messaging system with durability guarantees and strong ordering semantics."
LinkedIn's Journey: From Databus to Kafka
Databus — LinkedIn's first attempt. A CDC service that read Oracle's internal transaction log and let other systems subscribe to row-level changes. It worked, but only solved one connection: Oracle → out.
| Databus | Kafka | |
|---|---|---|
| Who produces | Only Oracle (via CDC) | Any system |
| What it stores | DB row changes | Any message or event |
| Retention | Short cache window | Configurable (days/weeks) |
| Replay | Limited | Full — rewind to any offset |
| Consumer model | Subscription | Consumer groups with independent offsets |
| Throughput | Bounded by Oracle | Designed for millions/sec |
The Breaking Point: Hadoop Project (2008)
LinkedIn tried to move recommendation processing into Hadoop. The plan: a few weeks to move the data, the rest of the time for algorithms. What actually happened: data movement consumed most of the project.
Three things became clear:
- Clean data in a new system creates outsized value. Just having data available in Hadoop made new products possible.
- Pipelines need structural support to be reliable. Define schema upfront; without schema discipline, every new source breaks something.
- Coverage was the actual bottleneck. Only a small fraction of LinkedIn's data was in Hadoop. Getting more in required a custom pipeline for every new source.
The N² → N Transformation
ETL: Why the Traditional Approach Breaks
The point: in the old setup, the warehouse pipeline was the only place data got cleaned, and its only output was the warehouse's format. That format suited the warehouse and nobody else.
Traditional ETL glues two different jobs into that one pipeline:
Job 1 — Cleaning the data: stripping out source-specific weirdness. Without a shared clean format, every consumer handles every source's weirdness on its own.
Job 2 — Reshaping for the warehouse: denormalizing, columnar conversion, pre-aggregation. This is warehouse-specific. Search doesn't need a star schema. A fraud model doesn't need daily rollups.
Job 1 in practice: what "cleaning" fixes
Raw sources are the systems where data is first written. Different teams built them at different times, so each one has its own quirks:
| Source | Quirk |
|---|---|
| Orders DB | Amount stored in paise (50000 means ₹500) |
| Users DB | Dates written as 02/10/26: is that 2 Oct or 10 Feb? |
| Product catalog | Calls the field prod_id; orders call it productId |
| Reviews service | Deleted reviews are still there, marked is_deleted = 1 |
| Inventory service | No database to read, only an API that allows 100 calls a minute |
Cleaning means fixing all of this: converting paise to rupees, using one date format, matching field names, dropping deleted rows and working within that API limit. Every consumer needs this done.
Job 2 in practice: one dish, cooked for the warehouse
Take three clean orders after Job 1:
| Order | User | Product | Amount | City | Time |
|---|---|---|---|---|---|
| 101 | 7 | Shoes | ₹500 | Pune | 2 Oct 10:01 |
| 102 | 9 | Shoes | ₹2,00,000 | Pune | 2 Oct 10:03 |
| 103 | 7 | Watch | ₹800 | Delhi | 2 Oct 11:00 |
Job 2 does three things to these rows:
- Denormalizing: joins in customer and product details so each row is complete. A star schema is the organized form of this: a central fact table (orders) with dimension tables (customer, product, date) around it.
- Columnar conversion: stores data column by column (e.g. Parquet), so "sum all amounts" reads one column instead of every row.
- Pre-aggregation: computes totals ahead of time, so dashboards don't rescan every order.
The output looks like this:
| Day | City | Revenue |
|---|---|---|
| 2 Oct | Pune | ₹2,00,500 |
| 2 Oct | Delhi | ₹800 |
That's perfect for an analyst asking "how much did Pune sell yesterday?" Hand it to anyone else and it's useless:
- Fraud model: needs to see order 102 by itself, at 10:03, and ask why user 9 suddenly spent ₹2 lakh. In the daily table that order has vanished into "Pune ₹2,00,500", and the table arrives the next morning.
- Search: needs one document per product, like "Shoes: in stock, sold 2 times". It has no use for revenue per city or a fact/dimension layout.
What the glue costs: the search team's choice
Search needs data from all 5 sources above. The warehouse team already wrote the cleaning code, but it lives inside their pipeline and only outputs warehouse tables. So search has two bad options:
- Take the warehouse format. Wrong shape, and up to a day late.
- Go back to the raw sources. Connect to all 5 itself (5 extractors), rewrite the same fixes (5 cleaners), and only then build its search documents.
The fraud team faces the same choice and writes the same cleaning code again. With M sources and N consumers you get about M × N pipelines: 5 sources × 3 consumers = 15. When the orders team switches from paise to rupees, every copy breaks separately.
The fix: split the pipeline at the point where data is clean but not yet shaped. Each source is cleaned once and published to the log. Each consumer reads clean data from the log and does only its own Job 2. That's 5 cleaners + 3 transforms = 8 pieces, and the warehouse becomes just one consumer among many.
The same glue causes four problems in day-to-day operations:
| Problem | What it means in practice |
|---|---|
| Batch schedule gates everything | Fraud detection needs data now. ETL runs at 2am. So you wait, or build a second pipeline. |
| One team is a bottleneck | Every system that wants clean data must ask the warehouse team. They can never keep up. |
| Producers don't see the impact | The team writing to the source DB never sees how downstream systems use their data. Schema changes silently break pipelines. |
| Every new system starts from scratch | Search, monitoring, fraud models — each needs clean data and builds its own extraction pipeline. |
The Better Architecture: Split the Two Jobs
- At the source — clean and normalize into canonical format (lossless, reversible)
- In stream processors — enrich, join, sessionize for real-time use
- At the destination — aggregate and reshape for each system's specific query needs
Event-Driven Systems — The Same Pattern in Application Code
The same O(N²) → O(N) argument applies to application code. A job display page that calls five downstream services on every render has five reasons to change — and if the ads team deploys a bad build, the job page goes down.
✗ Before — page calls every downstream service
displayJob(jobId):
renderPage()
hadoop.send(jobId, userId, timestamp)
scraping.countView(ip, jobId)
posterAnalytics.aggregate(jobId)
impressionCap.record(userId, jobId)
recommendations.trackPopularity(jobId)✓ After — publish one event, let consumers subscribe
displayJob(jobId):
renderPage()
log.publish("job-displayed",
{jobId, userId, timestamp, ...})