call(back)

Evaluating a Move From MySQL to MongoDB

Your team proposes migrating a service's data from MySQL to MongoDB. How do you evaluate the proposal, and how would you defend the decision afterwards?

Answer out loud in under a minute: a definition, one concrete example, and one pitfall or trade-off.

Hints

Hint 1

Ask what problem the migration is meant to solve and whether the current database could solve it with less risk.

Solution

Show the approach

The short version

Start from the workload, not the products. Write down the main read and write paths, their rates and latency targets, how data is related, how the schema changes, and where the current system hurts. MongoDB fits when records are self-contained documents read and written whole, the schema varies or changes often, and horizontal sharding on a natural key is needed. MySQL fits when the data is relational with joins across entities, multi-row transactions and constraints carry business rules, and queries are varied. Then check whether the pain has a cheaper fix: an index, a read replica, a cache, partitioning, or a JSON column.

Example

A product catalogue where each category has different attributes, read by id and written as a whole, moved cleanly: one document per product replaced a dozen joined tables and p99 read latency fell. An order system with inventory, payments and refunds did not: its invariants lived in transactions and foreign keys that the application would have had to re-implement. A defensible answer quotes the before and after: query latency, write throughput, storage, operational incidents.

Pitfall

The migration itself is the risk: dual writes or change-data capture, backfill, verification by comparing reads, a cutover with a rollback path. A flexible schema moves validation into application code, and a poorly chosen shard key is hard to change. Listing generic traits of SQL and NoSQL, without this workload and a measured outcome, is the answer interviewers reject.

Assistant

Sign in to use the assistant — ask what the problem means, get a hint when you're stuck, or have your current work reviewed. Conversations save to your account.

Asked at