VDesign a URL shortener. Where are the bottlenecks?
Pytanie rekruteraSystem design
Nie istnieje jeden słuszny projekt. Rekruterzy oceniają, jak doprecyzowujesz zadanie, jak rozumujesz o liczbach i jak wyjaśniasz kompromisy. Mówienie w jasnej kolejności jest ważniejsze niż wymienianie wielu technologii.
Użyj stałej struktury i wypowiadaj ją na głos: wymagania, przybliżone liczby, prosty projekt, a potem wąskie gardła i skalowanie. Gdy powiesz "now I will estimate the load", rekruter może za tobą nadążyć, a ty zyskujesz chwilę na namysł.
- ✓Słowa → zwroty → zdania → mówienie
- ✓Sens odpowiedzi
- ✓Język
Częste pytania i przykładowe odpowiedzi
Design a URL shortener. Where are the bottlenecks?
Zaprojektuj skracacz linków (URL shortener). Gdzie są wąskie gardła?
Co chce usłyszeć rekruter. Najpierw pytania doprecyzowujące, potem prosty projekt, a na końcu prawdziwe wąskie gardło: odczyty i unikalne kody.
Przykładowa odpowiedź po angielsku do ćwiczenia na głosFirst 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?
Jak strukturyzujesz odpowiedź na rozmowie o system design?
Co chce usłyszeć rekruter. Powtarzalna kolejność, którą wypowiadasz na głos.
Przykładowa odpowiedź po angielsku do ćwiczenia na głosI 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?
Jak wykorzystać cache i jakie wiążą się z nim ryzyka?
Co chce usłyszeć rekruter. Nazwany wzorzec, czas wygasania wpisów i co najmniej dwa realne ryzyka.
Przykładowa odpowiedź po angielsku do ćwiczenia na głosI 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?
Jak skalować bazę danych?
Co chce usłyszeć rekruter. Rozsądna kolejność: najpierw proste kroki, potem repliki, potem sharding wraz z jego kosztem.
Przykładowa odpowiedź po angielsku do ćwiczenia na głosI 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?
Jak mówisz o kompromisach i spójności?
Co chce usłyszeć rekruter. Każda decyzja wyrażona razem z jej kosztem i powiązana z produktem.
Przykładowa odpowiedź po angielsku do ćwiczenia na głosI 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.
Jak wymawiać kluczowe terminy
- scalability
- skej-la-BIL-i-ti
- sharding
- SZAR-ding
- cache
- kesz
- availability
- a-wej-la-BIL-i-ti
- latency
- LEJ-ten-si
- bottleneck
- BOT-l-nek
Przydatne zwroty do odpowiedzi
- Let me clarify the requirements first.Najpierw doprecyzujmy wymagania.
- Can I assume that…?Czy mogę założyć, że…?
- Let me do a rough estimate.Zrobię przybliżone oszacowanie.
- The main bottleneck here is…Głównym wąskim gardłem jest tu…
- The trade-off is…, so I would choose…Kompromis polega na tym, że…, dlatego wybiorę…
- To summarise the design,Podsumowując projekt:
- If we have time, I would go deeper into…Jeśli starczy czasu, zagłębię się w…
Typowe błędy
- Zaczynanie rysowania bez zadania pytań. Pierwsze minuty poświęć na wymagania.
- Milczenie podczas myślenia. Powiedz "I need a moment to think about the data model", żeby rekruter wiedział, że pracujesz.
- Wymienianie wielu technologii bez uzasadnienia. Wybierz jedną i wyjaśnij, dlaczego pasuje.
- Pomijanie awarii i monitoringu. Jedno zdanie o tym, co się dzieje, gdy węzeł padnie, pokazuje doświadczenie.
Najczęstsze pytania
Czy na rozmowie o system design są potrzebne liczby?
Tak, przybliżone. Mów je na głos: żądania na sekundę, ilość danych w skali roku. Nie muszą być dokładne, ale pokazują, że myślisz o skali.
Co zrobić, jeśli nie znam technologii, którą wymienia rekruter?
Powiedz o tym i rozumuj od potrzebnych ci właściwości: "I have not used it, but if it is a key-value store with low latency, I would use it for…"
Jak długo można mówić bez przerwy?
Nie dłużej niż minutę lub dwie. Zatrzymuj się w naturalnych miejscach i pytaj: "Does this direction make sense to you?"
Przeczytać odpowiedź to nie to samo, co ją wypowiedzieć. Przećwicz każde pytanie na głos, a potem porównaj sens i język własnej odpowiedzi.
Wypróbuj SpeakRole ↗Inne tematy w tym obszarze