VDesign a URL shortener. Where are the bottlenecks?
Senso della risposta✓
Lingua2
Domanda dell’intervistatoreSystem design
Non esiste un solo progetto giusto. Chi ti intervista valuta come chiarisci il problema, come ragioni sui numeri e come spieghi i compromessi. Parlare in un ordine chiaro conta più che nominare molte tecnologie.
Usa una struttura fissa e dichiarala a voce alta: requisiti, numeri approssimativi, un progetto semplice, poi i colli di bottiglia e come scalare. Quando dici "now I will estimate the load", l'intervistatore ti segue e tu guadagni un momento per pensare.
- ✓Parole → espressioni → frasi → parlato
- ✓Senso della risposta
- ✓Lingua
Domande comuni e risposte di esempio
Design a URL shortener. Where are the bottlenecks?
Progetta un URL shortener (un servizio che accorcia i link). Dove sono i colli di bottiglia?
Che cosa vuole sentire l'intervistatore. Prima le domande di chiarimento, poi un progetto semplice, infine il vero collo di bottiglia: le letture e i codici univoci.
Risposta di esempio in inglese da esercitare ad alta voceFirst I clarify the requirements: how many new links per day, how many redirects, and whether links expire. Let us say 100 million new links a month and a hundred times more reads. The design is simple: an API to create a link, a service that generates a unique short code, a database that maps the code to the URL, and a redirect service with a cache. Reads are the main load, so I put a cache in front of the database and use a store that scales for key-value access. The hard part is generating unique codes without collisions, for example with ranges of a counter given to each server, and base-62 encoding. I would also add rate limiting against abuse.
How do you structure your answer in a system design interview?
Come strutturi la risposta in un colloquio di system design?
Che cosa vuole sentire l'intervistatore. Un ordine ripetibile che dichiari a voce alta.
Risposta di esempio in inglese da esercitare ad alta voceI follow the same order every time. First, I ask about requirements, both functional and non-functional, like latency and availability. Second, I make a rough estimate of the traffic and the storage, so I know the scale. Third, I draw a simple high-level design with the main components and the data model. Then I go deeper into the part that matters most, usually the data store or the bottleneck. At the end I discuss failure, monitoring and how the system can grow. I say each step aloud, so the interviewer can follow my thinking and guide me.
How would you use a cache, and what are the risks?
Come useresti una cache e quali sono i rischi?
Che cosa vuole sentire l'intervistatore. Un pattern chiamato per nome, la scadenza dei dati e almeno due rischi reali.
Risposta di esempio in inglese da esercitare ad alta voceI would use a cache for data that is read often and changes rarely. The most common pattern is cache-aside: the application checks the cache first, and on a miss it reads from the database and saves the result with a time to live. The risks are stale data, a cache stampede when a popular key expires and many requests hit the database together, and an unclear invalidation strategy. To reduce these risks, I choose a sensible expiry time, add a small random variation to it, and decide how much stale data the business accepts.
How do you scale a database?
Come scali un database?
Che cosa vuole sentire l'intervistatore. Un ordine sensato: prima i passi semplici, poi le repliche, poi lo sharding con il suo costo.
Risposta di esempio in inglese da esercitare ad alta voceI start with the simplest options: better indexes, query tuning and a bigger machine. Then I add read replicas, which help when reads dominate, but replicas can lag behind the primary. When writes or data size become the problem, I use sharding: splitting data by a key, such as a user ID, across several databases. Sharding brings complexity. Queries across shards are hard, and moving data between shards is painful. So I pick the shard key carefully and delay sharding until it is really needed.
How do you talk about trade-offs and consistency?
Come parli di compromessi e di coerenza?
Che cosa vuole sentire l'intervistatore. Ogni decisione detta insieme al suo costo e legata al prodotto.
Risposta di esempio in inglese da esercitare ad alta voceI try to say each decision together with its cost. For example, I choose eventual consistency for a news feed, because it gives lower latency and higher availability, and users can accept a delay of a few seconds. For payments, I choose strong consistency, because correctness is more important than speed. When a network partition happens, a distributed system must choose between consistency and availability, and I explain which one the business prefers for each part of the system. This shows that I think about the product, not only about technology.
Come pronunciare i termini chiave
- scalability
- schèi-la-bìl-i-ti
- sharding
- shàr-ding
- cache
- cash
- availability
- a-vèi-la-bìl-i-ti
- latency
- lèi-ten-si
- bottleneck
- bòt-ol-nec
Frasi utili per rispondere
- Let me clarify the requirements first.Prima chiariamo i requisiti.
- Can I assume that…?Posso ipotizzare che…?
- Let me do a rough estimate.Faccio una stima approssimativa.
- The main bottleneck here is…Il principale collo di bottiglia qui è…
- The trade-off is…, so I would choose…Il compromesso è…, quindi sceglierei…
- To summarise the design,Per riassumere il progetto,
- If we have time, I would go deeper into…Se avremo tempo, approfondirei…
Errori comuni da evitare
- Iniziare a disegnare senza fare domande. Dedica i primi minuti ai requisiti.
- Restare in silenzio mentre pensi. Di' "I need a moment to think about the data model", così l'intervistatore sa che stai lavorando.
- Nominare molte tecnologie senza motivarle. Scegline una e spiega perché è adatta.
- Ignorare guasti e monitoraggio. Una frase su che cosa succede quando un nodo si ferma dimostra esperienza.
Domande frequenti
Servono i numeri in un colloquio di system design?
Sì, approssimativi. Dillo a voce alta: richieste al secondo, spazio di archiviazione all'anno. Non devono essere esatti, ma mostrano che pensi alla scala.
Che cosa faccio se non conosco una tecnologia citata dall'intervistatore?
Dillo, poi ragiona a partire dalle proprietà che ti servono: "I have not used it, but if it is a key-value store with low latency, I would use it for…"
Per quanto tempo posso parlare senza pause?
Non più di uno o due minuti. Fermati nei punti naturali e chiedi: "Does this direction make sense to you?"
Leggere una risposta non è la stessa cosa che dirla. Esercita ogni domanda ad alta voce, poi confronta il significato e la lingua della tua risposta.
Prova SpeakRole ↗Altri argomenti in quest’area