General System Design Fundamentals – R.A.I.L.S Framework

Although FrontendLead.com is built to help people prepare for frontend system design interviews and everything related to frontend design, this article shifts gears. Here, we’ll focus specifically on backend system design fundamentals.
Why, you might be asking?
Well, it’s not uncommon for frontend engineers to interview for full-stack roles. And in full-stack interviews, expectations have changed. You’re not just going to be asked a frontend system design question anymore – chances are, you’ll be expected to reason about the backend too.
While we already have several deep-dive articles on this platform covering frontend system design prep, there has been a noticeable gap in covering backend fundamentals. That’s precisely what this guide aims to address.
If your interview is only for the frontend, please skip this article.
Here’s the table of contents we’ll cover:
-
System Design Foundations – R.A.I.L.S Framework Explained
-
Core System Design Concepts
-
Databases
-
Caching
-
Asynchronous Processing
-
Load Balancing and Scalability
-
Rate Limiting and Throttling
-
Fault Tolerance and Reliability
-
Observability
-
Infrastructure and Deployment
-
Security
-
Practice System Design Scenarios
We use the R.A.D.I.O framework for front-end interviews; however, it’s not 1:1 applicable for back-end interviews.
R.A.I.L.S Framework
RAILS is a helpful mental model for structuring full-stack and backend interviews, but it’s not a strict checklist you need to follow in order. In interviews, the sections are fluid and often overlap.
If you’re designing a traffic-heavy system, you may start discussing scaling and bottlenecks before you lock down the interface. If you’re building a user-facing API, you might sketch out the contract first, then figure out how to support it at scale.
The framework is flexible; the goal is to make sure you cover all five areas thoughtfully:
| Letter | What it Covers | Why It Matters |
|---|---|---|
| R | Requirements | Clarifies what the system needs to do and under what constraints |
| A | Architecture | Helps you break the system into logical, scalable components |
| I | Interfaces | Defines how components talk to each other and external clients |
| L | Latency, Load, and Limits | Grounds your design in real-world performance, scale, and cost |
| S | Storage and Scaling | Ensures your data model and infrastructure can grow with demand |
Use it as a checklist, not a script. You can start with R and A to set the foundation, but from there, let the conversation guide whether you go into load, scaling, or APIs next. Ensure you touch on all five areas by the time you’re done.
Keep These 3 Principles in Mind
-
Always clarify requirements first. Don’t jump into solutions without understanding scale and constraints.
-
Don’t just name technologies, justify them. Saying “Redis” is fine, but explain why it makes sense for your use case.
-
Talk about tradeoffs. There’s rarely one perfect solution. Show that you’re aware of pros and cons.
P: Problem and Requirements
This is the first thing you should do in any backend or full-stack system design interview. Before discussing architecture or technology, you need to clearly define what you’re building, the constraints, and what the system needs to do.
Why this step matters
If you skip this, there’s a good chance you’ll build something that doesn’t solve the real problem or that can’t scale. It also gives the impression that you’re jumping into implementation without understanding the bigger picture. Starting with precise requirements shows thoughtfulness and helps anchor your design decisions later.
What to Cover
| Area | What to Ask or Do |
|---|---|
| Core Use Case | What is the system supposed to do? Summarize it in one sentence. |
| Users and Actors | Who is using the system? Are there admins, regular users, services, or third parties? |
| Scale | How many users, requests per second, or files per day are expected? Ask for numbers. |
| Latency Expectations | Is this a real-time system, or is some delay acceptable? |
| Availability Requirements | Is 24/7 uptime expected? Can parts of the system go down without breaking everything? |
| Read vs Write Patterns | Will this be a write-heavy system (like chat) or read-heavy (like a feed)? |
| Security or Compliance | Are we handling sensitive data like passwords, payments, or personal info? |
| Non-Functional Requirements | What’s expected regarding reliability, scalability, maintainability, and cost? |
Walkthrough Example: Real-Time Facebook News Feed
Prompt: Design a Facebook-style news feed that updates in real time.
You might start the interview like this:
Let me make sure I understand what we’re building. The goal is to allow users to see a real-time feed of posts from people or pages they follow. These posts might include text, images, and videos.
Before diving into architecture, I’d want to clarify a few things:
-
What’s the expected user base? Are we supporting millions or billions of users?
-
Are posts globally visible, or do we need privacy filters based on friends or groups?
-
Should the feed update in real time, or is it okay if there’s a slight delay?
-
Will the UI use infinite scroll with pagination, or should we preload content?
-
Should posts appear in strict reverse-chronological order, or does engagement rank them?
-
Do we need to support media uploads? If so, what’s the expected max file size?
-
Will the same post be shown to multiple users (fan-out), or is each feed fully personalized?
-
Are there any constraints around mobile performance or users on slow connections?
Tips for this step
-
Always ask about scale. Designing for 1,000 users is not the same as designing for 100 million.
-
Clarify business logic. Don’t assume things like privacy settings or sharing rules – ask.
-
Write down your assumptions before moving forward. If you’re unsure, make it explicit.
-
Use numbers. Think out loud: “If each user posts 10 times a day, and we have 10 million users, that’s 100 million new posts per day.”
A: Architecture
Once the requirements are precise, the next step is to break the system into high-level components. This is where you start diagramming and explaining how the system works behind the scenes. You’re not expected to cover every technical detail yet, but you should show that you understand how to organize the system into clean, scalable, and maintainable parts.
This is usually the part of the interview where you start drawing boxes. You can verbally walk the interviewer through the architecture while referencing a shared doc or whiteboard if you’re remote.
What to Cover
| Area | What to Think Through |
|---|---|
| Services | What services are involved? For example, post creation, feed generation, user service, and media service |
| Communication | Are services communicating via REST, gRPC, or queues? When do you need synchronous vs asynchronous communication? |
| Data Flow | What happens when a user creates a post? How does it reach their friends? How is the feed built? |
| Caching | What data should be cached? Feed results? Post metadata? Where is the cache placed? |
| External Systems | Are we using a CDN, media storage (like S3), analytics, or third-party auth? |
| Client Integration | How does the frontend fetch the feed? Is it polling? Using GraphQL? WebSockets for real-time updates? |
Example: Real-Time Facebook News Feed
Let’s say you’re asked to design a Facebook-style feed. At a high level, you might break it down into these components:
-
Client App: Sends a request to fetch the news feed
-
API Gateway: Routes traffic to backend services
-
Feed Service: Responsible for assembling and returning a user’s feed
-
Post Service: Handles creation and storage of new posts
-
User Graph Service: Tracks friendships and following relationships
-
Media Service: Stores and serves images or video content
-
Cache Layer (Redis or Memcached): Stores hot feeds or user-specific timelines
-
Database: Stores post data, user metadata, and feed indexes
-
Queue + Worker System: For fan-out (e.g., distributing new posts to followers’ feeds)
-
CDN: Delivers static assets like images and videos quickly
The typical flow might look like this:
-
A user opens the app and triggers a request to
GET /feed -
The request goes to the API Gateway, which forwards it to the Feed Service
-
The Feed Service checks Redis to see if a recent feed exists
-
If not, it pulls data from the Post Service, the User Graph Service, and the Database to build the feed
-
The resulting feed is cached and returned to the client
-
When a user creates a post, it goes through the Post Service, which stores the data and sends a message to a Queue
-
A Worker picks it up and fans out the post to all relevant followers’ cached feeds
-
Media is uploaded separately to the Media Service and delivered via CDN
Tips for This Step
-
Use boxes and arrows to walk through the system visually
-
Focus on how components talk to each other, and what each is responsible for
-
Show a clear separation of concerns between services
-
Start simple, then layer in more complexity (e.g., real-time updates, failover)
Data Flow
After laying out the high-level architecture, you should next walk through what actually happens in the system. This means explaining how data flows from the client to the backend, through different services, and back to the user.
You don’t need to cover every edge case here, but you should clearly explain the core flow for the main use cases, in a news feed system, which includes post creation, feed generation, and feed delivery.
What to Cover
| Scenario | What to Walk Through |
|---|---|
| Post Creation | How is a new post submitted, validated, stored, and distributed? |
| Feed Generation | How is the feed built for each user? When is it built — on write or on read? |
| Real-Time Updates | Are posts pushed to users using WebSockets, or do they refresh manually or poll periodically? |
| Media Upload | If a post has an image or video, how is it uploaded and linked to the post? |
| Analytics or Metrics | Are you logging views, clicks, or interactions? Where does that data go? |
Example: Real-Time Facebook News Feed
Let’s walk through what happens when a user creates a new post.
-
The user writes a post and hits “Publish” in the app
-
The frontend sends a
POST /postrequest to the backend, including text, metadata, and possibly a media link -
The Post Service validates and stores the post in the database
-
If the post includes media, it was likely uploaded separately using a presigned URL before the post request
-
The Post Service sends a message to a Queue (e.g., Kafka, SQS) indicating a new post was created
-
A Fan-out Worker picks up the message and updates the feed entries for all followers of the user
-
If using a fan-out-on-write strategy, the system writes the new post ID to each follower’s feed in Redis or a feed table
-
If using fan-out-on-read, nothing is written yet — the post will be pulled during the following feed query
-
-
When a follower opens the app and triggers a
GET /feedthe Feed Service fetches their personalized feed-
It first checks Redis or another cache
-
If a cache miss, it queries the database or joins across tables to generate the feed.
-
It may also rank posts based on engagement, recency, or relevance
-
-
The result is returned to the client, which renders it in the UI
Notes on Fan-out Strategies
There are two main ways to handle distributing posts:
-
Fan-out on write: You push the post to all followers’ feeds as soon as it’s created. This gives fast reads but a heavy write load.
-
Fan-out on read: You keep the posts in one place and fetch them dynamically when a user requests their feed. This keeps writes light but puts more load on reads.
Your choice depends on the scale, read-to-write ratio, and personalization complexity.
I: Interfaces
Now that you’ve mapped out how data flows through the system, the next step is to define the key interfaces. This includes the public-facing APIs that the client uses and internal service-to-service communication. You don’t need to write full API specs, but you should clearly describe the essential endpoints and how different components communicate.
What to Cover
| Type | What to Define |
|---|---|
| External APIs | What does the frontend call? What does each endpoint do? What is returned? |
| Internal APIs | How do services talk to each other? What data gets passed? Is it synchronous or asynchronous? |
| Auth Boundaries | Which endpoints require authentication? Are there role-based permissions? |
| Media Handling | Is media uploaded directly to object storage? If so, how is that coordinated with the backend? |
| Real-Time Interfaces | If using WebSockets or long polling, what does the handshake or data push look like? |
Example: Real-Time Facebook News Feed
Here are some of the primary interfaces you might include for a basic version of this system.
External APIs
| Endpoint | Method | Description |
|---|---|---|
/feed |
GET | Returns a user’s news feed, possibly paginated |
/post |
POST | Creates a new post with text and optional media reference |
/upload-url |
POST | Returns a presigned URL to upload media directly to storage |
/media/:id |
GET | Streams or downloads the media file if the user has access |
Depending on how auth is implemented, each of these endpoints would be authenticated using a session token, cookie, or bearer token.
Internal Interfaces
| Service | Method | Description |
|---|---|---|
| Post Service → Feed Worker | Queue message | Sends new post event to feed processor for fan-out |
| Feed Service → User Graph Service | RPC or REST | Fetches a list of followers or friends |
| Feed Service → Post Service | Internal call | Retrieves post details for a set of post IDs |
| Feed Service → Cache Layer | Read/Write | Gets or updates the user’s cached feed |
| Media Service → CDN | N/A | Serves media through an edge network for performance |
You can also include real-time communication if the system pushes new posts to clients:
-
WebSocket connection is opened from the client
-
Server pushes new post IDs when relevant
-
Client fetches the full post via
GET /post/:idor batch endpoint
Tips for Interfaces
-
Be clear about what’s public vs internal
-
Include pagination, filtering, or cursor-based navigation where needed
-
Talk about rate limiting, retries, and fallback behavior if an internal service is down
-
Explain auth rules: “Users can only access their feed and posts from users they follow.”
L: Latency, Load, and Limits
Once your system is architected and the interfaces are in place, you need to understand how much traffic you expect, how fast things need to be, and where bottlenecks might appear. This is where you do some quick math and discuss how your system holds up under real-world pressure.
You don’t need perfect numbers. What matters is showing that you can reason through scale, performance expectations, and where limits will start to appear.
What to Cover
| Area | What to Estimate or Discuss |
|---|---|
| Daily and Peak Traffic | How many users? How many reads and writes per second? |
| Data Size | How much data is being created and stored per day? |
| Latency Expectations | How fast should the feed load? Is 100ms good enough? Is 1 second too slow? |
| Read/Write Ratio | Are there more reads than writes? By how much? |
| Bottlenecks | Where is the system likely to slow down or fail under heavy load? |
| Cost Awareness | Are there any high-cost operations or external services to be cautious about? |
Example: Real-Time Facebook News Feed
Let’s say you’re building a scaled-down version of Facebook’s feed for 10 million monthly active users. Here’s how you might talk through some quick load estimates.
Upload and Post Volume
-
10 million users
-
20% post something each day → 2 million posts per day
-
Each post averages 1KB of metadata → ~2GB of metadata per day
-
Peak posting window might be 50,000 posts per hour → ~14 posts per second
Feed Read Volume
-
Let’s say each user opens the app 3 times a day
-
10 million users × 3 = 30 million feed requests per day
-
That’s about 350 feed reads per second on average
-
Realistically, traffic is spiky, so peak could be 3–5x average
-
Peak feed reads: up to 1,500 per second
Latency Expectations
-
Feed requests should respond in under 300ms for a good user experience
-
Media loads separately via CDN, which offloads that pressure from the backend
-
Writes (creating a post) can take slightly longer if asynchronous fan-out is used
Bottlenecks to Watch For
-
Fan-out worker queue might fall behind if post volume spikes
-
Feed cache misses could cause slower reads and more DB load
-
If the followers list is large, building personalized feeds on-the-fly could be expensive
-
Redis memory limits if you’re caching feeds per user
Cost Awareness
-
Storing full feeds for each user might grow quickly
-
Using a CDN for media reduces cost and latency
-
Long-term storage of posts and media may require lifecycle rules or archiving.
This section shows the interviewer you’re not just designing systems in a vacuum. You’re thinking about the real-world numbers, performance expectations, and infrastructure pressure points that will matter in production.
S: Storage and Scaling
Now that you’ve walked through architecture, data flow, interfaces, and performance, it’s time to talk about where the data lives and how your system scales as traffic grows. You discuss database choices, schema design, replication, sharding, and caching strategies here.
You don’t need to be overly detailed, but you should be thoughtful about how your data is stored, queried, and scaled over time.
What to Cover
| Area | What to Think Through |
|---|---|
| Data Models | What does a post look like? A feed entry? A user relationship? |
| Database Type | Are you using SQL, NoSQL, or both? Why? |
| Indexing | What indexes will improve performance for your access patterns? |
| Caching | What gets cached, and where? Redis, Memcached, or something else? |
| Replication | Are you using read replicas? How do you handle failover? |
| Sharding | What’s your strategy for horizontal scaling as data volume grows? |
| Archival | Do you expire or archive old content to save cost and improve performance? |
Example: Real-Time Facebook News Feed
Let’s start with some of the core models.
Post Table
| Column | Type | Description |
|---|---|---|
id |
UUID | Unique post ID |
author_id |
UUID | ID of the user who posted |
content |
Text | The post content |
created_at |
Timestamp | When the post was created |
media_url |
String | Optional media file path |
visibility |
Enum/String | public, friends-only, private |
Feed Storage
You have two options here:
-
Fan-out on write
Store a separate feed per user with a list of post IDs. This speeds up reads but requires more writes during post creation. -
Fan-out on read
Store posts in a single global table and build each feed on the fly when a user opens the app. This keeps writes light but increases read complexity and latency.
In many systems, a hybrid approach is used. For example, you might fan out to a limited number of followers for real-time delivery and use on-demand fetch for the rest.
Database Choices
-
Post and feed metadata: PostgreSQL or DynamoDB
-
User relationships: Graph database (like Neo4j) or key-value store, depending on complexity
-
Feed cache: Redis with TTL to reduce read load
-
Media storage: S3 or equivalent object storage
-
Analytics: Stream data to a logging or analytics pipeline (e.g,. BigQuery, ClickHouse)
Scaling Strategy
-
Use horizontal partitioning (sharding) by user ID for large tables
-
Add read replicas to handle higher read throughput
-
Use the cache-aside pattern for hot feeds and post metadata
-
Apply S3 lifecycle rules to expire old media
-
Break services into microservices as traffic grows
-
Deploy workers in autoscaling groups or use serverless (e.g., AWS Lambda) for fan-out jobs
At this point, you’ve covered everything the interviewer needs to see. You’ve shown that you can design a system that meets real-world requirements, scales under load, handles failure, and balances performance with cost.
To summarize the foundations, here is a table below:
| Topic | Subtopics | How to Prepare (What You Need to Know) |
| Design Process | Requirement gathering, defining scope, functional vs non-functional requirements | Practice asking clarifying questions, identifying core features vs stretch goals, and defining success metrics. Be ready to break down vague prompts into concrete components. |
| API Contracts | API schema design, input/output validation, OpenAPI/Swagger | Know how to design clean RESTful APIs. Understand idempotency, versioning, request validation, and standard status codes. Be familiar with documenting APIs using Swagger/OpenAPI. |
| Estimations | QPS, storage size, bandwidth, latency SLAs | Learn back-of-the-envelope calculations: requests/day → QPS, data size per item → monthly/yearly storage. Understand how to estimate SLA targets and their impact on design. |
| Tradeoffs | Latency vs consistency, availability vs cost, speed vs durability | Explain and justify tradeoffs (e.g., when you’d favor availability over consistency). Study CAP theorem and when to denormalize or cache data to meet performance targets. |
Core System Design Concepts
Before exploring individual technologies or patterns, it’s essential to understand the fundamental concepts that apply to almost every system design problem. You’ll use these mental tools to reason through tradeoffs, understand bottlenecks, and make architecture decisions under constraints.
| Topic | Subtopics |
| API Design | REST vs GraphQL vs gRPC, endpoint naming, versioning, idempotency, pagination |
| Authentication | JWT, session-based, OAuth2, OpenID Connect, refresh tokens |
| Authorization | RBAC (role-based), ABAC (attribute-based), permission hierarchies |
| Hashing | Hash functions (SHA256, MD5), consistent hashing, hash maps, and deduplication |
| Data Modeling | ER diagrams, normalization/denormalization, data ownership |
| Indexing | B-tree, hash index, composite index, covering index, full-text search |
API Design
Good API design is about creating consistent, scalable, and easy-to-use interfaces. In system design interviews, especially for full-stack roles, this is where you show that you know how to design APIs that hold up in production, evolve cleanly over time, and support real product needs.
You don’t need to write out exact specs, but you should be able to describe the key endpoints, how they behave, and why they’re structured the way they are.
REST vs GraphQL vs gRPC
-
REST is the default choice for most public-facing APIs. It’s simple, stateless, and built on standard HTTP verbs and conventions.
-
GraphQL is useful when clients need flexibility or want to reduce overfetching. Implementing and cache is more complex but powerful for UI-driven apps.
-
gRPC is best for fast, efficient internal service-to-service communication. It uses binary encoding and strongly typed contracts but isn’t browser-native.
Use REST when simplicity and clarity matter. Use gRPC for internal systems that prioritize speed and strict contracts. Use GraphQL when frontend flexibility is worth the tradeoff in complexity.
Endpoint Naming
Follow RESTful conventions:
-
GET /users→ list users -
GET /users/:id→ get one user -
POST /posts→ create a post -
GET /posts/:id/comments→ nested resource
Use plural nouns. Keep everything lowercase. Avoid putting actions in the URL — let HTTP methods define behavior.
Versioning
Always assume your API will change. Add versioning from day one.
-
Use path-based versioning like
/v1/feed -
Avoid breaking changes by introducing
/v2when needed
You can also version through headers or query params, but URL versioning is the most straightforward. It keeps things explicit and avoids surprises.
Idempotency
APIs should be safe to retry without unintended side effects.
-
POST is usually not idempotent, but can be made idempotent using an idempotency key
-
PUT, PATCH, and DELETE should be idempotent by default
Idempotency is critical for things like payments, uploads, and any action that might get retried after a failure.
Pagination
Always paginate list endpoints. Avoid returning massive payloads.
-
Use
limitandoffsetfor simple cases -
Use cursor-based pagination for better performance and deep scrolling
Cursor-based pagination scales better because it avoids large OFFSET scans on the database. It’s essential when dealing with feeds, timelines, or logs.
Example: News Feed API
For a Facebook-style feed, here’s a typical API structure:
-
GET /feed?limit=20&after=post_123→ fetch a feed page -
POST /post→ create a new post -
GET /post/:id→ fetch a post -
DELETE /post/:id→ delete a post -
POST /upload-url→ get a presigned S3 upload link
You might use REST for public APIs, and gRPC for internal services (e.g. feed service calling the user graph or media service). GraphQL is optional — useful for complex UIs, but harder to maintain.
What Interviewers Look For
-
Are your APIs predictable, consistent, and versioned?
-
Can they handle retries safely?
-
Do you plan for large datasets and paginated results?
-
Do you understand when different API styles make sense?
Authentication
Authentication is how your system verifies who a user is. In full-stack and backend system design interviews, you must know how user identity is handled at the API layer, what tokens or credentials are exchanged, and how long sessions remain valid.
You don’t need to implement full auth flows, but you should understand the common patterns, when to use them, and what tradeoffs come with each approach.
JWT (JSON Web Tokens)
JWTs are a stateless way to represent user identity. The server encodes user data into a signed token and sends it to the client. The client returns the token with every request, and the server verifies its signature.
Pros
-
Stateless and scalable (no need to store sessions in memory or database)
-
Suitable for APIs and microservices
Cons
-
Revocation is hard — once issued, tokens are valid until expiration
-
Tokens can get large and may contain sensitive data if not designed carefully
Use JWTs when scalability matters; session invalidation isn’t a hard requirement.
Session-Based Authentication
In session-based auth, the server creates a session and stores it (in memory, Redis, or DB). The client gets a session cookie and sends it with each request.
Pros
-
Easy to revoke or expire sessions
-
Works well with traditional web apps
Cons
-
Doesn’t scale easily without sticky sessions or distributed session stores
-
Requires server-side storage
Use session-based auth for monoliths, admin panels, or systems with strong revocation needs.
OAuth2
OAuth2 is a protocol that lets users grant access to third-party apps without giving them passwords. It’s used to log in via Google, Facebook, and GitHub.
Your system acts as the resource server, and the third party acts as the authorization server.
Grant types you should know:
-
Authorization Code (used in web apps)
-
Client Credentials (for server-to-server APIs)
-
Password (deprecated)
-
Refresh Token Flow (to renew access without login)
You should know when and why to use each.
OpenID Connect
OpenID Connect is a layer on top of OAuth 2 that adds identity information. It allows “Login with Google” to return profile data like email and name, not just authorization tokens.
If you hear OIDC, think: OAuth2 + user identity.
Refresh Tokens
Access tokens should expire quickly (e.g., 15 minutes). A refresh token allows the client to request a new access token without requiring the user to log in again.
Best practice:
-
Access token in memory or an HTTP-only cookie
-
The refresh token is stored securely and rotated often
-
Always have a way to revoke refresh tokens (e.g., on logout)
What Interviewers Look For
-
Do you understand the difference between authentication and authorization?
-
Can you choose the right authentication strategy for different types of systems?
-
Do you know the tradeoffs between JWT and sessions?
-
Are you aware of security best practices like token expiration and rotation?
Authorization
Once a user is authenticated, the next question is: what are they allowed to do? That’s where authorization comes in. It controls access to actions, resources, and data based on roles, attributes, or context.
In a system design interview, you should be able to explain how you would restrict access to specific endpoints or features, and how the system enforces those rules efficiently.
RBAC (Role-Based Access Control)
RBAC is the most common authorization model. Users are assigned roles (like admin, moderator, member), and roles are granted permissions.
Example:
-
An
admincan delete any post -
A
membercan only edit their own post
Pros
-
Simple to reason about
-
Easy to audit and maintain
Cons
-
Doesn’t work well for highly dynamic or contextual access rules
Use RBAC when roles and permissions are well defined and don’t change frequently.
ABAC (Attribute-Based Access Control)
ABAC uses attributes — not just roles — to determine permissions. This includes user properties (like department, location), resource properties (like owner, visibility), and context (like time of day or request source).
Example:
-
A user can access a file if
user.department == file.department -
A student can only view assignments for their enrolled course
Pros
-
More flexible and fine-grained than RBAC
-
Great for complex organizations or multi-tenant systems
Cons
-
More complex to implement and test
-
Harder to audit without good tooling
Use ABAC when access decisions depend on more than just a role — especially in enterprise or B2B apps.
Permission Hierarchies
Sometimes, you need more control than RBAC or ABAC provides on their own. This is where permission hierarchies come in.
You might define permission levels like:
-
read -
write -
delete -
admin
Then assign these permissions per resource (e.g., per project, team, post).
This is common in collaboration platforms like Google Docs, GitHub, or Notion, where one user might have full access to one document and read-only access to another.
Tips:
-
Store permissions in a normalized table (e.g.,
user_id,resource_id,permission) -
Cache results for faster access checks
-
Deny by default — allow only what’s explicitly granted
What Interviewers Look For
-
Can you design a system that enforces secure access to data?
-
Do you understand the difference between RBAC and ABAC?
-
Can you scale permission checks across millions of users and resources?
-
Have you thought about revocation, caching, and audit logging?
Hashing
Hashing is a core concept in backend system design. It’s used everywhere — from securing data to distributing traffic across servers to speeding up lookups. In interviews, you should be able to explain what a hash function does, where it’s useful, and when it becomes critical to system performance or scalability.
Hash Functions (SHA256, MD5)
A hash function takes input data and returns a fixed-size string (a hash) that represents it. Good hash functions are deterministic, fast, and produce evenly distributed outputs.
-
SHA256 is a secure, cryptographic hash function used for integrity checks, password storage (with salt), and digital signatures.
-
MD5 is outdated and not secure for cryptographic use, but may still be used for quick checksum comparisons in non-sensitive contexts.
Use cases:
-
Storing hashed passwords (with salt)
-
Detecting data tampering (e.g., comparing file hashes)
-
Content deduplication
Hash Maps
A hash map (or hash table) uses hashing to provide O(1) average time complexity for lookups, inserts, and deletes. It’s often used in caching, indexing, and in-memory storage.
Example in system design:
-
Storing a session map in Redis
-
Caching database query results
-
Indexing user data by ID for fast access
Consistent Hashing
Consistent hashing is a technique for distributing load across servers (or shards) that minimizes remapping when nodes are added or removed.
Adding a new server can cause nearly all keys to be remapped without consistent hashing. With it, only a small number of keys change ownership.
Use cases:
-
Load balancers distribute traffic
-
Distributed caches (e.g. Memcached, Redis Cluster)
-
Partitioning data in distributed databases or message queues
Deduplication
Hashing is often used to detect duplicate content. If two files produce the same hash, they’re assumed to be identical (with a small risk of collision).
Example:
-
A file upload service might compute a hash of each file and skip storing it if an identical hash already exists.
-
Used in cloud storage systems to save space and prevent redundant writes
What Interviewers Look For
-
Do you know when to use cryptographic vs non-cryptographic hashes?
-
Can you explain how consistent hashing improves scalability?
-
Do you understand how hash-based structures enable fast lookups?
-
Can you reason about edge cases like collisions and uneven distribution?
Data Modeling
Data modeling is about structuring your data to reflect real-world relationships and support the queries your system needs to run efficiently. In system design interviews, you should be able to sketch out core entities, their relationships, and how you plan to store and access them.
You don’t need to draw a complete ER diagram, but you should be able to explain your schema design choices and justify when you’d normalize or denormalize.
ER Diagrams (Entity-Relationship Diagrams)
ER diagrams visually represent your data structure. They show entities (like User, Post, Comment) and the relationships between them (one-to-many, many-to-many, etc.).
Why it matters:
-
Helps organize your thoughts when breaking down complex data
-
Clarifies how foreign keys and joins work
-
Useful for communication with teammates and interviewers
Example:
-
A
Userhas manyPosts -
A
Posthas manyComments -
A
Commentbelongs to aUserand aPost
Normalization
Normalization is the process of organizing data to reduce redundancy. Common standard forms eliminate duplicate fields, split data into related tables, and use foreign keys to connect them.
Pros:
-
Easier to update — one place to change
-
Avoids inconsistent or conflicting data
-
Reduces overall storage size
Cons:
-
Requires more joins to query
-
Can be slower for read-heavy systems
Use normalization when writing; consistency and integrity matter more than reading performance.
Denormalization
Denormalization is when you deliberately duplicate data to reduce the number of joins and speed up reads. It’s common in analytics systems, feeds, dashboards, and caching layers.
Pros:
-
Faster reads
-
Fewer joins, better performance under load
Cons:
-
Data can get out of sync
-
Harder to update consistently
Use denormalization when the system is read-heavy and stale data is acceptable for performance reasons.
Data Ownership
In microservice architectures, each service should own its data. That means the schema, database, and write access are fully controlled by the service. Other services are read via APIs, not direct queries.
Why it matters:
-
Prevents tight coupling between services
-
Makes data boundaries clear
-
Simplifies ownership and responsibility
For example, the User Service owns the users table. The Post Service might have a user_id foreign key, but it never directly queries the User DB.
What Interviewers Look For
-
Can you model real-world problems with clean relationships?
-
Do you know when to use normalization vs denormalization?
-
Can you give some reasons for data duplication, tradeoffs, and performance?
-
Do you keep service boundaries and ownership in mind?
Indexing
Indexing is how databases speed up queries. Without indexes, every query becomes a full table scan, which doesn’t scale. In system design interviews, you’re expected to know how indexing works and how to apply it to improve performance.
You don’t need to dive into database internals, but you should be able to explain which index type is appropriate based on the query pattern.
B-tree Index
B-tree (balanced tree) indexes are the default index type in most relational databases (like PostgreSQL and MySQL). They work well for range queries and sorted access.
Use cases:
-
Searching for values within a range
-
Sorting by date or ID
-
WHERE conditions like
age > 30orcreated_at BETWEEN ...
Hash Index
Hash indexes use a hash function to map keys directly to a location. They’re fast for exact matches but don’t support range queries or sorting.
Use cases:
-
Fast lookups with
=(e.g.WHERE email = 'user@example.com') -
Not useful for
>orORDER BY
Note: Many relational DBs don’t use hash indexes by default because B-trees offer more flexibility.
Composite Index
A composite index (also called a multi-column index) is created on more than one column. It helps when you often query or sort by multiple fields together.
Example:
-
Index on
(user_id, created_at) -
Speeds up queries like
WHERE user_id = ? ORDER BY created_at DESC
Important: The order of columns in a composite index matters. An index on (a, b) can help with queries on a or a + b, but not on b alone.
Covering Index
A covering index includes all the columns a query needs, so the database doesn’t need to access the table at all (no “table lookup”).
Example:
-
You query
SELECT title FROM posts WHERE user_id = ? -
If you have an index on
(user_id, title), the query is fully served from the index
Benefits:
-
Faster queries
-
Fewer disk reads
Use covering indexes for high-traffic queries that always use the same fields.
Full-Text Search
Full-text indexes are specialized for searching within large bodies of text, like articles or user-generated content.
Use cases:
-
Searching the post content by keyword
-
Autocomplete or fuzzy matching
-
Ranking results by relevance
Most databases support this through extensions or separate tools like Elasticsearch.
What Interviewers Look For
-
Can you match index types to common query patterns?
-
Do you know the tradeoffs between speed, memory, and write cost?
-
Can you give a reason for index maintenance and write overhead?
-
Do you think ahead about scaling read-heavy tables?
Databases
| Topic | Subtopics |
| Database Types | Relational (Postgres, MySQL), NoSQL (MongoDB, Cassandra, DynamoDB), Time Series (InfluxDB) |
| Transactions | ACID, two-phase commit, optimistic vs pessimistic locking |
| Schema Design | Normalization levels, handling large tables, surrogate vs natural keys |
| Scaling Techniques | Sharding (horizontal), replication (read-replicas), federation |
| Consistency Models | Strong vs eventual, causal, quorum-based consistency |
| Read/Write Optimization | Read replicas, write-ahead logs (WAL), and batching |
Kafka vs. Traditional Database for Event Streaming
Apache Kafka is a distributed event streaming platform that builds real-time data pipelines and streaming applications. Initially developed by LinkedIn, it is now open-source and part of the Apache Software Foundation.
| Feature | Kafka | Traditional DB Table |
|---|---|---|
| Throughput | High (millions of messages/sec) | Low/Moderate (concurrent writes can bottleneck) |
| Real-time Streaming | Built for real-time pub/sub pipelines | Not built for real-time; polling adds latency |
| Decoupling | Multiple consumers can read the same data independently | Hard to decouple producers/consumers cleanly |
| Scalability | Horizontally scalable (partitions across brokers) | Scaling write-heavy DB tables is hard |
| Durability | Data stored for configurable retention (even forever) | Data often updated/deleted; hard to reprocess |
| Reprocessing Events | Easy — consumers can rewind and reconsume data | Hard — must write complex logic to “replay” DB rows |
| Ordering Guarantees | Guaranteed within a partition | No natural event ordering unless manually managed |
| Backpressure Handling | Consumers can lag behind producers without data loss | Lagging consumers |
TL;DR: Use Kafka When…
-
You need real-time, high-throughput data pipelines (e.g. log processing, analytics).
-
You want multiple systems to consume the same stream of data independently.
-
You need reliable message delivery and want to reprocess events later.
-
You need event-driven architectures or microservices communication.
Caching
| Topic | Subtopics |
| Caching Layers | Client-side, CDN (Cloudflare), reverse proxy (Varnish), backend (Redis) |
| Cache Invalidation | TTL, write-through, write-back, cache busting |
| Eviction Policies | LRU, LFU, FIFO |
| Data Freshness | Stale-while-revalidate, background refresh |
Effective caching is critical for building fast, scalable, and resilient systems. Choosing the right caching layer depends on the type of content, the access patterns, and the freshness requirements.
CDN (Content Delivery Network)
Best for: Static assets like images, CSS, JavaScript, fonts, and HTML files.
How it works: CDNs replicate content across geographically distributed edge servers. When a user requests a file, the CDN serves it from the nearest location.
Common use cases:
-
Website assets (JS/CSS/images)
-
Static HTML pages for marketing sites
-
Video streaming content
Examples: Cloudflare CDN, AWS CloudFront, Akamai, Fastly
Benefits:
-
Reduces latency by serving content closer to the user
-
Decreases the load on your origin server
Cache invalidation:
-
Typically handled via
Cache-Control,ETag, andExpiresheaders -
Manual invalidation supported via purge APIs or cache-busting URLs (e.g.,
filename.12345.js)
Cloudflare (or Similar Edge Platforms)
Best for: CDN + security + edge logic.
Cloudflare can act as a CDN and a smart reverse proxy with additional features like DDoS protection, WAF (Web Application Firewall), and DNS. Using Cloudflare Workers or Page Rules, you can also cache dynamic API responses at the edge.
Use cases:
-
Protecting and accelerating a frontend application
-
Caching GraphQL or REST API responses
-
Edge-based A/B testing or redirects
Cache invalidation:
-
Edge caching can be purged manually
-
TTLs and
Cache-Controlheaders apply similarly to CDNs
Reverse Proxy (e.g., NGINX, Varnish)
Best for: Caching full or partial HTTP responses near your application.
A reverse proxy sits between the client and your app. It can serve cached versions of dynamic content, reducing the load on backend services.
Use cases:
-
Caching expensive dynamic pages (e.g., rendered blog articles)
-
Handling surge traffic to popular endpoints
-
Internal caching layer in monoliths or service mesh setups
Cache invalidation:
-
Based on URL and headers
-
Often uses custom logic or cache purging scripts
-
TTLs can be configured per endpoint
Redis
Best for: In-memory caching of computed data, user sessions, and ephemeral storage.
Redis is an in-memory data store that supports various data structures (strings, hashes, sets, etc.). It’s highly performant and can persist data to disk if configured.
Use cases:
-
Caching database query results
-
Storing user session data
-
Rate limiting counters
-
Storing ephemeral tokens or flags
Eviction policies:
-
LRU (Least Recently Used), LFU (Least Frequently Used), TTL-based, or manual
-
You can set expiry per key (
EXPIREorSETEX)
Cache invalidation:
-
Manual deletion (e.g.,
DEL) -
Automatic expiration after a TTL
Memcached
Best for: Lightweight, simple key-value caching with no persistence.
Memcached is a fast, in-memory cache ideal for use cases where persistence and advanced data types are unnecessary. In some scenarios, it’s simpler and faster than Redis but less feature-rich.
Use cases:
-
Caching small, frequently accessed query results
-
Transient data for API responses
-
Session caching (in stateless apps)
Eviction policies:
-
LRU only
-
TTL-based expiry
Limitations:
-
No persistence
-
No complex data structures
-
No replication or clustering (natively)
Cache Invalidation and Data Freshness
One of the most complex problems in caching is invalidation – knowing when to update or evict stale data.
Key strategies:
-
Time-to-Live (TTL): Set a fixed expiration time on cached content.
-
Write-through caching: Data is written together in the cache and the DB.
-
Write-behind caching: Cache is updated first; DB is updated asynchronously.
-
Manual invalidation: Cache is explicitly cleared when updates happen.
-
Cache busting: Use versioned keys or URLs to force new content to be fetched.
Considerations:
-
Strong freshness: Use low TTL or no caching.
-
Eventual consistency: Use higher TTLs and accept staleness.
-
Real-time systems: Combine pub/sub (e.g., Redis Streams) to trigger invalidations.
Summary: System Design Fundamentals Recap
| Tool | Best For | Persistent? | Eviction | Supports Complex Structures |
|---|---|---|---|---|
| CDN | Static files, global distribution | No | TTL | No |
| Cloudflare | Edge caching + security + APIs | No | TTL | No (but Workers add logic) |
| Reverse Proxy | Full-page or route caching | Optional | TTL/manual | No |
| Redis | Fast app-level caching, sessions | Optional | LRU/TTL/custom | Yes |
| Memcached | Lightweight key-value caching | No | LRU/TTL | No |
Each caching layer serves a distinct purpose. In modern systems, they are often used together, layered strategically to maximize speed, reduce backend load, and ensure acceptable data freshness.
Asynchronous Processing
| Topic | Subtopics |
| Message Queues | Kafka, RabbitMQ, SQS, Pub/Sub |
| Queue Patterns | Fan-out, fan-in, publish-subscribe, dead-letter queues |
| Async Processing | Worker pools, retry queues, exponential backoff |
| Scheduled Jobs | Cron jobs, delay queues, distributed schedulers (Quartz, Celery) |
Load Balancing & Scalability
| Topic | Subtopics |
| Load Balancers | Layer 4 (TCP), Layer 7 (HTTP), HAProxy, NGINX, AWS ALB/ELB |
| Load Balancing Algorithms | Round-robin, least connections, weighted routing |
| Sticky Sessions | Session affinity, IP hash |
| Autoscaling | CPU/memory-based, scheduled scaling, predictive scaling |
Rate Limiting & Throttling
| Topic | Subtopics |
| Algorithms | Token bucket, leaky bucket, fixed window, sliding window |
| Implementation | Redis-based rate limiter, API gateway-level throttling |
| Scope | Per-user, per-IP, per-endpoint |
| Abuse Prevention | Blacklisting, rate-based blocking, CAPTCHA triggers |
Fault Tolerance & Reliability
| Topic | Subtopics |
| Retry Mechanisms | Retry queues, exponential backoff, jitter |
| Circuit Breakers | Open/half-open/closed states, fallback handling |
| Graceful Degradation | Fallback UIs, feature toggles, read-only mode |
| Redundancy | Multi-region, active-active vs active-passive deployments |
Observability
| Topic | Subtopics |
| Monitoring | Prometheus, Grafana, DataDog |
| Logging | Structured logs, ELK stack (Elasticsearch, Logstash, Kibana) |
| Tracing | OpenTelemetry, Jaeger, Zipkin |
| Health Checks | Liveness and readiness probes, alerting systems |
Infrastructure & Deployment
| Topic | Subtopics |
| Containerization | Docker, container lifecycle, image optimization |
| Orchestration | Kubernetes basics (pods, deployments, services, autoscalers) |
| CI/CD | GitHub Actions, Jenkins, ArgoCD, blue-green & canary deployments |
| Environment Config | 12-factor apps, secrets management, dotenv, Vault |
Security
| Topic | Subtopics |
| Transport Security | HTTPS, TLS, mutual TLS (mTLS) |
| Data Security | Encryption at rest/in transit, KMS (Key Management Services) |
| App Security | Input validation, rate limiting, CSRF/XSS/clickjacking protection |
| Authentication/Token Handling | Secure token storage, rotation, session hijack protection |
Practice System Design Scenarios
| Problem Type | Example Use Case |
| Real-time system | Chat app (WebSockets vs polling) |
| Rate limiting | Token bucket algorithm in Redis |
| File uploads | Presigned URLs, virus scanning pipeline |
| Notification system | Push/SMS/email delivery with retries |
| AI Inference API | Streamed output, compute resource throttling |
| Feed system | User feed with fan-out vs fan-in architecture |
| URL shortener | ID generation, redirect routing, analytics |
