Skip to main content

System Design Interview Questions

Every question has a short model answer and a link to the lesson example that shows it in code. Levels: F = Fresher (0-2 yrs), M = Mid (3-5 yrs), S = Senior (6-9 yrs), A = Architect / Lead (10+ yrs).

Non-functional requirements

AWhich non-functional requirements change when the SMS goes from one school to 1,000 schools?design

Data isolation becomes critical: one school must never see another's data. Load peaks multiply, for example every school taking attendance between 8 and 9 AM. Availability, backups and restore per school, deployments without downtime, security reviews, and the cost per school all become explicit requirements with numbers.

How to answer:

List the categories (isolation, scalability, availability, recoverability, security, cost) and give one SMS number for each, such as "attendance save under 1 second at 8 AM for 1,000 schools". Then name the design consequence: a tenant column or database per school, caching, and horizontal scaling, and the trade-off between shared and separate databases (cost against isolation).

Reporting

AHow would you separate day-to-day school operations from heavy reporting when the SMS serves 1,000 schools?design

Keep the normalized transactional database for daily work such as attendance and fees. Send reporting to a separate copy built for reading: a read replica for simple reports, or a data warehouse with denormalized tables refreshed on a schedule. Heavy reports then never slow down a teacher saving attendance.

How to answer:

Name the two workloads (many small writes vs few large reads) and why one design cannot serve both well. Describe the options from cheapest to most powerful: indexed views, read replicas, then a warehouse. State the trade-off: reports become slightly delayed (eventual consistency) in exchange for fast, safe daily operations.

Multi-tenant SaaS

FWhat is a SaaS product, and what is a tenant?concept

SaaS (software as a service) means one company runs one system and many customers use it over the internet, usually for a monthly fee. Each customer is a tenant: it shares the system with the others but must only ever see its own data. In the SMS, each school is a tenant.

FWhat is the difference between functional and non-functional requirements? Give an example of each.concept

Functional requirements say what the system does, such as "a school admin can add a teacher". Non-functional requirements say how well it does it, such as "95% of requests answer in under 300 ms" or "99.9% availability". Non-functional ones need numbers, or nobody can test them.

FWhat is an architecture decision record (ADR)?concept

A short document, kept next to the code, that records one important decision: the context, the options considered, the choice, and its consequences. It explains later why the system looks the way it does, so the same debate does not have to be repeated.

MCompare shared database, schema per tenant, and database per tenant.concept

Shared database with a tenant column: one schema, cheapest, simplest upgrades, but a missed filter leaks data and one busy tenant can slow others. Schema per tenant: better separation, but every table is copied per tenant. Database per tenant: strongest isolation and easy per-tenant restore, but many databases to upgrade, back up, monitor and pay for, and cross-tenant reports are hard.

MHow would you estimate the database size of a system before it is built?scenario

Measure bytes per row on real or realistic sample data (data plus every index, for example from sys.allocation_units or sys.dm_db_index_physical_stats), then multiply by rows per year from written assumptions: tenants, users, events per user. Keep the assumptions in one place so the estimate can be rerun. For the SMS: about 100 bytes per attendance row, 176 million rows a year, about 19 GB.

MWhy design for the peak hour instead of the average load?concept

Users judge the system at its busiest moment. In the SMS, morning attendance is about 11 requests a second but results day is about 444, 40 times more; a system sized for the average would fail exactly when parents need it. Size compute, connection pools and caches for the peak, and use the quiet hours for batch work.

SYour company sold its app to each new customer by copying the code and database. What problems follow, and how do you fix them?scenario

Each copy drifts: fixes must be repeated per customer, some copies miss security fixes, and upgrades become projects. Move to one multi-tenant system: one code base, one schema with a tenant id, per-tenant settings instead of per-tenant code, and a migration plan that moves customers one by one with their data verified.

How to answer:

Name the operational and security costs of copies, then describe the target design and a safe migration path.

SYou chose a shared database with a SchoolId column. What risks does that bring, and how do you control them?design

Data leaks from a missing filter, and noisy neighbours. Control leaks with two layers: tenant filtering in every repository and database-level row-level security, plus tests that try to read another tenant's data. Control noisy neighbours with indexes that start with the tenant id, per-tenant rate limits, and background or serialized heavy jobs. Keep the option to move a very large tenant to its own database later.

How to answer:

Name each risk with a concrete failure, then a preventive control, a detective control, and an escape hatch.

ADesign the tenancy model for an education platform expected to grow from 50 to 10,000 schools.design

Start with a shared database and a tenant id for cost and simple operations, with isolation enforced in the application and the database. Design for movement: tenant id in every key and index, a tenant catalogue that maps each tenant to a database, and tooling to move one tenant. As it grows, shard tenants across several databases, and give the largest or most regulated tenants their own database, all behind the same code.

How to answer:

Show how the model evolves with scale and cost, covering isolation, routing through a tenant catalogue, sharding, per-tenant exceptions, and operations such as upgrades and backups.