VDesign a URL shortener. Where are the bottlenecks?
سؤال المقابلتصميم الأنظمة
لا يوجد تصميم واحد صحيح. يقيّم المحاورون كيف توضّح المسألة، وكيف تفكر بالأرقام، وكيف تشرح المفاضلات. التحدث بترتيب واضح أهم من ذكر تقنيات كثيرة.
استخدم بنية ثابتة وقلها بصوت عالٍ: المتطلبات، ثم أرقام تقريبية، ثم تصميم بسيط، ثم الاختناقات وكيفية التوسّع. عندما تقول "now I will estimate the load" يستطيع المحاور متابعتك، وتكسب لحظة للتفكير.
- ✓كلمات → عبارات → جمل → تحدث
- ✓معنى الإجابة
- ✓اللغة
أكثر الأسئلة تكرارًا ونماذج الإجابات
Design a URL shortener. Where are the bottlenecks?
صمّم مختصِر روابط (URL shortener). أين تقع الاختناقات؟
ما الذي يريد المحاور سماعه. أسئلة توضيحية أولًا، ثم تصميم بسيط، ثم الاختناق الحقيقي: القراءات والرموز الفريدة.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍFirst 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?
كيف تبني إجابتك في مقابلة تصميم الأنظمة؟
ما الذي يريد المحاور سماعه. ترتيب ثابت يمكن تكراره في كل مرة، وتقوله بصوت عالٍ أثناء الإجابة.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI 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?
كيف تستخدم ذاكرة التخزين المؤقت (cache) وما مخاطرها؟
ما الذي يريد المحاور سماعه. نمط مسمّى، ومدة صلاحية، وخطران حقيقيان على الأقل.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI 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?
كيف توسّع قاعدة بيانات؟
ما الذي يريد المحاور سماعه. ترتيب معقول: الخطوات البسيطة أولًا، ثم النسخ المتماثلة، ثم التجزئة (sharding) مع كلفتها.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI 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?
كيف تتحدث عن المفاضلات والاتساق؟
ما الذي يريد المحاور سماعه. ذكر كل قرار مع كلفته، وربطه بالمنتج لا بالتقنية وحدها.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI 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.
كيف تنطق المصطلحات الأساسية
- scalability
- سْكَيْلَبِلِتِي
- sharding
- شَارْدِنغ
- cache
- كَاش
- availability
- أَڤَيْلَبِلِتِي
- latency
- لَيْتِنْسِي
- bottleneck
- بُتِلْنِك
عبارات مفيدة للإجابة
- Let me clarify the requirements first.دعني أوضّح المتطلبات أولًا.
- Can I assume that…?هل يمكنني افتراض أن…؟
- Let me do a rough estimate.دعني أجري تقديرًا تقريبيًا.
- The main bottleneck here is…عنق الزجاجة الرئيس هنا هو…
- The trade-off is…, so I would choose…المفاضلة هي…، لذلك كنت سأختار…
- To summarise the design,لألخّص التصميم،
- If we have time, I would go deeper into…إذا توفر لدينا الوقت، فسأتعمق أكثر في…
أخطاء شائعة
- البدء بالرسم قبل طرح الأسئلة. اقضِ الدقائق الأولى في المتطلبات.
- الصمت أثناء التفكير. قل "I need a moment to think about the data model" ليعرف المحاور أنك تعمل.
- ذكر تقنيات كثيرة دون أسباب. اختر واحدة واشرح لماذا تناسب.
- إهمال الأعطال والمراقبة. جملة واحدة عما يحدث عند تعطل عقدة (node) تدل على الخبرة.
الأسئلة الشائعة
هل أحتاج إلى أرقام في مقابلة تصميم الأنظمة؟
نعم، لكن أرقامًا تقريبية. انطقها بصوت عالٍ: عدد الطلبات في الثانية وحجم التخزين في السنة. لا يشترط أن تكون دقيقة، لكنها تُظهر أنك تفكر في حجم النظام.
ماذا لو لم أعرف تقنية يذكرها المحاور؟
قل ذلك، ثم استنتج من الخصائص التي تحتاجها: "I have not used it, but if it is a key-value store with low latency, I would use it for…"
كم يمكنني التحدث دون توقف؟
لا أكثر من دقيقة أو دقيقتين. توقف عند نقاط طبيعية واسأل: "Does this direction make sense to you?"
قراءة الإجابة ليست مثل قولها. تدرّب على كل سؤال بصوت عالٍ، ثم قارن معنى إجابتك ولغتها بالنموذج.
جرّب SpeakRole ↗موضوعات أخرى في هذا المجال