VHow would you split a monolith into services without breaking data consistency?
سؤال المقابلالخدمات المصغّرة
نادرًا ما يريد المحاورون قائمة بالأنماط. هم يريدون أن يسمعوا كيف تتخذ قرارك: متى يستحق تقسيم الخدمات كلفته، وكيف تحافظ على اتساق البيانات دون قاعدة بيانات واحدة.
استخدم الإطار نفسه في كل مرة: المشكلة، ثم النمط، ثم المفاضلة. وإذا استطعت أن تضيف «لن أفعل هذا لفريق صغير»، فستبدو كمن رأى أنظمة حقيقية.
- ✓كلمات → عبارات → جمل → تحدث
- ✓معنى الإجابة
- ✓اللغة
أكثر الأسئلة تكرارًا ونماذج الإجابات
How would you split a monolith into services without breaking data consistency?
كيف تقسّم تطبيقًا أحاديًا (monolith) إلى خدمات دون الإخلال باتساق البيانات؟
ما الذي يريد المحاور سماعه. نهج تدريجي، وحدود واضحة، ونظرة صادقة إلى مسألة الاتساق.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI would not rewrite everything at once. First I find the business boundaries, for example orders, payments and users, and I move one of them out using the strangler approach: new traffic goes to the new service, and the old code stays until it is not needed. Each service should own its data, so I stop sharing tables. Where a business action touches several services, I use a saga with compensating steps instead of one big transaction. I also accept that some data will be consistent only eventually, so the product team must agree with that.
What is a saga, and when would you use one?
ما نمط Saga ومتى تستخدمه؟
ما الذي يريد المحاور سماعه. التنسيق المركزي (orchestration) مقابل التنسيق التفاعلي (choreography)، والإجراءات التعويضية.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍA saga is a way to run a business process across several services without a distributed transaction. The process is split into local transactions. If one step fails, we run compensating actions for the steps that were already completed, for example refunding a payment. There are two styles. In choreography, services react to each other's events. In orchestration, one coordinator tells each service what to do. I prefer orchestration for longer flows, because the logic is in one place and easier to debug. Every step must be idempotent, because messages can arrive twice.
When do you choose synchronous calls, and when asynchronous messaging?
متى تختار الاستدعاءات المتزامنة، ومتى تختار الرسائل غير المتزامنة؟
ما الذي يريد المحاور سماعه. الترابط (coupling) والمرونة في مواجهة الأعطال وما يراه المستخدم.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI use synchronous calls, like REST or gRPC, when the caller needs the answer to continue, for example to check a price. The cost is coupling: if the other service is slow or down, the caller suffers. I use asynchronous messaging when the work can happen later, or when many services care about the same event, for example 'order created'. It gives better resilience and scaling, but debugging is harder, and the user may see data that is not updated yet. In many systems I combine both: a synchronous call at the edge and events inside.
What is a circuit breaker?
ما قاطع الدائرة (circuit breaker)؟
ما الذي يريد المحاور سماعه. الحالات الثلاث، ولماذا يحمي الجهة المستدعية من الفشل.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍA circuit breaker protects a service from a failing dependency. It watches the calls. When the number of errors or timeouts becomes too high, the circuit opens, and the next calls fail immediately or use a fallback instead of waiting. After some time, it lets a few test calls through, and if they succeed, it closes again. This stops a slow dependency from using all our threads and spreading the failure to other services. I combine it with timeouts and limited retries. Libraries like Resilience4j make this easy in Java.
How do you find a problem in a request that goes through many services?
كيف تجد مشكلة في طلب يمر عبر خدمات كثيرة؟
ما الذي يريد المحاور سماعه. السجلات والمقاييس والتتبع، وعادة إضافتها في وقت مبكر.
نموذج إجابة بالإنجليزية للتدرّب عليه بصوت عالٍI rely on three things: logs, metrics and distributed tracing. Every request gets a trace ID at the entry point, and each service passes it on and writes it to the logs. With a tool like OpenTelemetry and a tracing backend, I can see the whole path of one request and where the time was spent. Metrics like latency and error rate per service tell me where to look first. Without this, a microservice system is almost impossible to debug, so I add it from the beginning, not after the first incident.
كيف تنطق المصطلحات الأساسية
- microservices
- مَايْكْرُوسِرْڤِسِز
- idempotent
- أَيْدِمْبُوتِنْت
- eventual consistency
- إِڤِنْتْشُوَل كُنْسِسْتِنْسِي
- saga
- سَاغَا
- latency
- لَيْتِنْسِي
- resilience
- رِزِلْيِنْس
عبارات مفيدة للإجابة
- The main trade-off is…المفاضلة الرئيسة هي…
- I would start with a modular monolith.كنت سأبدأ بتطبيق أحادي مبني على وحدات (modular monolith).
- Each service owns its data.كل خدمة تملك بياناتها.
- We accepted eventual consistency here because…قبلنا هنا بالاتساق النهائي (eventual consistency) لأن…
- It depends on how much failure the business can accept.هذا يعتمد على مقدار الإخفاق الذي يستطيع النشاط التجاري تحمّله.
- I would add a timeout and a limited retry.كنت سأضيف مهلة زمنية (timeout) وإعادة محاولة محدودة.
أخطاء شائعة
- التوصية بالخدمات المصغرة لكل مشكلة. الإجابة الجيدة تذكر متى يكون التطبيق الأحادي هو الخيار الأفضل، مثل الفريق الصغير أو المجال غير الواضح.
- الحديث عن الأنماط دون قصة عن الأعطال. اشرح ما يحدث عندما تتوقف إحدى الخدمات.
- نسيان البيانات. كثير من مشكلات الخدمات المصغرة هي مشكلات بيانات، لذا قل من يملك البيانات.
- نسيان الناس. الخدمات تتبع هيكل الفرق، لذا اذكر الملكية (ownership) ونوبات الاستجابة المناوبة (on-call).
الأسئلة الشائعة
هل أوصي بالخدمات المصغرة في المقابلة؟
أوصِ بما يناسب الحالة، وأظهر أنك تفهم الكلفة. يتوقع كثير من المحاورين أن تبدأ بتطبيق أحادي مبني على وحدات ثم تقسّمه لاحقًا.
أي الأدوات أذكر؟
الأدوات التي استخدمتها فعلًا، مثل Kafka أو RabbitMQ للرسائل، وKubernetes للنشر، وOpenTelemetry للتتبع. لا تسرد أدوات قرأت عنها فقط.
كيف أشرح الاتساق النهائي لشخص غير تقني؟
استخدم مثالًا من الحياة اليومية: تحويل مصرفي يظهر «قيد المعالجة» لبضع ثوانٍ. النظام صحيح، وإنما تتأخر الشاشات لحظة في اللحاق به.
قراءة الإجابة ليست مثل قولها. تدرّب على كل سؤال بصوت عالٍ، ثم قارن معنى إجابتك ولغتها بالنموذج.
جرّب SpeakRole ↗موضوعات أخرى في هذا المجال