This interview guide is for educational and informational purposes only. It is designed to help readers prepare, but it does not guarantee any interview result, hiring decision, offer, or outcome. Interview questions, hiring criteria, and preferred answers can vary by employer, interviewer, industry, location, and time. The examples and explanations reflect the authors' research and judgment, are provided without warranties of any kind, and should not be treated as the only correct approach. Diagrams are simplified illustrations intended to highlight the main components and their interactions; actual systems and implementations may be more complex. Alternative approaches may be equally valid or better suited to a particular question, context, or interviewer. To the fullest extent permitted by applicable law, the author, contributors, and publisher are not liable for decisions made, actions taken, or losses incurred based on this guide.
Identity, Image, and Privacy Notice
To respect individual privacy, some names, profile photographs, avatars, biographical details, and other identifying information displayed in this guide may be replaced with pseudonyms, licensed stock images, illustrative avatars, composite images, or representative descriptions. Unless a person is expressly identified as an actual contributor, a displayed name, image, or profile should not be understood as depicting or identifying a specific candidate, interviewer, employee, or other real individual. These representations are provided for editorial and illustrative purposes only and do not imply endorsement, employment, participation, or affiliation with this guide or any company mentioned in it. Any resemblance to an actual person is coincidental.
Company Notice
This guide is an independent educational resource and is not affiliated with, endorsed by, sponsored by, or approved by the company named in this guide. Company names are used only to identify interview experiences commonly reported by candidates. Interview practices can change without notice, and inclusion of company-specific content does not mean these questions are official, complete, or guaranteed to be asked. To the fullest extent permitted by law, the author, contributors, and publisher are not responsible for outcomes related to use of this material.
Questions or comments?
Contact us for general questions, or share feedback, technical corrections, and comments with the community.
Treat this as the reported Google Cloud interview prompt and explain the mechanism, inputs, and enforcement behavior expected from a rate-limiting component.
Short Interview Answer (30-60 seconds)
At a high level, my goal is to stop one client from overwhelming the API with too many requests. The client sends an HTTPS request to the Rate Limiter. It identifies the caller, checks current usage against the configured limit, and updates usage state. If the request is allowed, it goes to the API / Application and the normal response returns. If the limit is exceeded, the limiter returns HTTP 429 Too Many Requests with Retry-After. A shared state store improves consistency across instances, but adds coordination cost.
Detailed Explanation
This question asks how a system can stop one client from sending too many requests in a short time. The goal is to protect the application and its backend resources from overload or abuse. We need to know who is making the request, how much that caller has already used, and what limit applies. The diagram shows one simple path. A rate limiter checks the request before the application does business work. It either allows the request to continue or sends back a limit response.
Useful Questions to Ask the Interviewer
What should identify a caller: IP address, API key, user ID, or auth token?
What request limit and time window should we enforce?
Should rate-limit state be shared across all instances?
Which time model should we use: fixed window, sliding window, or token bucket?
How to Explain It in an Interview
1. Start with the incoming request
The client sends an API request over HTTPS. The Rate Limiter receives it before the API / Application. Its first job is to identify the caller. The diagram shows identity values such as IP address, API key, user ID, or auth token. That identity becomes the key used to find the caller's usage.
2. Look up and evaluate usage
The limiter reads usage for that identity from the state store. The diagram uses a fast shared store, such as Redis, for consistency. The limiter then checks the configured limit. The example is 100 requests per minute per user. The time model may be a fixed window, sliding window, or token bucket.
3. Update usage and make the decision
If the request is within the limit, the limiter updates usage. A counter-based design increments a counter. A token-based design consumes a token. If the limit is exceeded, the limiter rejects the request instead of forwarding it. This keeps excess traffic away from the application.
4. Process an allowed request
An allowed request is forwarded to the API / Application, shown as .NET with ASP.NET Core. The application runs business logic, performs data access, and can make downstream calls. The Data Store / Downstream Services box represents databases, microservices, and external APIs. Their response returns to the application, and the application response returns through the limiter toward the client.
5. Return success or rate-limit failure
For an allowed request, the client can receive a normal response such as 200 OK. When the limit is exceeded, the Rate Limit Rejection Response is HTTP 429 Too Many Requests. The diagram also shows Retry-After, which tells the client when it may try again. The limiter therefore owns the allow-or-reject enforcement decision.
6. Explain the main trade-off
Shared rate-limit state keeps different instances consistent, which is important when traffic is distributed. The downside is extra state-store work on the request path. The limiter must read and update usage quickly. We accept that cost because consistent enforcement protects backend resources and prevents one caller from bypassing the limit by reaching different instances.
Practical Complexity & Trade-offs
The benefit of this design is that expensive application work starts only after the rate check passes. Limits can be applied per IP address, API key, user ID, or auth token. The diagram also supports several time models: fixed window, sliding window, or token bucket. A shared state store, such as Redis, helps different instances see the same usage. The downside is extra state-store work on each decision, which can add latency. Fixed windows are simple, while sliding windows give smoother counting. Token buckets can allow controlled bursts. Returning HTTP 429 clearly tells the client that the limit was exceeded. Retry-After gives retry guidance. We accept the extra coordination because it protects backend resources and keeps enforcement consistent.
Why Interviewers Ask This
The interviewer is testing whether you understand rate limiting as an API control, not just as a counter. They want to see whether you can identify the caller, track usage over time, make the allow-or-reject decision, return correct HTTP behavior, and explain how shared state supports multiple instances. They are also checking whether you can communicate the trade-off between simple local checks and more consistent shared enforcement.
Interviewer may ask next
What changes if the API runs on many application instances?
I would keep the same request path, but I would make the rate-limit state shared across all instances. The affected parts are the Rate Limiter and its state store. Each limiter must read and update the same logical usage record for a caller instead of keeping an unrelated local count. That way, a user cannot receive a separate allowance from every instance. The shared store shown in the diagram, such as Redis, holds counters or token state for the chosen time model. Allowed requests still go to the API / Application. Rejected requests still return HTTP 429 Too Many Requests with Retry-After. The main downside is extra network and storage work on the request path. If the shared store becomes slow, the limiter can also become slow. We accept this cost because one consistent limit across instances is more useful than several independent local limits.
How would you choose between a fixed window, sliding window, and token bucket?
I would keep the same Rate Limiter and enforcement flow, but change how usage is measured. With a fixed window, the limiter counts requests during a period such as 100 requests in one minute. It is simple, but traffic can bunch around the boundary between two windows. With a sliding window, recent requests are measured more smoothly across time. With a token bucket, tokens refill over time and each allowed request consumes a token, so short controlled bursts are possible. The caller identity, shared state store, API / Application, downstream flow, and HTTP 429 response stay the same. Only the time and usage calculation changes. The main downside is complexity. Fixed windows are easiest to operate, while sliding windows and token buckets require more state or calculation. I would choose based on how much burst traffic the API should allow.
22. Design a rate limiter for a public API at millions of requests per second.API DesignHardGoogle
i Question Details
Use the reported Google system-design prompt in an API-design framing, and explain how callers are identified, how limits are enforced, and what behavior is expected at very high request volume.
Short Interview Answer (30-60 seconds)
At a high level, I would protect the public API by limiting each caller before traffic reaches the backend. Requests pass through DDoS Protection and the global API Gateway, then reach a distributed Rate Limiter Service. Caller identity can come from an API key, OAuth2/JWT, IP address, client ID, user ID, or mTLS subject. The limiter checks shared counters and policies. It forwards allowed requests to ASP.NET Core services and returns HTTP 429 with Retry-After when a limit is exceeded. The main trade-off is accurate distributed counting versus latency and coordination cost.
Detailed Explanation
The goal is to keep a very busy public API available when millions of requests arrive each second. We need to know who is sending each request, count how much traffic that caller sends, and stop traffic above the allowed limit. Good requests should continue quickly to the application. Extra requests should be rejected before they waste backend capacity. The diagram solves this with edge protection, a global gateway, a distributed rate limiter, shared counter and policy data, and monitoring for very large traffic volumes.
Useful Questions to Ask the Interviewer
Should limits differ by API key, user, IP address, endpoint, or customer plan?
Do we need both short burst limits and sustained limits?
How strict should counting be when traffic is distributed globally?
How to Explain It in an Interview
1. Start with the public request path
The request first comes from mobile apps, web apps, third-party integrations, or IoT devices. It uses HTTPS and passes through DDoS Protection using a WAF or CDN. This layer helps absorb abusive traffic before it reaches the API system. The request then goes over HTTPS to the API Gateway at the global edge. The gateway is the public entry point and sends the API request to the distributed Rate Limiter Service.
2. Identify and validate the caller
Before a rate-limit rule can be applied, the system needs a caller identity. The diagram shows API Keys, OAuth2/JWT, and mTLS Certificates as supported identity inputs. It also shows the caller key as an API Key, Client ID, User ID, IP address, or mTLS subject. The API Gateway performs the shown token or mTLS validation with the Identity and Caller Identification capability. This gives the rate limiter a trusted caller key for selecting the correct limit.
3. Make the distributed rate-limit decision
The API Gateway sends the API request to the Distributed Rate Limiter Service. The service is designed for stateless horizontal scale. This means many rate-limiter instances can process requests, while shared state remains in internal stores. The Distributed Counter Store is a scalable key-value store, with Redis or Aerospike shown as examples. The Policies and Limits Store contains configured rules, with DynamoDB, Spanner, or Cassandra shown as examples. Time and Window Management uses Sliding Window or Token Bucket logic to decide whether the caller still has capacity.
4. Apply the configured policy
The limiter selects the rule for the caller and request. The diagram shows example limits of 1000 requests per minute per API key, 500 per minute per user, and 100 per minute per IP address. It also supports different per-endpoint limits. Burst and sustained traffic can use a Token Bucket. Dynamic limits can vary by plan or tier. These are policy examples inside the rate-limiting design. They are not separate API endpoints.
5. Forward allowed requests
If the request is within its limit, the Rate Limiter Service sends the allowed request to Backend Services running ASP.NET Core. The backend performs the business work. It reads or writes data in the Data Store. The diagram shows SQL or NoSQL databases and a Redis cache. After processing, the backend response returns to the API Gateway. The gateway then returns the HTTPS response to the client.
6. Reject requests above the limit
If the caller has exceeded the selected rule, the Rate Limiter Service does not forward that request to the backend. It sends a denial to the API Gateway as HTTP 429 Too Many Requests with Retry-After. The gateway then returns that response to the caller. Rejecting traffic at this point protects backend capacity. Retry-After also gives the client useful feedback about when it should try again.
7. Observe and operate the system
The internal Rate Limiter Service sends metrics and logs asynchronously to Analytics and Monitoring. The diagram shows request rate, allowed and blocked counts, dashboards, alerts, high-cardinality logging, SLOs, and error budgets. It also sends rate-limit events asynchronously to a Streaming or Event Bus such as Kafka or Pub/Sub. These paths do not control the synchronous client response. The key design choice is a stateless distributed limiter backed by shared counters and policies. This scales horizontally, but distributed state adds latency, coordination work, and operational complexity.
Practical Complexity & Trade-offs
The benefit of this design is that excessive traffic is stopped before it consumes ASP.NET Core backend capacity. The Rate Limiter Service can scale horizontally because its important state is kept in shared counter and policy stores. Token Bucket is useful when callers may send short bursts while still following a longer-term limit. Sliding Window gives another way to measure traffic over time. The downside is that distributed counters require extra network calls and coordination. Strict global counting can cost more latency than looser local decisions. The caller key also matters because limits may use an API key, user, IP address, endpoint, mTLS subject, or customer tier. We accept this complexity because the API must remain responsive while handling millions of requests per second.
Why Interviewers Ask This
Interviewers ask this question to test design judgment at very high traffic. They want to see whether the candidate can identify callers correctly, place rate limiting before expensive backend work, model HTTP 429 behavior, and explain distributed counters and policies. They also look for understanding of burst handling, horizontal scaling, observability, and request versus response direction. A strong answer explains the trade-off between accurate distributed limits, low latency, backend protection, and operational complexity.
Interviewer may ask next
What happens if one API key suddenly sends a very large burst of traffic?
The distributed Rate Limiter Service should absorb the decision-making before the burst reaches the ASP.NET Core backend. The gateway validates the caller information and sends the API request to the limiter with the caller key needed for the policy lookup. The limiter checks the API-key policy and current state in the Distributed Counter Store. With the Token Bucket option shown in the diagram, a permitted burst can consume available tokens quickly. Once that capacity is exhausted, later requests are rejected. The limiter returns HTTP 429 Too Many Requests with Retry-After to the API Gateway, and the gateway returns that response to the client. The backend therefore receives only allowed traffic. Analytics record allowed and blocked counts, while rate-limit events can also go asynchronously to the event bus. The main downside is that one very hot caller can create heavy access to a small set of counter keys, so the distributed counter store must scale for that load.
How would you apply different limits to users, API keys, IP addresses, endpoints, and customer plans?
I would keep the same architecture and choose the rate-limit key and policy that match the validated caller and request. The diagram shows caller identification through API Keys, OAuth2/JWT, mTLS Certificates, Client ID, User ID, IP address, and mTLS subject. The Rate Limiter Service can therefore select a matching rule from the Policies and Limits Store and track its usage in the Distributed Counter Store. The examples show 1000 requests per minute per API key, 500 per minute per user, and 100 per minute per IP address. It also supports different per-endpoint limits and dynamic plan or tier limits. Requests that remain within the selected rule continue to the ASP.NET Core backend. Requests above it return HTTP 429 with Retry-After through the API Gateway. The downside is that supporting more dimensions creates more policy combinations, more counter keys, and more operational complexity.
23. Design Google Drive: distributed file storage with versioning, sharing, and sync.API DesignHardGoogle
i Question Details
Use the Google-reported Drive prompt and focus on the file-facing API contract, versioning semantics, sharing rules, and sync behavior that clients depend on.
Short Interview Answer (30-60 seconds)
At a high level, I would design Drive around files, folders, permissions, revisions, and an incremental changes feed. Clients send HTTPS requests with OAuth 2.0 or JWT identity through the API Gateway. The gateway authenticates the caller, applies rate limits and request validation, checks the token with the Identity Service, and routes valid work to Drive Core Services. Metadata and permissions use structured stores, while file bytes use object storage. Events handle background work and notifications. The trade-off is more operational complexity, but storage, sharing, versioning, and sync can scale independently.
Detailed Explanation
The goal is to let people store files, change them, share them, and keep different devices in sync. A user should see the same files, history, and sharing rules from the web, phone, desktop, or a connected application. The difficult part is coordinating file content, file details, revisions, permissions, and device changes while many users work at once. I would explain the design by following the diagram from the client request, through identity checks and Drive services, into storage, and then through background events and synchronization.
Useful Questions to Ask the Interviewer
Do we need web, mobile, desktop sync, and third-party clients?
Should users be able to restore any retained file revision?
Do shared links need permissions and expiration?
Is incremental synchronization required for offline clients?
How to Explain It in an Interview
1. Start with the client and API boundary
I would begin with the main resources shown in the design: Files, Folders, Permissions, Revisions, Changes, and About. Web, mobile, desktop, and third-party clients enter through the API Gateway / Front Door. A normal request travels over HTTPS and carries JWT or OAuth 2.0 identity information. The gateway handles authentication, rate limiting and throttling, routing and load balancing, and request validation. This keeps common API checks outside the individual Drive services.
2. Validate identity before business processing
The gateway asks the Identity Service to validate the token. The validation request moves from the gateway to the Identity Service. The Token Valid response returns to the gateway with the user and scopes. The Identity Service represents Google Identity and covers user accounts, OAuth 2.0 or OpenID Connect, JWT tokens, and groups or directory information. Only a request that passes these checks should continue into Drive Core Services. The normal response then returns through the gateway to the client as JSON, with either a success or error result.
3. Split Drive work into focused services
Drive Core Services separate responsibilities. The File Service creates, reads, updates, renames, and deletes files and folders. The Metadata Service manages properties, labels, and custom attributes. The Version Service manages revisions, retention information, and restore behavior. The Sharing Service manages ACLs, roles, sharing links, domains, and permissions. The Search Service indexes metadata and content. The Sync Service tracks changes, detects conflicts, and supports offline synchronization. The Notification Service handles change events, watchers, and real-time updates. Quota & Billing tracks storage usage and quotas.
4. Store each type of data appropriately
The services use separate stores because their data has different needs. Metadata uses the Metadata DB. File blobs use Object Storage. Revision information uses the Version Index. Search uses the Search Index. Sharing permissions use the Sharing / ACL DB. Frequently used information can use the Cache. This separation allows file content, metadata, indexes, permissions, and cached values to scale according to their own access patterns.
5. Define versioning and sharing semantics
File content updates create new revisions. Revision content is immutable, while revision metadata such as retention settings may change. Users can restore an earlier retained revision. Deleted files remain in Trash for a limited time, and retention policies are supported. Sharing can target users, groups, or domains. Roles include Viewer, Commenter, Editor, and Owner. Shared links can have permissions and expiry. Public access can be disabled, and folder permissions may be inherited.
6. Use incremental sync for desktop clients
The desktop client uses the incremental Sync Protocol. It gets changes since a saved token, uploads local changes, and receives changes plus acknowledgements. The Sync Service owns change tracking, conflict detection and resolution, and offline sync logic. The design accepts eventual consistency across devices instead of requiring every device to update instantly. Real-time notifications help clients discover that new changes are available, while the changes feed lets them catch up reliably.
7. Move secondary work to asynchronous events
Drive Core Services publish events through Event Bus / Pub/Sub. Events shown include FileChanged, VersionCreated, PermissionChanged, TrashEmptied, QuotaExceeded, LinkCreated, and LinkAccessed. Background workers handle indexing, thumbnails, virus scanning, transcoding, retention or lifecycle work, and backup or replication. Push Notifications deliver change or sync notifications to clients. Audit, Logging & Monitoring separately receives audit logs, access logs, metrics, alerts, and distributed tracing. These asynchronous paths support the system without becoming part of the main synchronous response path.
Practical Complexity & Trade-offs
The benefit is that each part has a clear job. The gateway handles authentication, rate limits, routing, and request checks once. Drive services then focus on files, metadata, revisions, sharing, search, sync, notifications, and quotas. File bytes use object storage, while metadata and permissions use structured stores. This matches their different access patterns. The downside is that several services and stores must stay coordinated. Event-driven work also means indexes or notifications may appear later. Incremental sync saves bandwidth, but conflict handling becomes harder. Caching improves speed, but cached values may become stale. We accept this complexity because large file storage needs independent scaling, durable history, flexible sharing, and efficient synchronization.
Why Interviewers Ask This
Interviewers ask this question to test API and system-design judgment rather than memorization. They want clear resource boundaries, correct request and response direction, sensible authentication and authorization ownership, and appropriate storage choices. They also look for good versioning and sharing semantics, efficient incremental sync, asynchronous processing, caching, reliability, and scalability. A strong answer should explain why each choice exists and describe its trade-offs without claiming stronger guarantees than the design actually provides.
Interviewer may ask next
What changes if the number of file updates and sync clients grows dramatically?
I would keep the same API and service boundaries, but scale the components already responsible for the heavy paths. The API Gateway / Front Door can distribute more requests across Drive Core Services. File blobs still go to Object Storage, while metadata, revision information, and sharing rules remain in their separate stores. For desktop synchronization, I would keep the incremental Changes flow because clients request only changes after their saved token instead of downloading all state again. Event Bus / Pub/Sub becomes especially important because FileChanged and other events can be consumed independently by indexing, thumbnail, virus scan, lifecycle, and backup workers. Those workers can scale without extending the main request path. The same versioning, permission, and sync rules still protect correctness. Devices may remain eventually consistent. The main downside is operational complexity because more service instances, consumers, caches, and storage partitions make monitoring and failure diagnosis harder.
How would you handle two offline desktop clients editing the same file before either one syncs?
I would keep the existing incremental Sync Protocol and let the Sync Service detect and resolve the conflict when both clients reconnect. Each client can queue local changes while offline. After reconnecting, it gets server changes since its saved token and uploads its pending changes. The Sync Service owns change tracking and conflict handling, while the Version Service preserves revision history. That history matters because file content updates create new revisions and retained older revisions can be restored. The client then receives changes and acknowledgements through the normal Delta Sync response. Notifications can tell other clients that new changes exist, but the incremental changes feed remains the mechanism for catching up. I would not claim that every device updates instantly because the diagram explicitly accepts eventual consistency across devices. The downside is that conflicting edits may require visible resolution behavior, even though revision history helps prevent loss of earlier content.
24. Design a URL shortening service like bit.ly. Discuss the database schema, API endpoints, and how you would handle scaling to millions of requests per day.API DesignMediumGoogle
i Question Details
Use the exact Google interview prompt, keeping the focus on the public API surface, the storage model, collision handling, and the scaling assumptions called out in the question.
Short Interview Answer (30-60 seconds)
At a high level, I would build a read-heavy URL shortening service with a simple create API and a very fast redirect path. Clients reach the system through DNS, an optional CDN, and an Anycast load balancer. Stateless ASP.NET Core services create codes, resolve redirects, and record analytics. Redis keeps hot code mappings close to the application, while durable data stays in the relational store. I would use HTTPS, rate limiting, and unique code checks. The main trade-off is extra cache and queue complexity for lower latency and easier scaling.
Detailed Explanation
The goal is to turn a long web address into a short one that is easy to share. When someone opens the short address, the system must quickly send them to the original page. We also need to remember each link, avoid giving two links the same short code, and count visits. The system should keep working when traffic becomes very large. I would explain the design by following the picture from the user request, through link creation or redirect, into storage, caching, and background work.
Useful Questions to Ask the Interviewer
Should users be allowed to choose a custom short code?
Should short links be allowed to expire?
What read traffic and write traffic should we expect?
How to Explain It in an Interview
1. Start with the public API
I would first define the small public surface shown in the diagram. POST /api/shorten creates a short link. Its body contains url, optional customCode, and optional expiresAt. It returns 201 Created with shortUrl, code, createdAt, and optional expiresAt. GET /api/shorten/{code} returns the original url, code, createdAt, clicks, and optional expiresAt. The public redirect endpoint is GET /{code}. A successful lookup returns 302 Found with Location set to the original URL. GET /health returns {"status":"ok"}.
2. Follow the request into the application
The client sends an HTTPS request. DNS resolves the service name. The optional CDN can help serve redirect traffic close to users. The request then reaches the Anycast load balancer. It sends traffic to a stateless ASP.NET Core API instance in the multi-region application cluster. The response travels back from the API through the load balancer toward the client. Stateless services let us add more instances as traffic grows.
3. Create a short link and handle collisions
The Shorten Service validates the request and generates a candidate code. The diagram allows either a secure random Base62 value or a Snowflake-style identifier encoded as Base62. A seven-character Base62 code gives about 62^7, or roughly 3.5 trillion combinations. The service checks Redis with a SETNX style uniqueness step. If the candidate exists, it generates another. If it looks unique, the service inserts it into the database. A UNIQUE constraint on code is the final correctness check. A rare uniqueness failure causes another retry. If a requested custom code is already used, the service returns 409 Conflict.
4. Resolve redirects on the fast path
For GET /{code}, the Redirect Service resolves the short code to the original URL. Redis keeps hot code-to-URL mappings, so popular redirects avoid repeated database reads. On a successful lookup, the service returns 302 Found with the original URL in the Location header. The design is read optimized because redirect traffic is the dominant path.
5. Store links and click events
The relational model has a urls table and an append-only, partitioned clicks table. The urls table keeps the short code, original URL, creation time, optional expiry, and is_active state. The unique index on code protects correctness, while is_active supports soft delete. The clicks table stores redirect events such as timestamp, IP, user agent, country, and referrer. Partitioning click data by day keeps large analytics data manageable. Read replicas support heavy read and analytics workloads.
6. Scale analytics and operations separately
The application publishes click events to the Kafka message broker instead of doing heavy analytics on the redirect path. Background workers process analytics, aggregate statistics, expire links, and perform cleanup. Object storage holds exports and backups. For larger traffic, I would add stateless ASP.NET Core instances, keep hot mappings, rate-limit state, and idempotency keys in Redis, use database read replicas, partition click data, and use connection pooling. The diagram also shows retries, timeouts, circuit breakers, health checks, dead-letter queues, centralized logs, metrics, tracing, dashboards, and alerts. The trade-off is more moving parts, but each layer can scale independently.
Practical Complexity & Trade-offs
The benefit of this design is that the common redirect path stays very fast. Redis can answer many hot lookups without touching the database. Stateless ASP.NET Core services are also easy to add behind the load balancer. The downside is that Redis, Kafka, read replicas, workers, and multiple regions make operations harder. The database UNIQUE constraint is still important because the cache check alone cannot guarantee that two requests never choose the same code. Async analytics also means click counts may not update immediately. We accept that small delay because it keeps analytics work away from the redirect path. HTTPS protects traffic in transit, while rate limiting helps reduce abuse and protect shared capacity.
Why Interviewers Ask This
The interviewer is testing whether the candidate can turn a simple product idea into clear API contracts and a scalable data flow. They want to see correct HTTP behavior, a sensible storage model, safe collision handling, and a fast redirect path. They are also checking whether the candidate understands caching, stateless scaling, asynchronous work, database growth, reliability, and the trade-offs created by adding more infrastructure.
Interviewer may ask next
What would you change if redirect traffic became much larger than expected?
I would keep the API contract the same and scale the redirect path first. The affected flow is GET /{code} through DNS, the optional CDN, the Anycast load balancer, the Redirect Service, Redis, and then the database when needed. I would add more stateless ASP.NET Core instances across the existing regions and keep frequently used code-to-URL mappings in the Redis cluster. The CDN can also serve more redirect traffic close to users when those responses are cacheable. Database read replicas would absorb more lookup traffic that reaches the data layer. I would keep click recording asynchronous through Kafka so analytics work does not slow the redirect response. Correctness still comes from the stored URL mapping and the unique code constraint. HTTPS remains the transport protection, and rate limiting continues to protect shared capacity. The main downside is higher infrastructure cost and more cache coordination. Popular links may also create uneven traffic, so monitoring Redis hit rate, redirect latency, errors, and replica load becomes more important.
How would you handle link creation if many requests generate the same short code at the same time?
I would keep the existing collision-handling flow and rely on the database UNIQUE constraint as the final correctness rule. POST /api/shorten first generates a candidate Base62 code. The Shorten Service checks Redis with the SETNX style uniqueness step. If Redis says the code already exists, the service generates another candidate. If the cache check succeeds, the service still inserts the mapping into the relational database using the UNIQUE index on code. Two requests could still race between the cache check and the database insert, so one insert may fail with a uniqueness violation. That request generates a new code and retries a few times, as shown in the diagram. For a user-selected custom code, the service does not silently choose another value. If that custom value is already taken, it returns 409 Conflict. HTTPS still protects the request in transit. The downside is a small amount of retry work, but the database constraint prevents duplicate short codes from becoming valid mappings.
25. Design a small but scalable feature for Google Maps.API DesignMediumGoogle
i Question Details
Use the Google junior developer prompt and define the feature boundary, the request/response contract, and the minimum public interface needed to keep the feature small yet scalable.
Short Interview Answer (30-60 seconds)
At a high level, I would keep this feature focused on saving and sharing places through collections. A signed-in Google Maps client sends POST /v1/collections with a bearer JWT. The API Gateway authenticates and authorizes the caller, applies limits and validation, then forwards the request to the .NET 8 Collections Service over HTTPS with mTLS. The service stores collection data in regional databases and returns 201 Created through the gateway. Pub/Sub supports asynchronous work such as notifications. The trade-off is more infrastructure, but the public interface stays small while the backend can scale.
Detailed Explanation
This question asks us to add one useful Google Maps feature without building a large new platform. Users should be able to save places, organize them into collections, and share those collections. The main challenge is keeping the public interface small while supporting many users later. The diagram uses one API Gateway and one Collections Service for this feature. Regional databases hold collection data. Existing Google services still handle identity and place information. Pub/Sub handles background work. I would explain the design by following the create-collection request from the client to storage and back.
Useful Questions to Ask the Interviewer
Should collections be private by default, or may users make them public?
Is delayed notification delivery acceptable when a collection is shared?
Is the first version only for signed-in Google Maps users?
How to Explain It in an Interview
1. Define the feature boundary
I would keep the new feature focused on collections. Google Maps mobile and web clients remain outside the Google Maps API boundary. The API Gateway is the single public entry point. The Collections Service owns business logic for collections and their items. Existing Identity Platform and Places Service components stay separate. This keeps the new feature small because it reuses services that already solve identity and place-data problems.
2. Define the minimum public contract
The public operation shown in the diagram is POST /v1/collections. The client sends it over HTTPS with Authorization: Bearer <JWT> and Content-Type: application/json. The example body contains name, description, and isPublic. It creates a collection named "Weekend Cafes", with description "Cafes to try this weekend", and isPublic set to false. I would avoid adding more public endpoints until the feature actually needs them. That keeps the initial contract easy to understand and evolve.
3. Protect the request at the API Gateway
The Identity Platform issues the JWT through OAuth 2.0 or OIDC. The API Gateway handles JWT authentication, authorization scopes, rate limiting, quotas, request validation, routing, and observability. Authentication checks who the caller is. Authorization checks whether that caller has permission. If one of these gateway checks fails, the request does not continue to the Collections Service. The diagram does not define specific failure status codes, so I would not invent them.
4. Run the collection logic in .NET
After the gateway accepts the request, it forwards the request over HTTPS with mTLS to the Collections Service. mTLS encrypts the connection and lets both sides verify each other. The service uses .NET 8 and ASP.NET Core. Its internal structure shows Minimal API controllers, application services, domain or business logic, EF Core repositories, and request or response DTOs. This separates HTTP handling, business rules, storage access, and data contracts.
5. Read and write supporting data
The Collections Service reads and writes the regional User Collections DB and Collection Items DB using the protected connection shown in the diagram. The stores are labeled Spanner or PostgreSQL. The service can also read from the existing Places Service over HTTPS to validate a placeId and get place details. This avoids making the Collections Service the owner of Google Maps place data. Memorystore provides caching, while Secret Manager provides configuration and secrets. Cloud Logging plus Cloud Monitoring provide logs, metrics, and tracing.
6. Return the response and handle background events
For the shown create request, the service returns 201 Created. The response contains id, name, description, isPublic, ownerId, createdAt, updatedAt, shareUrl, and itemsCount. The response travels from the Collections Service back through the API Gateway and then to the client over HTTPS. Separately, the service can publish collection.created, collection.updated, and collection.shared events to Pub/Sub. The notification path is asynchronous, so email or push work does not need to block the main request and response.
7. Explain scalability and the trade-off
The design keeps one small public boundary while allowing internal pieces to scale independently. Regional databases support growing collection data. Caching reduces repeated reads. Pub/Sub separates background processing from user-facing work. The benefit is clear ownership and a small client contract. The downside is more infrastructure, including a gateway, databases, caching, event processing, monitoring, and secret management. I would accept that cost because it supports growth without making the public API unnecessarily large.
Time & Space Complexity
The main choice is to expose one small public contract and hide scaling details behind it. The benefit is that clients stay simple while the Collections Service can grow independently. JWT authentication and authorization scopes protect the public API. Rate limiting and quotas protect shared capacity. Request validation stops bad input before business processing. mTLS protects traffic between the gateway and service. Regional databases improve scale and availability, but they add operational work. Pub/Sub keeps notification work away from the main response path. Caching can reduce repeated reads, but cached data may be older than stored data. Logging, metrics, and tracing help operators find problems. The downside is extra infrastructure. We accept it because each part has a clear responsibility.
Why Interviewers Ask This
The interviewer is testing whether you can define a small feature boundary without blocking future growth. They want to see a clear request and response contract, correct ownership, and a minimal public interface. They also check whether you separate authentication from authorization and understand validation, rate limiting, storage, asynchronous events, and observability. A strong answer explains why each component exists and communicates the trade-off between a simple public API and additional backend infrastructure.
Interviewer may ask next
What would you change if collection sharing became very high volume?
I would keep the existing public request path and scale the asynchronous event path independently. The Google Maps client would still enter through the API Gateway, and the Collections Service would still own collection and sharing rules. When the service produces a sharing change, it would continue publishing the collection.shared event to Pub/Sub. The notification work shown in the diagram could then process more events without making the synchronous collection request wait for email or push delivery. Authentication, authorization scopes, rate limits, quotas, and request validation would remain at the API Gateway. The Collections Service would still decide whether the requested collection change is valid before publishing the event. Regional databases would remain the source of stored collection data. The main downside is that notification delivery is asynchronous, so a user may receive a notification after the collection change is already complete. That trade-off is acceptable because the diagram already separates event-driven notification work from the main request and response path.
How would you reduce database load when many users repeatedly read popular collections?
I would use the Memorystore caching component already shown in the design. The Collections Service would remain the owner of collection business logic, and the regional User Collections DB and Collection Items DB would remain the stored data sources. For suitable repeated reads, the service could use cached collection information instead of repeatedly doing the same database work. When the needed value is not available in cache, the service would read it from the regional data stores. The API Gateway would still perform authentication, authorization, rate limiting, quotas, and request validation before traffic reaches the service. The existing Places Service would still own place details and placeId validation. Cloud Logging, Cloud Monitoring, metrics, and tracing would show whether caching actually improves performance. The main downside is that cached information can become older than stored information. Because of that, I would treat the cache only as a performance layer and keep the regional databases as the durable data stores.
26. Design a managed pub/sub or message queue used internally across Google.API DesignHardGoogle
i Question Details
Keep the discussion on the message-ingest and publish/subscribe contract implied by the prompt, including how producers and consumers interact with the API boundary.
Short Interview Answer (30-60 seconds)
At a high level, I would build one managed service for durable publish and subscribe. Producers send PublishRequest calls through the Global Front Door over HTTPS and mTLS. The API Gateway handles authentication, authorization, rate limits, and request validation. The regional control plane manages topics, subscriptions, routing, quotas, and metadata. The multi-region data plane stores messages in replicated partition logs. Consumers pull or subscribe, receive messages through the API boundary, and acknowledge processing. The benefit is durable horizontal scale. The trade-off is replication and operational complexity.
Detailed Explanation
This question asks us to design one shared messaging system for many internal Google services. A producer should be able to send a message without knowing which consumer will process it. Consumers should receive those messages safely and reliably. The system should continue working when machines or zones fail. It also needs clear rules for publishing, subscribing, ordering, and acknowledging messages. I will follow the attached design from the client boundary, through validation and routing, into durable storage, and then back through message delivery and acknowledgment.
Useful Questions to Ask the Interviewer
Do we need both pull and streaming delivery for consumers?
Is ordering required only per key or partition?
Should at-least-once delivery be the normal behavior?
How long should undeliverable messages be retained?
How to Explain It in an Interview
1. Define the producer and consumer API boundary
I would start with one clear API boundary for producers and consumers. Producers send a PublishRequest to the Global Front Door over HTTPS with mTLS. The publish contract contains the topic, key, value, and attributes shown in the diagram. The Global Front Door provides Anycast load balancing and DDoS protection.
A PublishResponse returns from the Global Front Door to the producer with an ACK or error. Consumers also connect through the Global Front Door. They send a Pull / SubscribeRequest containing the topic, subscription, maxMessages, and ackDeadline. Pull responses, delivered messages, errors, and acknowledgments use separate directions so the contract stays clear.
2. Validate and protect requests at the API Gateway
The Global Front Door forwards traffic to the API Gateway. The gateway performs authentication, authorization, rate limiting, and request validation. Authentication checks who the caller is. Authorization decides whether that caller may perform the requested action.
The gateway uses the Identity Service for token and identity validation. The diagram shows Google IAM with OAuth2 and mTLS. Rate limits protect shared capacity from a noisy producer or consumer. Request validation blocks bad input before it reaches the messaging core.
3. Manage topics, subscriptions, routing, and quotas
Validated requests enter the regional Pub/Sub Control Plane. The Topic Service manages topics and subscriptions. The Subscription Service manages subscription metadata and configuration. The Routing Service performs partition assignment and load balancing. The Config & Quota Service manages quotas, limits, and feature flags. The Admin API supports internal management tools.
The control plane reads and writes metadata in Spanner. That metadata includes topics, subscriptions, ACLs, configuration, and quotas. Message payloads do not belong in this metadata store.
4. Persist published messages in the multi-region data plane
For a publish, the control plane sends the validated publish plus its partition and routing assignment into the Pub/Sub Data Plane. The data plane is divided into partitions. Each partition has a leader and followers and uses a chunked append-only log.
The diagram shows replication across three or more zones. It also shows asynchronous replication and durable flush into Colossus / GCS. That storage is durable, encrypted, and multi-region. Partitioning provides horizontal scale, while replication protects committed data from machine and zone failures.
5. Deliver messages and process acknowledgments
For consumption, the Pull / SubscribeRequest enters through the same client boundary. The system uses subscription metadata and the data plane to find the correct messages. Message delivery or the pull result returns through the Global Front Door to the consumer. Delivery can use streaming or batching.
After processing a message, the consumer sends ACK / ModifyAckDeadline back through the Global Front Door. An ACK marks successful processing. ModifyAckDeadline gives the consumer more time before the message becomes eligible for redelivery. The diagram uses at-least-once delivery by default, so consumers should tolerate duplicate delivery. Ordering is provided per key or partition rather than globally.
6. Explain reliability and operating support
The design includes monitoring and alerting through Cloud Monitoring and logging and audit through Cloud Logging. An Encryption Service provides key management with CMEK. A per-subscription Dead Letter Queue holds undeliverable messages. An optional Schema Registry supports Avro or Protobuf schemas.
The main trade-off is operational complexity. Multi-zone and multi-region replication improve durability, but they require more storage, coordination, and background replication. Partitioning gives high throughput and horizontal scale, but ordering is limited to a key or partition.
Why Interviewers Ask This
Interviewers use this question to test whether you can define a clear messaging API boundary and trace publish, consume, response, delivery, and acknowledgment flows correctly. They also want to see whether you separate control-plane metadata from message data, understand partitioning and replication, and place authentication, authorization, validation, and quotas in sensible components. Strong answers explain delivery semantics, ordering limits, durability, horizontal scaling, failure handling, and the trade-offs created by stronger replication.
Interviewer may ask next
What changes if message volume grows much faster than expected?
I would keep the client API unchanged and scale the partitioned data plane horizontally. Producers would still send PublishRequest calls through the Global Front Door and API Gateway. Consumers would still use Pull / SubscribeRequest and ACK / ModifyAckDeadline. The main changes would happen in the Routing Service and Pub/Sub Data Plane.
The Routing Service would assign traffic across more partitions and rebalance load when a partition becomes hot. New partitions would keep the same leader-and-followers model, append-only log, and replication across three or more zones. Monitoring and alerting would help detect hot partitions and capacity pressure.
Correctness stays the same because every published message still receives a partition and routing assignment before entering the data plane. Security also stays unchanged because traffic still crosses the same authentication, authorization, validation, and quota boundary.
The downside is more coordination. More partitions increase throughput, but they also increase routing metadata and rebalancing work. Ordering remains per key or partition instead of becoming global.
How would you handle messages that consumers repeatedly cannot process?
I would use the per-subscription Dead Letter Queue already shown in the design. The normal API flow would not change. Consumers still receive messages through the subscription flow and send ACK / ModifyAckDeadline after processing.
Messages that become undeliverable can be isolated in the Dead Letter Queue instead of remaining mixed with healthy delivery traffic. Monitoring and alerting can show that the dead-letter backlog is growing. Logging and audit can help operators understand what happened. Access still goes through the existing API boundary, so authentication, authorization, and subscription ACLs continue to protect the system.
The message data plane, partition replication, Spanner metadata, encryption service, and client contracts remain unchanged. This keeps the failure path separate from the main delivery path.
The downside is additional operational work. Teams need a process for inspecting and handling dead-lettered messages. The Dead Letter Queue also does not remove the need for consumers to tolerate duplicate delivery under the system's at-least-once semantics.
27. Explain what an API is to a completely non-technical person.API DesignEasyGoogle
i Question Details
Frame the explanation for a Google interview context, keep the audience non-technical, and define the minimum ideas the answer should cover without drifting into implementation details.
Short Interview Answer (30-60 seconds)
At a high level, I would explain an API as a messenger between an app and a service. In this example, the app asks for menu information with GET /menu over HTTPS. The API receives the request, checks that it is allowed, understands it, and sends it to the service. The service does the work and returns the result to the API. The API then sends 200 OK with the data back to the app. The benefit is that the API hides the service's complexity and gives both sides clear rules, although it adds another step to the request path.
Detailed Explanation
This question asks me to explain a technical idea in everyday language. Imagine that a person wants something from a service but does not need to know how that service works inside. The API sits between the person’s app and the service. It carries the request to the right place and brings the result back. The goal is to make communication simple, controlled, and easy to understand. I would follow the diagram from the person using the app, through the API, to the service, and then trace the answer back.
Useful Questions to Ask the Interviewer
Should I keep the explanation completely non-technical and use the restaurant analogy?
Should I explain only the basic request-and-response flow shown in the diagram?
How to Explain It in an Interview
1. Start with the restaurant analogy
I would say that an API is like a waiter in a restaurant. The customer does not walk into the kitchen and prepare the food. The customer tells the waiter what they want. The waiter takes that request to the kitchen. The kitchen does the work. Then the waiter brings the result back.
In the diagram, You / App is the customer. The API is the waiter. The Service / System is the kitchen. This gives a non-technical person the main idea before introducing any software terms.
2. The app sends a request
The request starts from You / App. The diagram shows the app sending an HTTPS request to the API. The example is GET /menu.
HTTPS means the communication is protected while it travels between the app and the API. For a non-technical explanation, the important idea is simply that the app asks for something in an agreed and protected way.
The request arrow points from the app to the API.
3. The API receives and checks the request
The API acts as the messenger. It receives the request, checks that it is allowed, understands what is being requested, and sends it to the correct place.
The diagram also says that an API has rules. The caller must make requests in a specific way and may need permission. The API therefore gives the app a clear way to communicate with the service.
It also hides complexity. The app does not need to know how the service works inside.
4. The API sends the request to the service
After handling the request, the API sends an Internal Call to the Service / System. The diagram labels this call as secure.
The service owns the actual work. In the restaurant analogy, this is the kitchen. The API carries the request, while the service performs the requested operation.
For the GET /menu example, the service would find the requested menu information and prepare the result.
5. The service returns the result
The service sends Data / Result back to the API through the response path shown in the diagram. The response arrow points from the service back to the API.
This is important because the request and response are separate directions. The API does not invent the result. It receives the result produced by the service and carries it back to the requester.
6. The API returns the response to the app
The API returns the response to You / App over HTTPS. The diagram shows 200 OK + Data, with menu items as the example. 200 OK means the shown request succeeded.
So the complete flow is: the app asks, the API receives and checks the request, the service does the work, the result returns to the API, and the API delivers it back to the app.
The main benefit is that the API gives software a simple set of rules while hiding the service's internal complexity. The trade-off is that the API adds another step in the communication path. The diagram does not show a failure response, retry path, or fallback, so I would not invent one.
Practical Complexity & Trade-offs
The main design choice is to put the API between the app and the service. The benefit is that the app gets one clear set of rules and does not need to understand how the service works inside. The API receives the request, checks that it is allowed, understands it, and sends it to the correct service. HTTPS protects the app-to-API communication, while the diagram also shows a secure internal call. The service returns the result to the API, and the API returns 200 OK with data when the shown request succeeds. The downside is that the API adds another step to the request path. We accept that extra step because it gives a cleaner communication boundary and hides service complexity from the caller.
Why Interviewers Ask This
The interviewer is testing whether I can explain a technical idea clearly without hiding behind jargon. They want to see that I understand the API boundary, the request and response directions, and the separate responsibilities of the app, API, and service. They may also look for basic judgment about clear rules and protected communication. A strong answer shows that I can simplify an engineering concept without making the explanation technically wrong.
Interviewer may ask next
What happens if many users send API requests at the same time?
The basic design stays the same. Each user still sends a request from the app to the API. The API still receives and checks the request, sends it to the service, and returns the service's result to the app. The request and response directions do not change.
What changes is the amount of work the API and service must handle. The diagram does not show extra servers, load balancers, queues, caches, or another scaling mechanism, so I would not add one to this design. I would simply say that both components would need enough capacity to handle the larger number of requests while keeping the same API rules.
The protected communication also stays the same. The app still uses HTTPS to reach the API, and the diagram's internal call remains secure.
The main downside of higher traffic is more pressure on the API and service. The diagram explains the communication model, but it does not define a particular scaling solution.
Why does the diagram use HTTPS and a secure internal call?
They protect the communication while keeping the same request-and-response flow. The app sends GET /menu to the API over HTTPS. The API then sends the request to the service through the secure internal call shown in the diagram. The service sends its Data / Result back to the API, and the API returns 200 OK + Data to the app over HTTPS.
For a non-technical person, I would explain this as carrying a message through protected channels instead of exposing it while it travels. The API also checks that the request is allowed before sending it to the service, which matches the responsibility shown in the diagram.
I would not add tokens, certificates, authentication servers, or other security technology because the diagram does not show them. The downside is that protected communication adds some setup and processing, but it gives better protection to the request and response without changing the basic API design.
28. Explain what an API is to a 6 year old.API DesignEasyGoogle
i Question Details
Use the reported Google prompt exactly as a simplified audience check, and keep the explanation age-appropriate without introducing jargon that a child would not know.
Short Interview Answer (30-60 seconds)
At a high level, I would explain an API using a restaurant. You are like the app, the API is like the waiter, and the service is like the kitchen. You tell the API what you want. The API carries that request to the service. The service does the work and sends the result back through the API. No security or reliability behavior is shown in this simple picture, so I would not invent it. The trade-off is that this child-friendly example leaves out many real API details.
Detailed Explanation
This question asks me to explain one simple idea to a young child. I need to show how one thing can ask another thing for help without knowing how the work is done. The picture uses a restaurant because that is easy to understand. You are the app, the waiter is the API, and the kitchen is the service. The goal is to explain the request going in and the answer coming back. I would follow those four steps exactly and avoid adding technical details that the picture does not show.
Useful Questions to Ask the Interviewer
Should I keep the explanation completely child-friendly?
Is the restaurant example enough, or should I briefly connect it back to apps?
How to Explain It in an Interview
1. Start with the restaurant idea
I would begin by saying, "An API is like a waiter at a restaurant." You want something, but you do not walk into the kitchen and make it yourself. Instead, you tell the waiter what you want. The waiter knows where to take your request and how to bring the result back. In the picture, this restaurant story shows how an app can ask a service to do something.
2. You place the order
The left side is labeled "YOU (the app)." The first arrow points from you toward the API. This is step 1: "You place an order." In simple words, the app asks for something it wants. The picture does not show a web address, request method, message format, login token, or other technical detail, so I would not add one.
3. The API carries the request
The middle person is labeled "API (the waiter)." Step 2 shows the API sending the request toward "SERVICE (the kitchen)." The picture says, "The waiter tells the kitchen." The API is the helpful middle person. It takes the request from the app and passes it to the service that can do the work. The app does not need to know how the kitchen works inside.
4. The service does the work
The right side is labeled "SERVICE (the kitchen)." Step 3 says, "The kitchen makes it." This means the service handles the work needed to create the answer. In the restaurant example, that work is making the food. The diagram does not name any technical operation, so I would keep the explanation at that simple level.
5. The answer comes back through the API
The response path goes back in the opposite direction. First, the service sends the result toward the API. Then step 4 shows the API returning it to you: "The waiter brings it back to you." The complete flow is app to API, API to service, service to API, and API back to the app.
6. End with the simple meaning
I would finish with the message at the bottom: an API is a helpful middle person. It takes your request, talks to the service that can do the work, and brings the answer back. The diagram also reminds us that you do not go into the kitchen yourself. The waiter gets it for you. This explanation is intentionally simple. The picture does not show security, failures, retries, status codes, databases, or other production details, so I would not invent them.
Practical Complexity & Trade-offs
The main design choice is to put the API between the app and the service, just like a waiter stands between a customer and a kitchen. The benefit is that the app can ask for something without knowing how the service does the work inside. The request moves from the app to the API, then to the service. The answer comes back through the API to the app. This keeps the explanation clear and separates asking for work from doing the work. The downside is that the restaurant example is intentionally simplified. It does not explain real API details such as web addresses, request formats, security, errors, or retries. We accept that because the interview question is testing whether the basic idea can be explained clearly to a six-year-old.
Why Interviewers Ask This
The interviewer is checking whether you truly understand the basic purpose of an API and can explain it without hiding behind technical words. They want to see whether you can model a clear request and response path, keep the app, API, and service roles separate, and choose an example that matches the listener's level. This tests communication judgment as much as technical knowledge. A strong engineer should make an idea simpler without changing its basic meaning.
Interviewer may ask next
What would happen if the kitchen could not make what you asked for?
The same basic path should still be used. The service, which is the kitchen in this example, would tell the API that it could not produce the requested result. The API would then carry that answer back to the app, just like a waiter would return to the table and explain that the kitchen cannot make the order. The important change is the result, not the direction of the flow. The request still goes from the app to the API and then to the service. The response still comes from the service to the API and then back to the app. I would not add retries, backup services, error numbers, or other behavior because none of those appear in the original diagram. Correctness is maintained by keeping the same response path and clearly telling the requester what happened. The downside is that this introduces a failure idea into an explanation that was originally meant to stay very simple for a child.
Why does the app use the API instead of going straight to the service?
In this diagram, the API is the helpful middle person between the app and the service. The restaurant picture explains that with a waiter. You do not walk into the kitchen and ask the cook directly. You tell the waiter what you want. The waiter passes the request to the kitchen and brings the result back. The same relationship is shown here. The app sends its request to the API, and the API carries it to the service. The service creates the result, and that result returns through the API to the app. The benefit is that the app can focus on asking for what it wants instead of dealing with the service's internal work. The main downside is that this child-friendly picture makes the API look like a separate person in the middle, while real API designs can be implemented in different ways. For this question, that simplification is useful because it matches the approved diagram and keeps the idea easy to understand.
29. How would you create a communication system from Earth to Mars? Core Components: API Gateway:API DesignMediumGoogle
i Question Details
Use the reported Google Prepfully prompt, keep the API gateway boundary explicit, and explain the request flow, contracts, and routing assumptions implied by the question.
Short Interview Answer (30-60 seconds)
At a high level, I would keep one clear API Gateway boundary on Earth. Earth clients send HTTPS requests using JWT or OIDC identity. The gateway handles TLS termination, authentication, authorization, rate limiting, request validation, routing, response shaping, caching, and audit logging. It routes commands, telemetry, schedules, and device requests to ASP.NET Core services. Commands use durable messaging before crossing the Deep Space Network with CCSDS. Telemetry and acknowledgements return toward Earth. The trade-off is accepting delayed, asynchronous communication so the system remains reliable across an intermittent interplanetary link.
Detailed Explanation
The goal is to let people and systems on Earth safely send commands to Mars and receive information back. The difficult part is distance. A message can take about 4 to 24 minutes one way, and the connection may not always be available. So this cannot work like a normal fast website where the user waits for Mars to answer. The design keeps one controlled entry point on Earth. It then uses internal services, durable messaging, and the Deep Space Network to move commands and telemetry reliably.
Useful Questions to Ask the Interviewer
Should a command return after Earth accepts it, or after Mars executes it?
How much command delay is acceptable?
Which Earth clients need API access?
How should duplicate command retries be handled?
Should telemetry use SSE, WebSocket, or both?
How to Explain It in an Interview
1. Define the Earth API Gateway boundary
I would put all public access through the Earth API Gateway. The clients are the Web Dashboard, Mobile App, Operations CLI, and external integrations. They send HTTPS requests using JWT or OIDC identity. The gateway terminates TLS, authenticates callers, checks roles or scopes, rate limits traffic, validates request schemas, routes requests, shapes responses, uses read-only caching where suitable, and records audit information. If authentication, authorization, or validation fails, the gateway rejects the request instead of sending it to an internal service.
2. Route requests to the ASP.NET Core services
The gateway sends each accepted request to the correct internal service. /v1/commands* goes to the Command Service. /v1/telemetry* goes to the Telemetry Service. /v1/schedules* goes to the Scheduling Service. /v1/devices* goes to the Device Registry Service. Read-only /v1/* requests may use cached data where possible. An unmatched route returns 404 Not Found. This keeps public routing rules in one place.
3. Keep the visible API contracts clear
The command contract uses POST /v1/commands. Its request contains deviceId, type, payload, priority, and scheduledAt. Its response contains commandId, status, and scheduledWindow. Telemetry uses GET /v1/telemetry/streams/{deviceId} with SSE or WebSocket streaming. Events contain values such as timestamp, device ID, and metrics. GET /v1/devices returns device information including device ID, type, status, and last-seen information.
4. Use durable messaging before the space link
The Command Service sends accepted work to the Command Queue, shown as Azure Service Bus. This supports store-and-forward behavior when the space link is delayed or unavailable. Idempotent commands and correlation IDs help detect repeated work after retries without claiming exactly-once delivery. Incoming telemetry uses the separate Telemetry Ingest path, shown as Event Hub. The Command DB, Telemetry DB, and Metadata DB keep command, time-series telemetry, and device metadata respectively.
5. Cross the Deep Space Network
Queued commands move toward the Deep Space Network as an uplink telecommand using CCSDS. The DSN relay forwards the uplink to the Mars rover, lander, or orbiter relay. This part is asynchronous because the interplanetary link has high latency. Durable queues and storage let Earth keep work safely until transmission is possible.
6. Bring telemetry and acknowledgements back
Mars sends telemetry and acknowledgements down through the DSN using CCSDS. Earth receives that data through the Telemetry Ingest flow. The Telemetry Service processes it and exposes it to clients. Client-facing responses return through the API Gateway as HTTPS JSON, while telemetry can be delivered through the shown streaming contract. Telemetry is eventually consistent because space data does not arrive instantly.
7. Cover security, operations, and the main trade-off
Azure AD or OIDC provides identity, while Key Vault holds secrets and keys. The design also includes centralized logging, Prometheus metrics, OpenTelemetry tracing, and Alertmanager alerts. The main benefit is reliability across a slow and intermittent link. The downside is that accepting a command on Earth does not mean Mars has already executed it. Clients must track command status and later acknowledgements instead of expecting an immediate Mars result.
Practical Complexity & Trade-offs
The benefit is that the Earth-facing API remains familiar even though communication with Mars is unusual. The API Gateway gives one place for TLS, identity checks, authorization, rate limits, validation, routing, caching, response shaping, and audit logging. Durable queues protect commands when the DSN link is unavailable. Idempotent commands and correlation IDs make retries safer. The downside is extra operational work. We must run queues, several services, databases, telemetry ingestion, monitoring, and delayed status tracking. Read-only caching improves some Earth-side reads, but it must not make changing data look newer than it is. Telemetry is eventually consistent because of space delay. We accept this complexity because a normal synchronous request model would not work well across a 4-to-24-minute one-way link.
Why Interviewers Ask This
The interviewer is checking whether the candidate can design an API around a difficult network instead of assuming every request is fast and synchronous. They want clear API boundaries, correct request and response directions, sensible routing, authentication and authorization, durable messaging, idempotency, and observability. They also want to see whether the candidate can separate the Earth HTTP contract from the CCSDS space-link contract and explain the reliability-versus-latency trade-off clearly.
Interviewer may ask next
What happens if the Deep Space Network link is unavailable for several hours?
I would keep the same API and use the existing store-and-forward design. The affected path is the Command Service to Command Queue to Deep Space Network flow. A valid POST /v1/commands request still enters through the API Gateway, where authentication, authorization, rate limiting, and schema validation remain unchanged. The Command Service records the command and places it in the durable Azure Service Bus queue. The command can stay there until a usable transmission window becomes available. The Scheduling Service can manage the planned window, while correlation IDs keep later acknowledgements connected to the original command. Idempotent command handling reduces the risk of duplicate execution if delivery is retried. Telemetry returning from Mars can also arrive later through the existing Telemetry Ingest path. The downside is stale status. Earth can know that the command was accepted and queued, but it cannot claim Mars received or executed it until a later acknowledgement arrives.
How would you prevent a retried command from being executed twice on Mars?
I would preserve the current command path and rely on the idempotent-command behavior already shown in the design. The affected flow is POST /v1/commands through the API Gateway, Command Service, Command Queue, DSN, and Mars side. The logical command should keep a stable command identity and correlation ID. When the same logical command appears again after a retry, the command-processing path can recognize that identity instead of treating the retry as unrelated work. The durable queue may still redeliver work, so consumers must be designed for repeated delivery rather than assuming exactly-once behavior. Authentication, authorization, rate limiting, and request validation at the gateway remain unchanged. Audit logging and command storage provide a record of what was accepted and processed. The downside is additional state and bookkeeping. Duplicate detection must be retained long enough to cover realistic retry and communication delays, which increases storage and operational complexity.
30. Design a live chat that delivers messages to all connected viewers of a YouTube live session.System DesignEasyGoogle
i Question Details
Use the Google system-design prompt and specify the message fan-out path, connected-client handling, and latency expectations for live viewers.
Short Interview Answer (30-60 seconds)
At a high level, this system accepts chat messages and delivers them quickly to every connected viewer in the same live session. The main challenge is fan-out because one message may need to reach millions of viewers. I would explain the send path, the fan-out path, and connected-client handling. Messages move through the Global Edge, Chat API Gateway, Chat Ingestion Service, and partitioned Message Queue. Fan-out workers then deliver them through WebSocket hubs. The trade-off is more complexity for better scale and availability.
Detailed Explanation
The goal is to let someone send a chat message during a live session and make that message appear quickly for every connected viewer. The difficult part is the size of the audience. One message may need to reach millions of people at almost the same time. The system also needs to know which viewers are still connected. The diagram separates accepting a message from delivering it. A queue connects those two parts, while WebSocket servers keep long-lived connections to viewers. This lets message delivery scale without making the sender wait for every viewer.
Useful Questions to Ask the Interviewer
How many viewers can one live session have at peak?
Should messages stay ordered inside each live session?
How long should recent chat messages be stored?
Are the shown p50 and p95 latency numbers our target?
Should the service run active-active across multiple regions?
How to Explain It in an Interview
1. Start with clients and the Global Edge
I would first separate sending from receiving. Web and mobile viewers send chat messages over HTTPS and receive live updates over secure WebSockets, or WSS.
Traffic enters through the Global Edge. It handles DNS, CDN or Anycast routing, WAF protection, DDoS protection, and TLS termination. The Chat API Gateway then handles Authentication, Authorization for the live session, Input Validation and Sanitization, Rate Limiting, and Request Routing.
2. Accept and publish the message
For the send path, the Chat Ingestion Service creates the chat message. It adds the user, session, timestamp, and metadata shown in the diagram.
The service can save recent messages and then publishes an event to the Message Queue. The queue is partitioned by LiveSessionId. This helps keep messages ordered within one live session. After the request is accepted, the path returns a 202 Accepted acknowledgment.
The Chat Store keeps short-term chat history for history and replays. The diagram shows it as a scalable NoSQL or caching database.
3. Fan out to connected viewers
For delivery, Chat Fan-out Workers consume events from the Message Queue. The diagram shows these as .NET BackgroundService workers.
The workers can format, enrich, moderate, and filter messages. They then fan each message out to the WebSocket hubs serving connections for that live session. The WebSocket Connection Servers scale horizontally, so more servers can be added as the number of connected viewers grows.
4. Track connections and handle failures
The Connection Registry is a distributed cache. It maps a LiveSessionId to its active connection set. This helps the delivery layer find the viewers that should receive each message.
Clients can reconnect with exponential backoff after a disconnect. Heartbeats and idle-timeout cleanup remove dead connections. WebSocket servers can scale behind L4 or L7 load balancing.
If workers cannot keep up, the design uses backpressure and retries. After the maximum retries, failed messages go to the Dead Letter Queue. Because delivery is at-least-once, consumers use message IDs to avoid showing duplicates.
5. Explain latency, scale, and operations
The diagram targets about 100 to 300 ms p50 end-to-end latency and less than 1,000 ms at p95. It also shows multi-region active-active operation for high availability.
Operations use Prometheus metrics, ELK or OpenSearch logs, OpenTelemetry traces, PagerDuty alerts, and Grafana dashboards. The main trade-off is extra operational complexity. Queues, connection tracking, retries, and many WebSocket servers add moving parts, but they let the system support very large live audiences.
Engineering Considerations / Design Trade-offs
The benefit is that sending and delivery can scale separately. The sender does not wait while the system pushes the message to every viewer. Partitioning the Message Queue by LiveSessionId also helps preserve ordering inside one live session. The downside is more complexity. We need fan-out workers, many WebSocket servers, a Connection Registry, retries, and a Dead Letter Queue. At-least-once delivery can also send a message more than once, so consumers must detect duplicate message IDs. Multi-region active-active operation improves availability, but it makes the system harder to operate.
Why Interviewers Ask This
Interviewers ask this question to see whether you can break a real-time system into clear flows. They want to know if you understand fan-out, WebSocket connections, queues, partitioning, retries, and horizontal scaling. They also look for good judgment around latency, rate limits, duplicate delivery, connection tracking, failures, and operational trade-offs. A strong answer explains why each choice is needed instead of only naming technologies.
Interviewer may ask next
What would you change if one live session suddenly had millions of connected viewers?
I would keep the same basic design and scale the parts already built for fan-out. The Message Queue would still partition messages by LiveSessionId, and the Chat Fan-out Workers would continue consuming those events. The main change would be adding more WebSocket Connection Servers for the very large audience.
The Connection Registry would still map the LiveSessionId to its active connection set. The delivery layer would use that information to reach the WebSocket hubs holding connections for that session. Because the diagram already uses horizontal scaling, we can add more connection servers instead of forcing one server to hold every viewer.
I would watch queue delay, worker processing, connection counts, and latency with the existing observability tools. The design stays correct because the same fan-out and connection-tracking flow remains in place. The downside is higher cost and more operational work because a huge session needs many network connections and delivery resources.
What happens if a Chat Fan-out Worker keeps failing while processing a message?
I would use the retry path already shown in the diagram. The Chat Fan-out Worker retries failed processing while the system applies backpressure so workers do not take more work than they can handle safely.
If the message still fails after the maximum retries, it goes to the Dead Letter Queue. This keeps a repeatedly failing message away from normal traffic, so other chat messages can continue moving through the system.
The Message Queue uses at-least-once delivery. That means a retry can cause the same message to appear more than once unless the consumer checks it. The design therefore uses message IDs so consumers can safely ignore duplicates.
Prometheus metrics, logs, OpenTelemetry traces, PagerDuty alerts, and Grafana dashboards help operators find the problem. The downside is that retries can delay the affected message, and Dead Letter Queue items require operational attention.
More questions load as you scroll
Disclaimer: This interview guide is for educational and informational purposes only. It is designed to help readers prepare, but it does not guarantee any interview result, hiring decision, offer, or outcome. Interview questions, hiring criteria, and preferred answers can vary by employer, interviewer, industry, location, and time. The examples and explanations reflect the authors' research and judgment, are provided without warranties of any kind, and should not be treated as the only correct approach. Diagrams are simplified illustrations intended to highlight the main components and their interactions; actual systems and implementations may be more complex. Alternative approaches may be equally valid or better suited to a particular question, context, or interviewer. To the fullest extent permitted by applicable law, the author, contributors, and publisher are not liable for decisions made, actions taken, or losses incurred based on this guide.
Company Notice: This guide is an independent educational resource and is not affiliated with, endorsed by, sponsored by, or approved by the company named in this guide. Company names are used only to identify interview experiences commonly reported by candidates. Interview practices can change without notice, and inclusion of company-specific content does not mean these questions are official, complete, or guaranteed to be asked. To the fullest extent permitted by law, the author, contributors, and publisher are not responsible for outcomes related to use of this material.