Scrivio Interview library

Storage choices and data pipelines

39 questions in 9 subtopics.

About this topic

Every large design has to decide where data lives and how it moves between systems. The main database, object storage, search indexes, time-series stores, warehouses and real-time analytics engines each solve a different problem, and pipelines built on change data capture, batch jobs and stream processors keep their copies in step. These choices are hard to reverse, and in production they fail in recognisable ways: request limits in object storage, stale search results, wrong percentiles, too many small writes, CDC floods after a migration, jobs that miss their deadline, storage bills that grow faster than the business, and duplicate ids after a clock jump. The questions cover how to choose between the options, how each works inside, the incidents they cause, and the cost, retention and strategy decisions that senior engineers and leaders own.

Choosing SQL or NoSQL for a design

The database for a service is chosen from its access patterns, consistency needs, transaction needs and numbers, not from fashion. Relational databases give joins, constraints and transactions; NoSQL stores give predictable scale for known access patterns. Understand how secondary lookups differ between them, when an overloaded relational database is really a usage problem, what a live migration between stores involves, and how pricing models change the answer.

ConceptFoundations7 min read

Partitioned NoSQL stores answer queries efficiently only by the partition key. A user table in a hash-partitioned key-value store is keyed by user id, and a new login flow must also find users by email and by phone number.

What are the options for the extra lookups, and what consistency and cost does each bring compared with a secondary index in a relational database?
ConceptFoundations7 min read

In a design discussion the database is chosen per service from its access patterns, consistency needs and numbers, not from habit. Three services are being designed: user profiles (10 million users, read-heavy), chat messages (2 billion new messages a day) and a billing ledger.

Which questions decide between a relational database and a NoSQL store, and which store would you start with for each of the three services?
ScenarioIntermediate7 min read

An event ingestion service writes 60,000 rows per second into one PostgreSQL table. WAL volume is 2 TB a day, replicas lag up to 3 minutes at peak, and autovacuum never finishes on the table. The team proposes moving to Cassandra.

How do you decide whether this is a limit of the relational database or of how it is used, and what would you try before a migration?
ScenarioAdvanced6 min read

A 4 TB MongoDB collection of customer accounts serves 8,000 reads and 1,500 writes per second. Reporting and new features need joins and constraints, and leadership approved moving it to PostgreSQL without downtime.

Plan the migration under live traffic: how data is copied and kept in sync, how you verify it, and how the cutover and rollback work.
LeadershipPrincipal7 min read

A product team chose a serverless, pay-per-request NoSQL table for a new feature. After a recommendation job started reading it, the monthly bill for that table went from 8,000 to 120,000 dollars, and finance asks how this can be prevented across the company.

How do you decide between per-request, provisioned and self-managed database pricing models, and what controls do you put in place?

Object and blob storage

Object storage keeps files as whole immutable objects in a flat key space behind an HTTP API, with high durability and low cost per GB. It holds uploads, media, backups and data lake files, while databases keep the metadata. Understand its consistency, request-rate limits per key prefix, direct uploads with presigned URLs, how the database and the bucket drift apart, and why the location of data drives transfer costs.

ConceptFoundations6 min read

Object storage such as Amazon S3 or an S3-compatible store keeps files as whole objects addressed by bucket and key. It is the usual home for uploads, media, backups and data lake files, while databases keep the metadata.

How does object storage differ from block and file storage, which consistency does it give today, and how should a service split data between the object store and its database?
DebuggingIntermediate6 min read

A thumbnail service writes 9,000 objects per second at peak into one bucket under keys such as thumbs/2026-11-13/<id>.jpg. Since a marketing campaign started, about 4 percent of PUTs fail with HTTP 503 Slow Down, and the error rate does not fall when more workers are added.

Explain the cause and how you would fix both the immediate errors and the key design.
DesignIntermediate6 min read

A marketplace receives 2 million photo and video uploads a day from mobile apps, up to 2 GB each. Today uploads pass through Spring Boot pods, which run out of memory and disk at peak.

Design the upload and processing path so files go straight to object storage, are checked before anyone can see them, and are served efficiently.
ScenarioAdvanced6 min read

A document platform stores 1.2 PB in object storage. An inventory report shows that about 40 percent of objects are not referenced by any database row, mostly from failed uploads, deleted documents and abandoned multipart uploads, and storage cost grows 8 percent a month.

How do you clean this up safely, and how do you change the design so the database and the object store stay consistent?
LeadershipPrincipal6 min read

Raw event data, 3 PB, lives in object storage in one cloud region. A new analytics team wants to use another cloud's warehouse and would read about 400 TB a month across clouds; the egress estimate alone is larger than their whole budget.

How do you decide where data should live and where compute should run, and what policy do you set for data that crosses regions or providers?

Search indexes in a design

A search engine such as Elasticsearch or OpenSearch is a derived, eventually consistent copy of data, built for relevance ranking, text analysis and facets. Understand when a design needs one and when database indexes are enough, which screens should read from the database instead, how denormalised documents make some updates expensive, and why a search cluster must never be able to take down a critical path.

ConceptFoundations6 min read

Many designs add a search engine such as Elasticsearch or OpenSearch next to the main database. It is a derived copy of the data, built for text relevance, filters and facets, and kept in sync from the source of truth.

When does a design need a separate search index instead of database indexes, and what does the design give up by adding one?
DebuggingFoundations6 min read

A classifieds site serves both public search and the seller's My listings page from OpenSearch. Sellers who publish a listing often do not see it on My listings for 5 to 40 seconds and publish it again, creating duplicates.

What causes the delay, and how would you change the design of these pages?
ScenarioIntermediate6 min read

A product search index holds one document per SKU, 120 million documents, each with the brand name copied in. A brand rename must update 2 million documents; the update job saturated cluster CPU for 3 hours and search p99 rose from 80 ms to 1.4 seconds.

Why did the rename hurt so much, and how would you design the documents and the update path to cope with such changes?
ScenarioAdvanced6 min read

An e-commerce site added related products from the search cluster to the product page and to the cart. A search cluster outage during an evening peak made product pages and checkout fail for 25 minutes, although orders do not need search at all.

What design mistakes allowed a derived search index to take down checkout, and what do you change?

Time-series and metrics storage

Time-series stores hold timestamped samples per series and compress them heavily by exploiting regular timestamps and slowly changing values. Data is organised in time blocks so old data is dropped cheaply. Understand how compression and chunking work, why percentiles must be stored as histograms or sketches rather than averaged, how chunk sizing affects query planning, and why billing data needs stronger guarantees than operational metrics.

InternalsFoundations6 min read

Time-series data is a stream of timestamped values per series, such as CPU per host every 10 seconds. Dedicated time-series stores keep billions of samples in little space because the data has a very regular shape.

How do time-series stores compress samples so well, and how do they organise data on disk by time?
DebuggingFoundations6 min read

A service runs 40 pods, and each pod exports its own p99 request latency as a gauge. The fleet dashboard averages these gauges and shows a p99 of 50 ms, while user complaints and traces show many requests taking 900 ms.

Why is the dashboard wrong, and how should latency be stored so fleet-wide percentiles are correct?
DebuggingIntermediate7 min read

Sensor readings land in a TimescaleDB hypertable created with a 1-hour chunk interval and kept for 2 years. Simple dashboard queries over the last 30 days now take 2 seconds, and EXPLAIN shows most of the time in planning, not execution.

Explain why chunk sizing caused this and how you would fix it on a live system.
LeadershipPrincipal6 min read

The observability team runs a metrics platform built for dashboards and alerts, with downsampling and occasional sample loss. Product now wants to bill customers on per-minute usage series and proposes reusing the same platform because the data is already there.

How do you decide where billing-grade usage data should live, and what principles do you set for operational versus business time series?

OLTP, OLAP and data warehouses

Transactional databases serve many small reads and writes; warehouses run complex analytical SQL over large history; real-time OLAP engines serve fast aggregations over fresh data at high concurrency. Understand which workload belongs where, how columnar engines expect data to arrive in batches, how dashboards can make warehouse costs explode, and how to reconcile numbers when two analytical pipelines disagree.

ConceptFoundations6 min read

Analytical data now lives in several kinds of systems: the transactional database, a cloud data warehouse, and real-time OLAP engines such as ClickHouse, Apache Druid or Apache Pinot that serve dashboards inside products.

What is each of the three built for, and which would you pick for an internal monthly finance report, a customer-facing dashboard refreshed every few seconds, and a lookup of one order by id?
DebuggingIntermediate6 min read

A product analytics feature writes each click event to ClickHouse as a single-row INSERT, about 5,000 inserts per second from 30 pods. Inserts start failing with errors saying there are too many parts and merges are slower than inserts.

Explain how MergeTree storage leads to this error and how you would fix the ingestion.
ScenarioIntermediate5 min read

A sales dashboard used by 2,000 employees runs eight queries against a cloud warehouse on every page load and auto-refreshes each minute. Warehouse spend for this one dashboard reached 40,000 dollars a month, and the underlying data only changes hourly.

How would you cut the cost without making the dashboard worse?
ScenarioAdvanced6 min read

Revenue for last month is 3 percent higher in the product team's ClickHouse dashboards, fed from Kafka events, than in finance's warehouse, fed by CDC from the orders database. The board pack is due on Friday.

How do you find where the numbers diverge, and what do you change so the two systems stay reconciled?

Change data capture pipelines

Change data capture turns committed database changes into a stream that keeps caches, search indexes, read models and warehouses up to date. Log-based CDC reads the database log and captures every change, including deletes, in commit order. Understand how it compares with polling, triggers and dual writes, how ordering can still break at the sink, why bulk migrations flood the pipeline, and how to detect silent stalls.

ConceptFoundations8 min read

Change data capture (CDC) turns changes in a database into a stream that feeds caches, search indexes and warehouses. A legacy application's database must feed a new search service, and its code cannot be changed.

Compare polling by an updated_at column, database triggers, dual writes and log-based CDC for this case: what each misses and what each costs.
CodingIntermediate7 min read

A CDC pipeline applies row changes from Kafka into a PostgreSQL read model. After the topic was resized from 6 to 24 partitions, some rows in the read model show older values than the source, and the errors persist until the row changes again.

Explain how out-of-order changes reached the sink, and write the SQL upsert that makes the sink ignore stale changes.
ScenarioIntermediate6 min read

A schema migration ran UPDATE orders SET region_code = ... on 300 million rows in one evening. Log-based CDC turned it into 300 million change events; consumer lag reached 6 hours, and the search index and caches served stale orders all night.

What should have been planned before the migration, and how do you recover now?
ScenarioAdvanced6 min read

Twenty CDC pipelines feed search, caches and the warehouse. Last month one connector reported RUNNING while emitting nothing for 5 hours after a database failover, and nobody noticed until customers complained about stale prices.

How do you monitor CDC pipelines so that silent stalls and data loss are detected within minutes?

Batch and stream processing

Batch jobs process bounded data on a schedule; stream processors handle events continuously with state and windows; lambda and kappa architectures combine or unify the two. Understand where each fits, why skewed keys make batch jobs miss deadlines, why exactly-once inside a processor does not cover external sinks, how to reprocess history after a bug, and when fresher data is worth the higher cost.

ConceptFoundations6 min read

Data pipelines process either bounded data sets on a schedule (batch) or unbounded streams continuously. Architectures that mix the two are often described as lambda or kappa architectures.

Compare batch, micro-batch and stream processing, and explain the lambda and kappa architectures with their main weaknesses.
DebuggingIntermediate6 min read

A stream processor reads orders from Kafka, aggregates revenue per merchant per minute and writes rows into PostgreSQL with INSERT. After each deployment, totals in PostgreSQL are about 2 percent higher than the source data.

Explain where the duplicates come from and how to get exactly-once results in an external database.
DebuggingIntermediate6 min read

A nightly batch job that builds customer statements took 2 hours a year ago and now takes 7, missing its 06:00 deadline twice this week. Executor metrics show 199 of 200 tasks finishing in 20 minutes and one task running for 5 hours.

What is the likely cause, how do you get the job back under its deadline, and what longer-term changes would you make?
ScenarioAdvanced6 min read

A bug in a fraud-feature stream job produced wrong features for 3 weeks before anyone noticed. Kafka keeps the input topic for 7 days, the fix is ready, and the fraud models need corrected features for the whole period.

How do you reprocess history the log no longer holds, while the live job keeps running, and what do you change so the next fix is easier?
LeadershipPrincipal6 min read

After a competitor launched instant insights, the executive team asks for all reports and data products to become real-time. Today almost everything runs as nightly or hourly batch jobs on a warehouse, and the data engineering team has no streaming experience.

How do you respond, and how do you decide which pipelines move to streaming?

Data retention, archival and tiering

Retention decides how long data is kept; tiering moves it to cheaper storage as it ages; archival keeps it for rare access or legal needs. Colder tiers cost less per GB but charge for retrieval, transitions and minimum durations. Understand the tiers and their hidden costs, why small objects defeat lifecycle rules, how to tier a live database while still allowing edits and deletes, and how legal holds interact with retention and erasure.

ConceptFoundations6 min read

Storage is offered in tiers that trade access speed for price, from hot SSD-backed databases to archive classes in object storage that take hours to restore. Lifecycle rules move data between tiers by age.

Describe typical storage tiers, what each costs and how fast it can be read, and the hidden charges to check before moving data to a colder tier.
ScenarioIntermediate7 min read

A messaging product stores 6 billion small attachments and previews, averaging 20 KB, in standard object storage. A lifecycle rule to move objects older than 30 days to an archive class was enabled, and the next bill went up instead of down.

Explain why, and design a tiering approach that actually saves money for this data.
DesignAdvanced7 min read

A chat platform keeps all messages in a Cassandra cluster whose disks are at 80 percent. Analysis shows 90 percent of reads touch messages younger than 30 days, but users can scroll back years and can edit or delete old messages.

Design tiering so old messages move to cheaper storage, and explain how reads, edits and deletes work on the cold tier.
LeadershipPrincipal6 min read

Legal places a litigation hold on three years of customer communications. Lifecycle rules delete such data after 1 year, privacy erasure requests keep arriving, and some of the data sits in archive tiers.

As the engineering leader, how do you reconcile the hold with retention and erasure, and what controls do you build so this is routine next time?

Unique ID generation

Large systems need unique identifiers generated at high rates, often without a central database round trip. Common schemes are database sequences, segment allocation from an id service, UUIDs and Snowflake-style 64-bit ids that combine time, worker id and sequence. Understand the bit layouts and their limits, what clock jumps and duplicate worker ids do, what segment allocation gives up, and why ids ordered by creation time can make cursors miss data.

CodingFoundations6 min read

Snowflake-style ids are 64-bit numbers generated without coordination on each node. They combine a timestamp, a worker id and a per-millisecond sequence, so they are unique and roughly sorted by time.

Describe the usual bit layout and its limits, and outline in Java the nextId() method of such a generator.
DebuggingIntermediate7 min read

An order service generates Snowflake-style ids on 24 pods. One night, inserts failed with duplicate key errors for 40 seconds. Logs show an NTP correction stepped one node's clock back by 2 seconds, and two pods report the same worker id derived from a hash of the pod name.

Explain both causes and how you would make id generation safe.
DesignIntermediate6 min read

A payments platform hands out ids from one database sequence through an id service. At 50,000 ids per second the sequence database became the bottleneck, and every id costs a network round trip.

Design an id service that scales and keeps ids roughly increasing, and explain what it gives up.
ScenarioAdvanced6 min read

An activity feed API pages with WHERE id > :lastSeenId ORDER BY id using Snowflake-style ids. Partners syncing the feed report that about 0.05 percent of events never reach them, although the events are in the database.

Explain how events can be skipped, and redesign the feed so a cursor never misses a committed event.