تمرین ۱ — lag را به دام بیندازExercise 1 — trap the lag
replica lag و consistency تجربهٔ کاربر مستقیماً به طراحی مرتبطاند؛ نصب replica را به مسیر آزمایشگاهی منتقل میکنیم.A useful consistency discussion; replica setup belongs in the lab.
نسخهٔ بازبینیشده برای مصاحبهReviewed interview brief
بعد از ویرایش پروفایل، یک read replica مقدار قدیمی برمیگرداند. read-your-writes، monotonic reads و causal consistency را با history کوتاه نشان بده. routing به primary، session stickiness و version/LSN barrier را مقایسه کن و برای lag بیحد fallback تعریف کن.Show read-your-writes, monotonic-read and causal anomalies after profile changes. Compare primary routing, stickiness and version/LSN barriers, including fallback when lag has no known bound.
معیار پاسخ خوبWhat a good answer demonstrates
- زمان ثابت sleep را تضمین consistency نمیداندNo fixed sleep guarantee
- دو replica را با version دنبال میکندVersion-aware routing
- قیمت تازگی را در latency و availability میبیندFreshness/availability trade-off
پیگیری مصاحبه:Interview follow-up: اگر primary بعد از ACK خراب شود، read-your-writes چه وابستگیای به replication durability دارد؟If the primary fails after ACK, how does read-your-writes depend on replication durability?
آزمایشگاه تکمیلی · زمان تقریبی ۳–۶ ساعتExtended hands-on laboratory · estimated 3–6 hours
یک اسکریپتِ ساده بنویس که به یک پایگاه دادهِ تکرهبرِ ناهمزمان (مثلاً PostgreSQL با یک read replica) نوشته و بلافاصله از follower بخواند. lag را اندازه بگیر و بعد هر سه ناهنجاری را عمداً بازتولید کن: خواندنِ نوشتهٔ خودت، عقبگردِ زمان (دو خواندن از دو replica)، و جابهجاییِ ترتیبِ علّی. برای هرکدام یک راهحلِ عملی پیاده کن و نشان بده ناهنجاری رفع شده است.
Write a small script that writes to an async single-leader database (e.g. PostgreSQL with one read replica) and immediately reads from the follower. Measure the lag, then deliberately reproduce all three anomalies: reading your own writes, time moving backward (two reads from two replicas), and swapped causal order. Implement one practical fix for each and show the anomaly gone.
برای یادگیریِ عمیق است؛ انجام کاملش در زمان بحثِ مصاحبه انتظار نمیرود.The full laboratory is optional depth work and is not expected within the discussion time.
ارزیابی، سطح و شواهد این تمرینAssessment, level and evidence · حل آموزشی این تمرینWorked solution · Amazon · SDE III interview preparation · Atlassian · engineering interview handbook