DDIA·واژه‌هاTERMS

نقشه راهRoadmap/ واژه‌نامهGlossary/ فصل ۱۳Chapter 13

۱۳13فلسفهٔ سیستم‌های جریانیA Philosophy of Streaming Systems

۸ واژه از فصل ۱۳ — هر کدام با یک مثال روزمره، یک نمودار و تلهٔ رایج.8 terms from chapter 13, each with an everyday example, a diagram and the usual trap.

compensating transaction

تراکنش جبرانی فصل ۱۳Chapter 13 · دیدن در متنsee in context

پول را دادی، بعد پشیمان شدی. حالا برش گردان.You paid, then changed your mind. Now undo it.

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

بلیت قطار می‌خری و دقیقهٔ بعد پشیمان می‌شوی. بلیت کنسل می‌شود، ولی در حساب تو «هیچ‌کدام نشده» ثبت نمی‌شود؛ یک ردیف خرید به مبلغ X و یک ردیف برگشت به مبلغ X داری. بانک چیزی را پاک نکرد؛ دو عملِ متقابل ثبت کرد.You buy a train ticket, then change your mind a minute later. The ticket is cancelled, but your statement does not say nothing happened. It shows a purchase of X and a refund of X. The bank deleted nothing; it recorded two opposing actions.

تشبیه و تصویر ذهنیThe analogy

کافه‌ای را تصور کن که سفارش را ثبت کرده، قهوه را درست کرده، و پول را گرفته است. مشتری پشیمان می‌شود. کاری که باید بکنی سه چیز است: پول را برگردانی، قهوه را دور بریزی، و در دفتر یک ردیفِ برگشت بنویسی. هیچ‌کدام از اینها کار را «نشد» نمی‌کند؛ همه‌شان اثر آن را خنثی می‌کنند و یک رد پا باقی می‌گذارند. تفاوت مهم همین است: برگشتِ واقعی اثر را پاک می‌کند و تاریخ را جعل می‌کند، جبران اثر را متعادل می‌کند و تاریخ را صادق نگه می‌دارد.Picture a café that has taken the order, made the coffee and charged the customer. The customer changes their mind. You have three jobs: refund the money, pour out the coffee, and write a reversal line in the ledger. None of them makes the order “not happen”; they all cancel its effect and leave a trace. That is the important difference: a true rollback erases the effect and falsifies history, a compensation balances the effect and keeps history honest.

رزروreserveاتاق گرفته شدroom heldپرداختpayپول کم شدmoney takenخطاfailureادامه ممکن نیستcannot continueبرگشتrefundدو ردیف متقابلtwo reversing rows
هر قدم یک قدمِ جبرانی دارد؛ اثر متعادل می‌شود، تاریخ پاک نمی‌شود.Every step has an inverse; the effect balances, the history stays.

و بعدش، فنیAnd now, technically

وقتی یک عمل به چند سرویس می‌رسد و تراکنش توزیع‌شده در کار نیست، هر قدم باید یک قدمِ متضاد داشته باشد که اثرش را خنثی کند. زنجیرهٔ این قدم‌ها همان الگوی saga است. سه ویژگی لازم است. اول، جبران باید تکرارپذیر باشد؛ چون فراخوانی آن ممکن است چند بار برسد. دوم، جبران نباید به ترتیبِ رسیدن متکی باشد؛ اگر تصمیم گرفتید همه را برگردانید، ترتیب دقیق قدم‌ها خیلی وقت‌ها دیگر مهم نیست. سوم، جبران خودش می‌تواند شکست بخورد، پس هر جبران باید مالک و هشدار داشته باشد، وگرنه سیستمی می‌سازی که در آن پول کم شده و اتاق هم رزرو مانده. در سطح پیاده‌سازی، سه چیز را صریح نگه دار: شناسهٔ یکتا برای هر قدم تا تکرار قابل تشخیص باشد، شمارهٔ نسخه تا جبرانِ قدیمی روی وضعیت تازه اعمال نشود، و یک وضعیت پایانیِ صریح برای هر قدم تا بدانی کدام قدم جبران شده و کدام نه. بدون این سه، جبران به یک عملیات کور تبدیل می‌شود.When one operation spans several services without a distributed transaction, every step needs an inverse step that cancels its effect. The chain of those steps is the saga pattern. Three properties are required. The compensation must be idempotent, because the call may arrive more than once. It must not depend on arrival order; once you decide to undo everything, the exact order usually stops mattering. And the compensation can itself fail, so every compensation needs an owner and an alert, or you build a system where the money is gone and the room is still held. At the implementation level keep three things explicit: a unique id per step so retries are detectable, a version number so a stale compensation cannot land on fresh state, and an explicit terminal state per step so you know which steps were compensated.

1 : 1هر قدمِ تمام‌شده یک قدمِ جبرانی لازم داردevery completed step needs one inverse

چرا این کار شبیه rollback نیستWhy this is not a rollback

rollback یک عملِ موتور دیتابیس است: همهٔ تغییرها نادیده گرفته می‌شوند، انگار تراکنش هرگز شروع نشده. جبران یک عملِ برنامه است: اثرها باقی می‌مانند و با اثرهای متضاد متعادل می‌شوند. به همین دلیل جبران، جداسازی نمی‌دهد. در تمام مدتی که بین قدم اول و قدم جبرانی هستی، دیگران حالتِ میانی را می‌بینند: پول کم شده ولی سفارش ثبت نشده. طراحی درست، این حالت میانی را قابل تحمل و قابل تشخیص می‌کند، نه نامرئی.A rollback is an engine operation: all changes are discarded as if the transaction never began. A compensation is an application operation: the effects remain and are balanced by opposing effects. That is why it provides no isolation. For the whole interval between the first step and its compensation, others see the intermediate state: money taken, order not recorded. Good design makes that state tolerable and visible, not invisible.

جبرانی که خودش شکست می‌خوردWhen the compensation fails

این معمولاً فراموش می‌شود. اگر برگشتِ پول شکست بخورد، تو در بدترین وضعیت هستی: مشتری پول داده و خدمت نگرفته. برای همین هر جبران باید مثل هر عملِ بحرانی دیگر، بازتلاش با فاصلهٔ نمایی، صف نامه‌های مرده، و یک هشدار انسانی داشته باشد. بهترین نشانهٔ بلوغ یک تیم این است که بداند وقتی جبران شکست می‌خورد چه کسی بیدار می‌شود.This is the part people forget. If the refund fails, you are in the worst state: the customer paid and got nothing. Every compensation therefore needs what any critical operation needs: retries with backoff, a dead-letter path, and a human alert. The clearest sign of a mature team is that it knows who wakes up when a compensation fails.

تلهٔ رایجThe usual trap

طراحی جبران به‌عنوان «همان کاری که کردیم، برعکسش». جبرانِ یک رزرو، آزاد کردن است؛ جبرانِ یک پرداخت، برگشت پول است؛ ولی جبرانِ یک ایمیلِ ارسال‌شده وجود ندارد. قدم‌هایی که اثر بیرونیِ برگشت‌ناپذیر دارند باید آخرین قدم باشند، یا اصلاً به شکل قابل جبران طراحی شوند.Designing the compensation as “the same thing backwards”. The inverse of a reservation is a release, the inverse of a payment is a refund, but the inverse of a sent email does not exist. Steps with an irreversible external effect must be last, or designed so they can be reversed.

data integration

یکپارچه‌سازی داده فصل ۱۳Chapter 13 · دیدن در متنsee in context

یک داده، پنج نسخه، و پنج جواب مختلف.One fact, five copies, five different answers.

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

لیست خرید را روی کاغذ می‌نویسی، بعد همان را برای همسرت پیام می‌کنی و یک نسخه هم روی در یخچال می‌چسبانی. سه نسخه داری و هر سه به یک کار می‌آیند؛ ولی روزی که شیر را خط بزنی و فقط یکی را عوض کنی، سراغ یخچال می‌روی و فکر می‌کنی شیر لازم داری.You write a shopping list on paper, message the same list to your partner, and stick a copy on the fridge. Three copies, all useful, until the day you cross out milk on one of them and later read the fridge copy and buy milk you no longer needed.

تشبیه و تصویر ذهنیThe analogy

رستورانی را تصور کن که منویش سه جا زندگی می‌کند: تختهٔ بالای صندوق، اپلیکیشن سفارش آنلاین، و منوی کاغذی روی میزها. هر سه از یک آشپزخانه می‌آیند و هر سه برای یک هدف ساخته شده‌اند، ولی هیچ‌کدام مالکِ قیمت نیستند؛ آشپزخانه مالک است. وقتی قیمت تغییر می‌کند، باید هر سه را به‌روز کنی، و همیشه یکی جا می‌ماند. یکپارچه‌سازی داده همین کار است، با این تفاوت که به‌جای یک منو با ده‌ها سیستم طرفی: جست‌وجو، کش، انبار داده، مدل یادگیری، داشبورد مالی. همه داده را می‌خواهند، هیچ‌کدام نباید مالک باشند، و همه باید با هم بخوانند.Picture a restaurant whose menu lives in three places: the board above the till, the online ordering app, and the printed menu on the tables. All three come from one kitchen and all three were built for one purpose, but none of them owns the price; the kitchen does. When a price changes you have to update all three, and one always lags. Data integration is that job at the scale of a company: search, cache, warehouse, a model, a finance dashboard. They all want the data, none may own it, and all must agree.

منبع حقیقتSystem of recordایندکس جست‌وجوSearch indexکشCacheانبار دادهWarehouseمدل یادگیریModel featuresهمه مشتق‌اند؛ هیچ‌کدام نباید مالک داده شودAll derived; none of them may become the owner
یک منبع حقیقت، چند سیستم مشتق‌شده؛ کارِ سخت نگه‌داشتنِ این چند نسخه هم‌خوان است.One system of record, several derived systems; keeping them in agreement is the real job.

و بعدش، فنیAnd now, technically

در معماری داده، یکپارچه‌سازی یعنی رساندن تغییراتِ یک منبع حقیقت به انبارهایی که هر کدام برای یک نوع پرس‌وجو ساخته شده‌اند: ایندکس جست‌وجو، کش، انبار تحلیلی، جدول ویژگی برای مدل. این انبارها دادهٔ مشتق‌شده دارند و باید هر وقت لازم شد از منبع بازساختنی باشند. سه مسیر رایج وجود دارد. دسته‌ای دوره‌ای که ساده است ولی تأخیر دارد؛ ثبت تغییرات (CDC) که تغییرات را از لاگ تراکنشی می‌خواند و با تأخیر کم می‌رساند؛ و کارگزار رویداد که تغییرات را به‌صورت جریان پخش می‌کند و چند مصرف‌کننده مستقل روی آن می‌نشینند. هر سه یک چیز مشترک دارند: داده را دو بار می‌نویسند، و همان نوشتنِ دوم منبع همهٔ ناهم‌خوانی‌هاست.In a data architecture, integration means propagating changes from one system of record into the stores built for other questions: a search index, a cache, an analytical warehouse, a feature table for a model. Those stores hold derived data and must be rebuildable from the source on demand. Three paths are common: periodic batch, which is simple but lagging; change data capture, which reads the transactional log and delivers with low latency; and an event broker, which publishes changes as a stream several consumers follow independently. All three share one property: the data is written twice, and that second write is where every disagreement comes from.

2 writesهر داده دو بار نوشته می‌شود: منبع و مشتقevery fact is written twice: source and derivative
ms–minتأخیر معمول CDC در برابر ساعت‌ها در دسته‌ایtypical CDC lag, against hours for a nightly batch

چرا یکپارچه‌سازی هیچ‌وقت تمام نمی‌شودWhy integration is never finished

یکپارچه‌سازی یک مهاجرت نیست که یک بار انجامش بدهی؛ یک خط تولید دائمی است که باید مالک، هشدار و آزمون داشته باشد. هر سیستم جدیدی که اضافه می‌شود یک مصرف‌کنندهٔ تازه است و یک راه تازه برای واگرایی. به همین دلیل سیستم‌های بالغ برای هر مشتق، یک آزمونِ «هم‌خوانی» دارند که دوره‌ای اجرا می‌شود و اختلاف را گزارش می‌دهد؛ بدون آن، اولین باری که می‌فهمی ایندکس جست‌وجو با دیتابیس اختلاف دارد، روزی است که مشتری می‌گوید محصولی را پیدا نمی‌کند که موجود است.Integration is not a migration you finish; it is a permanent pipeline that needs an owner, alerts and tests. Every new system is a new consumer and a new way to diverge. Mature shops therefore run a periodic agreement test per derived store and report any difference; without it, the first time you learn the search index disagrees with the database is the day a customer says they cannot find a product you have in stock.

کدام مسیر را انتخاب کنمWhich path to pick

اگر مصرف‌کننده تحمل ساعت‌ها تأخیر را دارد و منطق پیچیده دارد، دسته‌ای ساده‌ترین و قابل‌اعتمادترین انتخاب است. اگر تأخیر ثانیه‌ای مهم است و منبع یک دیتابیس تراکنشی است، CDC کم‌هزینه‌ترین راه است چون لاگ از قبل نوشته می‌شود. اگر چند مصرف‌کنندهٔ مستقل با سرعت‌های متفاوت داری، کارگزار رویداد انعطاف بیشتری می‌دهد ولی ترتیب و تکرارِ تحویل را باید خودت مدیریت کنی. در هر سه حالت، مصرف‌کننده باید تکرارپذیر باشد؛ چون تحویلِ دقیقاً یک‌بار در عمل وجود ندارد.If the consumer tolerates hours of lag and carries complex logic, the nightly batch is the simplest reliable choice. If seconds matter and the source is a transactional database, CDC is the cheapest route because the log is already being written. If several independent consumers move at different speeds, an event broker is more flexible, at the price of managing ordering and redelivery yourself. In all three cases the consumer must be idempotent, because exactly-once delivery does not exist in practice.

تلهٔ رایجThe usual trap

فکر کردن این‌که یکپارچه‌سازی یعنی یک اسکریپت مهاجرت که یک بار اجرا می‌شود. اسکریپت تمام می‌شود، ولی داده تمام نمی‌شود؛ هر تغییری از آن به بعد باید مسیرش را پیدا کند، وگرنه سیستم مشتق آرام‌آرام کهنه می‌شود و کسی متوجه نمی‌شود.Treating integration as a one-off migration script. The script ends; the data does not. Every change after that needs a path, or the derived system quietly rots and nobody notices.

هیچ خطایی ندیدی. پس چرا عدد غلط است؟No error was reported. So why is the number wrong?

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

بشقاب‌ها را به آشپزخانه برمی‌گردانی و می‌شماری: شش بشقاب. هیچ‌کس چیزی نینداخته و هیچ صدایی نیامد، ولی یک بشقاب زیر میز مانده. شمارشِ آخر کار، تنها چیزی است که واقعیت را می‌گوید، نه سکوتِ اتاق.You carry the plates back and count six. Nothing dropped, nothing made a sound, yet one plate is still under the table. The count at the end is the only thing that tells the truth, not the silence of the room.

تشبیه و تصویر ذهنیThe analogy

انبارداری را تصور کن که هر کارتن را با برچسب و شماره ثبت می‌کند. فرض کن قفسه سالم است، جرثقیل سالم است، و اپراتور هم درست کار می‌کند؛ باز هم هر از چند گاه یک اختلاف پیدا می‌شود: کارتنی که در سیستم هست و روی قفسه نیست. اینجا هیچ اجزایی خراب نشده، بلکه زنجیرهٔ کار یک جا ناهماهنگ بوده: یک اسکن گم شده، یک انتقال دو بار ثبت شده، یا یک نسخهٔ قدیمی روی جدید نوشته شده. یکپارچگی، یعنی طراحی‌ای که این ناهماهنگی‌ها را پیدا و جبران کند؛ نه فقط امید به اینکه هیچ‌کدام رخ نمی‌دهد.Picture a warehouse that logs every carton with a label and a number. Suppose the shelf is fine, the crane is fine and the operator is careful; differences still appear — a carton the system has and the shelf does not. No component failed. The chain of steps was inconsistent: a scan missed, a transfer logged twice, an older version overwrote a newer one. Integrity means designing for detecting and correcting those, rather than hoping they do not happen.

نوشتنWriteبا شناسهٔ یکتاwith a unique idذخیرهStoreبا چک‌سامwith a checksumانتقالTransportقابل بازپخشreplayableسنجشVerifyمقایسه با منبعcompare to source
یکپارچگی سرتاسری: هر مرحله امضا می‌گذارد و مرحلهٔ بعد آن را می‌سنجد.End-to-end integrity: every stage signs, the next stage verifies.

و بعدش، فنیAnd now, technically

یکپارچگی با تحمل خرابیِ معمول یکی نیست. چک‌سام دیسک بیت‌روت را می‌گیرد؛ TCP بایت‌های گم‌شده را جبران می‌کند؛ ولی هیچ‌کدام باگِ برنامه‌ای را نمی‌گیرد که یک فیلد را هنگام نوشتن حذف می‌کند، یا یک پراکسی که فیلد اضافه را دور می‌ریزد، یا نوشتنی که دو بار اعمال شده. برای همین، تضمین باید سرتاسری باشد: هر رکورد شناسهٔ یکتا داشته باشد تا تکرار قابل تشخیص باشد؛ محتوا هش داشته باشد تا تغییر قابل تشخیص باشد؛ و مصرف‌کننده بعد از پردازش، نتیجه را با منبع مقایسه کند. یکپارچگی، خصلتِ یک جزء نیست؛ خصلتِ کلِ مسیر است. در عمل، همین سه گانه (شناسه، هش، مقایسه) تفاوت میان سیستمی است که «معمولاً درست است» و سیستمی که می‌توانی درباره‌اش حرف بزنی. بدون شناسه، تکرار یک احتمال است؛ بدون هش، تغییر یک حدس است؛ و بدون مقایسهٔ دوره‌ای، هر دو فقط امیدند.Integrity is not the same as ordinary fault tolerance. A disk checksum catches bit rot; TCP repairs lost bytes; neither catches an application bug that drops a field on write, a proxy that discards unknown fields, or a write applied twice. The guarantee therefore has to be end to end: every record carries a unique id so duplicates are detectable, the content carries a hash so alteration is detectable, and the consumer compares its output against the source after processing. Integrity is not a property of a component; it is a property of the whole path. In practice those three (an id, a hash, a comparison) are what separates a system that is usually right from one you can make claims about.

1 idشناسهٔ یکتا، تنها راه تشخیص تکرارa unique id is the only way to detect a duplicate
2× checkهم منبع، هم مشتق، باید سنجیده شوندboth the source and the derivative have to be checked

چرا TCP و چک‌سام کافی نیستندWhy TCP and checksums are not enough

TCP تضمین می‌کند بایت‌ها درست برسند، نه اینکه برنامه درست خوانده باشد. چک‌سام دیسک تضمین می‌کند بلوک همان است که نوشته شد، نه اینکه نوشته درست بود. یک باگ در کد سریال‌سازی، یک فیلد را حذف می‌کند و از تمام این لایه‌ها سالم عبور می‌کند، چون هیچ‌کدام نمی‌دانند فیلد باید وجود داشته باشد. سنجشِ سرتاسری دقیقاً همین را می‌گیرد: مقایسهٔ محتوای منطقی با منبع، نه بایت‌های مسیر.TCP guarantees the bytes arrived intact, not that the application read them correctly. A disk checksum guarantees the block is what was written, not that what was written was right. A bug in the serialization code can drop a field and pass every one of those layers unharmed, because none of them knows the field was supposed to exist. An end-to-end check catches exactly this: comparing logical content with the source, not bytes along the wire.

یکپارچگی را چطور اندازه بگیریHow to measure integrity

دو عدد لازم داری: نرخِ اختلافِ کشف‌شده و زمانِ کشف. اولی می‌گوید چند رکورد با منبع نمی‌خواند؛ دومی می‌گوید چقدر طول می‌کشد تا بفهمی. یک سیستم با نرخ اختلاف بسیار کم ولی زمان کشف یک ماه، عملاً بی‌سنجش است، چون تا وقتی بفهمی، دادهٔ غلط به تصمیم‌ها و گزارش‌ها رسیده. آزمونِ دوره‌ایِ هم‌خوانی، دقیقاً برای کوتاه کردن همین زمان است.You need two numbers: the rate of detected disagreement and the time to detect it. The first says how many records disagree with the source; the second says how long until you know. A system with a very low rate but a one-month detection time is effectively unmeasured, because by the time you learn, wrong data has already fed decisions and reports. A periodic agreement test exists to shorten that detection time.

تلهٔ رایجThe usual trap

تکیه بر این‌که «اگر خطایی بود، لاگ نشان می‌داد». بیشترین خرابی‌های داده‌ای که دیده‌ام هیچ استثنایی پرتاب نکردند؛ یک نوشتنِ نیمه‌کاره، یک فیلدِ حذف‌شده، یک ترتیبِ عوض‌شده. سکوتِ لاگ یعنی هیچ‌کس چیز غیرمنتظره ندیده، نه اینکه داده درست است.Trusting that “if anything were wrong, the log would show it”. Most data faults I have seen raised no exception at all: a half-applied write, a dropped field, a reordered stream. Silence in the log means nobody saw something unexpected, not that the data is right.

lambda and kappa architecture

معماری لامبدا و کاپا فصل ۱۳Chapter 13 · دیدن در متنsee in context

دو بار حساب کن، یا یک بار؟Compute it twice, or once?

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

فروشگاه دو راه دارد که بداند امروز چقدر فروخته: هر شب دفترِ کل را از اول جمع بزند، یا در تمام روز یک عدد روی تختهٔ کنار صندوق بالا ببرد. راه اول دقیق است ولی تا شب صبر می‌خواهد؛ راه دوم همان لحظه جواب می‌دهد ولی یک اشتباهِ کوچک تا آخر روز جمع می‌شود.A shop can know today's takings two ways: add the whole ledger up again each night, or keep a running tally on a board by the till. The first is exact but waits until closing; the second answers instantly but a small mistake accumulates all day.

تشبیه و تصویر ذهنیThe analogy

معماری لامبدا می‌گوید هر دو را داشته باش: یک لایهٔ دسته‌ای که شبانه همه چیز را از اول و دقیق حساب می‌کند، یک لایهٔ سریع که همان لحظه عدد تقریبی می‌دهد، و یک لایهٔ نمایش که جواب دقیق را روی تقریبی می‌نشاند. زیبایی‌اش این است که همیشه یک جواب درست داری؛ عیبش این است که دو برنامه‌نویس، دو منطق، و دو جای اشتباه داری. کاپا می‌گوید اصلاً لایهٔ دسته‌ای لازم نیست: یک موتور جریانی که همیشه روی لاگِ رویدادها می‌نشیند، و وقتی عدد اشتباه شد، لاگ را از اول بازپخش می‌کنی. یک مسیر، یک منطق، به قیمت اینکه بازپخش تاریخچه ممکن است ساعت‌ها طول بکشد.Lambda says have both: a batch layer that recomputes everything exactly overnight, a speed layer that answers immediately with an approximation, and a serving layer that overlays the exact result on the approximate one. The beauty is that a correct answer always exists; the cost is two implementations, two sets of bugs. Kappa says the batch layer is unnecessary: one stream engine always reading the event log, and when a number looks wrong you replay the log from the start. One path, one implementation, at the price of a replay that may take hours.

لامبدا · دو مسیرLambda · two pathsلایهٔ دسته‌ای: دقیقbatch layer: exactلایهٔ سریع: تقریبیspeed layer: approximateدو منطق، دو جای خطاtwo logics, two bug sitesکاپا · یک مسیرKappa · one pathیک موتور جریانیone stream engineبازپخش برای تصحیحreplay to correctیک منطق، بازپخش گرانone logic, costly replay
لامبدا دو مسیر و یک نمایش؛ کاپا یک مسیر و بازپخشِ تاریخچه.Lambda runs two paths and merges them; kappa runs one and replays history.

و بعدش، فنیAnd now, technically

در لامبدا سه لایه داری. لایهٔ دسته‌ای، دادهٔ کامل را می‌خواند و نتیجهٔ دقیق را می‌سازد؛ لایهٔ سریع، فقط رویدادهای تازه را با همان منطق به‌صورت تقریبی پردازش می‌کند تا تأخیر کم شود؛ لایهٔ نمایش، نتایج لایهٔ دسته‌ای را با خروجی تازهٔ لایهٔ سریع ترکیب می‌کند. کاپا همان کار را با یک موتور جریانی انجام می‌دهد که لاگ را از یک آفست مشخص می‌خواند؛ برای تصحیح یک نتیجه، همان برنامه را از آفست قدیمی‌تر دوباره اجرا می‌کنی و خروجی را جایگزین می‌کنی. شرط موفقیت کاپا این است که جریان، تاریخچهٔ کافی را نگه دارد و پردازش، قطعی و تکرارپذیر باشد؛ بدون این دو، بازپخش همان نتیجهٔ قبلی را نمی‌دهد و تصحیح بی‌فایده است.Lambda has three layers. The batch layer reads the complete data and produces an exact result; the speed layer processes only recent events with the same logic, approximately, to cut latency; the serving layer merges the exact result with the fresh output. Kappa does the same with one stream engine reading the log from a chosen offset; to correct a result you rerun the same job from an older offset and replace the output. Kappa works only if the stream retains enough history and the processing is deterministic and repeatable; without those two, a replay does not reproduce the previous result and the correction is worthless.

2 codebasesهزینهٔ اصلی لامبدا: دو پیاده‌سازی و دو مجموعه باگlambda's main cost: two implementations, two bug sets
1 logکاپا همه چیز را از یک لاگ بازپخش‌پذیر می‌سازدkappa rebuilds everything from one replayable log

چرا لامبدا از مد افتادWhy lambda fell out of fashion

مشکل لامبدا این نبود که غلط بود؛ این بود که دو پیاده‌سازی از یک منطق داشت، و آن دو پیاده‌سازی به‌ندرت هم‌رفتار می‌ماندند. یک باگ در لایهٔ دسته‌ای و نه در لایهٔ سریع، جواب را بین دو بازه ناسازگار می‌کند، و پیدا کردنش از پیدا کردن یک باگ معمولی سخت‌تر است چون هر دو مسیر «درست» به نظر می‌رسند. کاپا با یک مسیر این کلاس از باگ را حذف می‌کند، ولی هزینهٔ بازپخش و نیاز به نگهداشتِ طولانی‌ترِ لاگ را اضافه می‌کند.Lambda's problem was not that it was wrong; it was that it had two implementations of one logic, and those two rarely stayed identical. A bug in the batch layer but not the speed layer makes answers disagree across a boundary, and finding it is harder than an ordinary bug because both paths look correct. Kappa removes that class of bug by having one path, and adds replay cost plus the need to retain the log longer.

کدام را انتخاب کنمWhich one to choose

امروز پاسخ عملی این است: اول ببین اصلاً به هر دو لایه نیاز داری یا نه. بسیاری از تیم‌ها لایهٔ دسته‌ای را نگه می‌دارند نه برای دقت، بلکه برای آزمون: هر شب نتیجهٔ دسته‌ای را با نتیجهٔ جریانی مقایسه می‌کنند و اختلاف را هشدار می‌دهند. این همان لامبداست، با یک تفاوت: لایهٔ دسته‌ای دیگر جواب نمی‌دهد، فقط قاضی است. اگر تیم کوچکی، یک موتور جریانی با بازپخشِ آزمون‌شده انتخاب کن و لاگ را به‌قدر کافی نگه دار.The practical answer today starts with a question: do you need both layers at all? Many teams keep a batch layer not for accuracy but as a referee: every night the batch result is compared with the stream result and a difference raises an alarm. That is lambda with one change — the batch layer no longer serves answers, it only judges. If you are a small team, pick one stream engine with a tested replay path and retain enough log.

تلهٔ رایجThe usual trap

انتخاب کاپا بدون اینکه بازپخش را آزموده باشی. اگر پردازش قطعی نباشد، یا لاگ به‌قدر کافی نمانده باشد، وقتی عدد اشتباه شد هیچ راهی برای برگشت نداری و مجبور می‌شوی همان لامبدایی را بسازی که از آن فرار می‌کردی.Choosing kappa without testing the replay. If processing is not deterministic, or the log has already been trimmed, you have no way back when a number is wrong, and you end up rebuilding the lambda you were avoiding.

دو نسخه اختلاف دارند. کدام را درست کنی؟Two copies disagree. Which one do you fix?

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

دو صندوق‌دار یک مغازه، هر کدام دفتر خودش را دارد. آخر روز دو دفتر را کنار هم می‌گذارند و ردیف‌به‌ردیف مقایسه می‌کنند. اختلاف که پیدا شد، تصمیم می‌گیرند کدام درست است و همان را در دفتر دیگر می‌نویسند.Two cashiers in one shop each keep their own ledger. At closing they put the books side by side and compare line by line. When a difference shows up, they decide which line is right and write it into the other book.

تشبیه و تصویر ذهنیThe analogy

این کار سه بخش دارد و هر سه لازم است. اول باید بفهمی اختلاف هست، و برای این کار نمی‌شود هر شب همهٔ دفترها را خط‌به‌خط خواند؛ باید چیزی مثل جمع کل یا شمارهٔ آخرین ردیف را مقایسه کنی تا فقط جای اختلاف را پیدا کنی. دوم باید تصمیم بگیری کدام نسخه درست است، و این تصمیم همیشه آسان نیست؛ گاهی هیچ‌کدام درست نیست و باید از رویدادها از نو ساخت. سوم باید ترمیم را طوری انجام بدهی که اگر نصفه کاره ماند، تکرارش بی‌خطر باشد. ترمیمی که خودش داده را خراب کند، از اختلاف اولیه بدتر است.The job has three parts and all three are needed. First you must learn that a difference exists, and you cannot reread every ledger line by line each night; you compare something cheap like a total or the last entry number to narrow down where to look. Second you must decide which copy is right, which is not always easy; sometimes neither is, and the truth has to be rebuilt from the events. Third the repair itself must be safe to repeat, because it will be interrupted. A repair that corrupts data is worse than the divergence it was fixing.

کشفDetectهش یا شمارهhash or offsetتصمیمDecideکدام درست استwhich is rightاعمالApplyتکرارپذیرidempotentاثباتProveآزمون دوبارهre-run the check
ترمیم یک خط تولید است: کشف، تصمیم، اعمال، و اثبات.Repair is a pipeline: detect, decide, apply, prove.

و بعدش، فنیAnd now, technically

ترمیم معمولاً دو شکل دارد. ترمیمِ در مسیرِ خواندن، که وقتی یک درخواست چند نسخه را می‌خواند و اختلاف می‌بیند، نسخهٔ تازه‌تر را برمی‌گرداند و نسخهٔ کهنه را همان‌جا اصلاح می‌کند. ترمیمِ پس‌زمینه، که مستقل از درخواست‌ها اجرا می‌شود و با مقایسهٔ درخت‌های مرکل یا شماره‌های ترتیب، بخش‌های واگرا را پیدا می‌کند. هر دو باید تکرارپذیر باشند و باید بتوانند متوقف و از سر گرفته شوند. ترمیم پس‌زمینه باید نرخ‌محدود باشد، چون ترافیک ترمیم با ترافیک سرویس رقابت می‌کند و می‌تواند همان چیزی را کند کند که می‌خواهد نجاتش بدهد. یک نکتهٔ عملی دیگر: ترمیم را همیشه از روی منبع یا از روی نسخهٔ دارای شمارهٔ نسخه انجام بده، نه از روی «اکثریت آرا». اکثریت در برابر یک باگِ سیستماتیک که هر سه نسخه را یکسان خراب کرده، هیچ محافظی نیست و فقط اطمینانِ دروغین می‌دهد.Repair takes two shapes. Read-path repair: when a request reads several replicas and sees a disagreement, it returns the newer value and fixes the stale one on the spot. Background repair: it runs independently of requests and, by comparing Merkle trees or sequence numbers, locates the divergent ranges. Both must be idempotent and resumable. Background repair must also be rate-limited, because repair traffic competes with serving traffic and can slow down the very system it is trying to rescue. Repair from the source, or from the copy that carries a version number, never from a majority vote. A majority offers no protection against a systematic bug that corrupted all copies the same way; it only offers false confidence.

idempotentترمیم باید بی‌خطر تکرار شود؛ همیشه نصفه می‌ماندrepair must be safe to repeat; it always gets interrupted
1 ownerبرای هر داده فقط یک قاعدهٔ برد لازم استeach fact needs exactly one winning rule

تصمیم سخت‌تر از کشف استDeciding is harder than detecting

پیدا کردن اختلاف یک مسئلهٔ مهندسی است: هش بساز، مقایسه کن، بازه را کوچک کن. تصمیم گرفتن یک مسئلهٔ معنایی است: کدام نسخه واقعیت است؟ اگر دو نوشتن هم‌زمان بوده‌اند و هیچ ترتیبی بینشان نیست، هیچ نسخه‌ای به‌تنهایی درست نیست؛ باید هر دو را نگه داری یا یک قاعدهٔ صریح برای برداشتن داشته باشی. بیشتر خرابی‌های ترمیم از همین‌جا می‌آید: یک قاعدهٔ «آخرین نوشتن برنده» که بی‌سروصدا داده را حذف می‌کند.Detecting is an engineering problem: build a hash, compare, narrow the range. Deciding is a semantic problem: which copy is the fact? If two writes were concurrent and no order exists between them, neither copy alone is right; you must keep both or have an explicit rule for choosing. Most repair disasters start here: a last-write-wins rule that quietly deletes data.

ترمیم را چطور اجرا کنی که خودش خراب نکندRunning repair without breaking things

سه قاعدهٔ عملی. اول، همیشه از منبع حقیقت ترمیم کن، نه از یک نسخهٔ تصادفی. دوم، ترمیم را با شناسهٔ یکتا و شمارهٔ نسخه بنویس تا اگر دو بار اجرا شد، دو بار اعمال نشود. سوم، پیش از اعمال، حجم و نرخ را بسنج؛ یک ترمیم بزرگ می‌تواند کش را از کار بیندازد یا فضای دیسک را پر کند. اگر ترمیم در همان روز اول درست طراحی نشود، بعداً که داده زیاد شد دیگر نمی‌توانی اجرایش کنی.Three practical rules. Repair from the system of record, never from an arbitrary copy. Write the repair with a unique id and a version so a second run does not apply twice. Measure volume and rate before applying, because a large repair can evict the cache or fill the disk. If repair is not designed well on day one, you will not be able to run it once the data has grown.

تلهٔ رایجThe usual trap

ترمیمی که نسخهٔ تازه‌تر را با نسخهٔ کهنه عوض می‌کند، چون کدِ مقایسه فقط می‌داند اختلاف هست و نمی‌داند کدام جلوتر است. این اتفاق در سیستم‌هایی می‌افتد که شمارهٔ نسخه را از دست داده‌اند و فقط محتوا را مقایسه می‌کنند.A repair that overwrites the newer version with the older one, because the comparison code knows only that they differ, not which is ahead. This happens in systems that lost their version numbers and compare content alone.

سیستم جدید را امتحان کن، بی‌آنکه کسی متوجه شود.Try the new system without anyone noticing.

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

می‌خواهی مسیر تازه‌ای به محل کار بروی ولی نمی‌خواهی روز جلسهٔ مهم امتحانش کنی. پس یک روز که عجله نداری، مسیر جدید را می‌روی و زمانش را با مسیر همیشگی مقایسه می‌کنی. جوابی که به کسی می‌دهی هنوز از مسیر قدیمی است.You want to try a new route to work but not on the morning of an important meeting. So on a day without a deadline you take the new route and compare its time with the usual one. The answer you actually rely on is still the old route.

تشبیه و تصویر ذهنیThe analogy

این کار یک تفاوت مهم با «تست در محیط آزمایشی» دارد: ترافیک واقعی است. همان درخواستی که به سیستم قدیم می‌رود، یک نسخه هم به سیستم جدید می‌رود، و کد مقایسه می‌کند که جواب‌ها یکی هستند یا نه. مزیتش این است که ایرادهایی را می‌بینی که با دادهٔ ساختگی هرگز پیدا نمی‌شدند: یک فیلد که در مایگریشن گم شده، یک ردیف با کاراکتر عجیب، یک اختلاف در منطقهٔ زمانی. عیبش این است که سیستم جدید باید بدون آنکه جوابش را سرو کنی، هزینهٔ کاملِ یک درخواست را بپردازی.This differs from testing in staging in one crucial way: the traffic is real. The same request that goes to the old system also goes to the new one, and a comparison layer checks whether the answers agree. The advantage is that it finds the faults synthetic data never would: a field dropped in the migration, a row with an odd character, a timezone difference. The cost is that the new system pays the full price of a request while none of its answers are served.

درخواستrequestبه هر دوto bothجواب قدیمold answerسرو می‌شودservedجواب جدیدnew answerفقط مقایسهcompared onlyنرخ اختلافmismatch rateدروازهٔ برشcutover gate
سایه می‌خواند، مقایسه می‌کند، و تصمیمِ برش را با عدد می‌سازد.The shadow reads, compares, and turns the cutover decision into a number.

و بعدش، فنیAnd now, technically

خواندن سایه سه جزء دارد: یک مسیر موازی که همان درخواست را به سیستم جدید می‌فرستد، یک لایهٔ مقایسه که جواب‌ها را نرمال و مقایسه می‌کند، و یک معیار پذیرش که می‌گوید نرخ اختلاف باید به چه عددی برسد تا برش مجاز باشد. مقایسه سخت‌تر از آن است که به نظر می‌رسد: ترتیب ردیف‌ها، فیلدهای اضافه، و مقادیر شناور همه باید نرمال شوند، وگرنه هر اختلافِ بی‌اهمیت یک هشدار می‌شود و تیم به آن بی‌اعتنا می‌شود. خواندن سایه باید فقط‌خواندنی باشد؛ اگر درخواست سایه‌ای اثر جانبی داشته باشد، دو بار می‌نویسی و همان مشکلی را می‌سازی که می‌خواستی از آن فرار کنی. یک نکتهٔ دیگر: مقایسه باید منطقی باشد نه بایتی. دو سیستم می‌توانند همان داده را با ترتیب فیلد متفاوت، با یک فیلد اضافهٔ بی‌اثر، یا با دقتِ عددی متفاوت برگردانند و هر سه سالم باشند. اگر نرمال‌سازی را جدی نگیری، نرخ اختلاف همیشه بالا می‌ماند و دروازهٔ برش هیچ‌وقت باز نمی‌شود.A shadow read has three parts: a parallel path that sends the same request to the new system, a comparison layer that normalizes and diffs the answers, and an acceptance criterion that says what mismatch rate permits the cutover. Comparison is harder than it looks: row order, extra fields and floating-point values all need normalizing, or every harmless difference raises an alert and the team learns to ignore alerts. The shadow path must be read-only; if a shadowed request has a side effect, you write twice and recreate the very problem you were avoiding. The comparison must be logical, not bytewise. Two systems can return the same data with a different field order, an extra harmless field, or a different numeric precision, and all three be healthy.

0 writesدرخواست سایه نباید هیچ نوشتنی داشته باشدthe shadowed request must write nothing

چرا سایه از آزمون در محیط آزمایشی بهتر استWhy a shadow beats a staging test

محیط آزمایشی با دادهٔ ساختگی ساخته می‌شود، و دادهٔ ساختگی همیشه تمیزتر از دادهٔ واقعی است: کدگذاری‌های عجیب، نام‌های با فاصله، تاریخ‌های نامعتبر، ردیف‌هایی که هیچ‌وقت نباید وجود می‌داشتند. خواندن سایه همین‌ها را می‌بیند، و چون ترافیک واقعی است، توزیع واقعی بار را هم می‌بیند. به همین دلیل بیشتر برش‌های موفقی که دیده‌ام، عددشان از سایه آمده بود، نه از محیط آزمایشی.Staging is built with synthetic data, and synthetic data is always cleaner than the real thing: odd encodings, names with spaces, invalid dates, rows that should never have existed. A shadow sees exactly those, and because the traffic is real it also sees the real load distribution. That is why most successful cutovers I have seen got their number from a shadow, not from staging.

دروازهٔ برش را عدد کنMake the cutover gate a number

عبارت «وقتی مطمئن شدیم برش می‌زنیم» یک جملهٔ مدیریتی است، نه یک معیار. دروازهٔ برش باید یک عددِ مکتوب باشد: مثلاً نرخ اختلاف زیر یک در هزار برای سه روز پیوسته، بدون هیچ اختلافی در فیلدهای مالی. این کار دو فایده دارد: تصمیم از فشارِ جلسه جدا می‌شود، و تیم می‌تواند دقیقاً بداند چه چیزی مانع برش است. بهترین حالت این است که همان اسکریپت سایه، خودش این عدد را هر روز بسازد.The phrase “we cut over when we feel confident” is a management sentence, not a criterion. The gate should be a written number: a mismatch rate below one in a thousand for three consecutive days, with zero differences in financial fields. That buys two things: the decision leaves the pressure of the meeting room, and the team knows exactly what is blocking. The best version has the shadow script producing that number itself, daily.

تلهٔ رایجThe usual trap

فراموش کردن اینکه خواندن سایه ظرفیت مصرف می‌کند. سیستم قدیم و جدید هر دو باید بار کامل را تحمل کنند، و اگر سیستم جدید هنوز بهینه نشده، سایه می‌تواند همان لحظه‌ای که به بیشترین ظرفیت نیاز داری، آن را بخورد. سایه را روی درصدی از ترافیک اجرا کن، نه روی همهٔ آن، مگر اینکه واقعاً ظرفیتش را داری.Forgetting that a shadow consumes capacity. Both systems must carry the full load, and if the new one is not tuned yet, the shadow can eat the capacity exactly when you need it most. Shadow a percentage of traffic rather than all of it, unless you genuinely have the headroom.

timeliness

به‌هنگام‌بودن فصل ۱۳Chapter 13 · دیدن در متنsee in context

دیر رسیدن با غلط بودن یکی نیست.Late is not the same as wrong.

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

صورت‌حساب بانکی دیروز را می‌بینی. یک روز عقب است، ولی هر ردیفش درست است. حالا صورت‌حسابی را تصور کن که به‌روز است ولی یک تراکنش را جا انداخته؛ آن یکی دیر نیست، غلط است، و خطرش بیشتر است.You read yesterday's bank statement. It is a day old, but every line is right. Now imagine a statement that is up to the minute but missing a transaction. That one is not late; it is wrong, and far more dangerous.

تشبیه و تصویر ذهنیThe analogy

در یک مغازه، دو چیز را می‌شود به تعویق انداخت: خبرِ رسیدنِ جنس تازه و شمارشِ صندوق. خبر ممکن است یک ساعت دیر برسد و این فقط کمی آزاردهنده است؛ ولی اگر شمارش یک اسکناس را جا بیندازد، هیچ تأخیری در کار نبوده، فقط حساب غلط است. هر سیستم داده‌ای این دو را قاطی می‌کند: تأخیر را می‌بیند و آن را با اشتباه یکی می‌گیرد، در حالی که درمان این دو کاملاً متفاوت است.In a shop you can postpone two different things: news that a delivery arrived, and counting the till. The news may arrive an hour late and that is merely annoying; if the count misses a banknote, no lateness was involved, the total is simply wrong. Data systems conflate these two constantly: they see lag and treat it as error, when the cure for each is entirely different.

رویدادeventساعت ۱۰10:00تأخیرlagچند ثانیهsecondsرسیدنarrivalساعت ۱۰:۰۲10:02هر دو درستboth correctداده گم نشدnothing lost
تأخیر یک بازهٔ زمانی است؛ از دست رفتن داده یک شکاف است.Lag is a stretch of time; missing data is a hole.

و بعدش، فنیAnd now, technically

به‌هنگام‌بودن با lag اندازه‌گیری می‌شود: فاصلهٔ زمانی میان وقتی که یک رویداد در منبع رخ داد و وقتی که در سیستم مشتق قابل خواندن شد. یکپارچگی با چیزی متفاوت شکسته می‌شود: رکوردی که هرگز نرسید، دو بار اعمال شد، یا محتوایش عوض شد. این تفکیک در عمل حیاتی است چون هشدارها و درمان‌ها فرق دارند. lag بالا با ظرفیت، بچ‌بندی و فشار برگشتی درمان می‌شود؛ از دست رفتن داده با شناسه، بازپخش و آزمون هم‌خوانی. یک سیستم می‌تواند lag صفر داشته باشد و کاملاً غلط باشد، و می‌تواند ساعت‌ها عقب باشد و کاملاً درست. در داشبوردها، این دو را با دو عدد جدا نشان بده: سنِ داده و نرخ اختلاف. اگر تنها یک عدد نشان بدهی، مخاطب همیشه آن را «درستی» می‌خواند و بعد از یک تأخیر بی‌خطر، به کل داشبورد بی‌اعتماد می‌شود.Timeliness is measured as lag: the time between an event happening at the source and becoming readable in the derived system. Integrity breaks in a different way: a record that never arrived, was applied twice, or changed content. The distinction matters operationally because alerts and fixes differ. High lag is fixed with capacity, batching and backpressure; lost data is fixed with identifiers, replay and agreement tests. A system can have zero lag and be completely wrong, or be hours behind and completely correct. Show the two numbers separately on the dashboard: data age and mismatch rate. Show only one and the reader will always read it as correctness.

secondslag سالم در یک خط CDC معمولیhealthy lag on a typical CDC pipeline
0 recordsهدفِ یکپارچگی: هیچ رکوردی گم یا تکراری نشودthe integrity target: no record lost or duplicated

چرا این تفکیک در جلسه‌ها گم می‌شودWhy the distinction gets lost in meetings

وقتی داشبورد عقب است، اولین جمله معمولاً این است که «داده اشتباه است». اما اگر همان داشبورد را یک ساعت بعد نگاه کنی و عدد درست باشد، داده هیچ‌وقت اشتباه نبود؛ فقط دیر رسیده بود. هزینهٔ این قاطی‌شدن این است که تیم به‌جای اضافه کردن ظرفیت یا کوتاه کردن مسیر، شروع می‌کند به ساختن آزمون‌های صحت که هیچ‌وقت چیزی پیدا نمی‌کنند، و مشکل واقعی — یعنی lag — سر جای خودش می‌ماند.When a dashboard is behind, the first sentence is usually “the data is wrong”. But if you look again an hour later and the number is right, the data was never wrong; it was late. The cost of conflating them is that the team, instead of adding capacity or shortening the path, starts building correctness tests that never find anything, while the actual problem — lag — stays exactly where it was.

دو هشدار، دو مالکTwo alerts, two owners

بهترین تمرین این است که دو سیگنال جدا داشته باشی. یکی سنِ داده (age) که می‌گوید آخرین رکورد چه وقت رسیده، و اگر از حد گذشت هشدار بدهد. دیگری آزمونِ هم‌خوانی که دوره‌ای چند نمونه را با منبع مقایسه کند و اختلاف را گزارش دهد. اولی مالکش تیم پلتفرم است و درمانش ظرفیت است؛ دومی مالکش تیم داده است و درمانش بازپخش و رفع باگ. وقتی این دو را در یک هشدار جمع می‌کنی، هیچ‌کس نمی‌داند چه کاری باید بکند.The best practice is two separate signals. One is data age — when the last record arrived — which alerts when it passes a threshold. The other is an agreement test that compares a sample against the source and reports differences. The first belongs to the platform team and its cure is capacity; the second belongs to the data team and its cure is replay and a bug fix. Merge them into one alert and nobody knows which action to take.

تلهٔ رایجThe usual trap

گرفتنِ lag به‌عنوان شاخصِ درستی. تیمی که می‌گوید «lag صفر است، پس داده درست است» دقیقاً همان تیمی است که یک روز می‌فهمد نیمی از رویدادها هرگز به انبار داده نرسیده‌اند؛ مصرف‌کننده به آخرین آفست رسیده بود، ولی از روی شکاف‌ها پریده بود.Using lag as a correctness metric. The team that says “lag is zero, so the data is right” is exactly the team that one day discovers half the events never reached the warehouse; the consumer had reached the latest offset, having jumped over the gaps.

دیتابیس را از هم باز کن؛ کدام تیکه را برمی‌داری؟Take the database apart. Which piece do you keep?

مثال روزمره، بدون اصطلاحThe everyday one, no jargon

چاقوی چندکارهٔ جیبی داری که همه چیز را «کمی» انجام می‌دهد. روزی که آشپزی جدی شروع می‌کنی، می‌روی یک چاقوی سرآشپز، یک پوست‌کن و یک تخته می‌خری. حالا هر کار را بهتر انجام می‌دهی، ولی سه چیز اضافه داری که باید بشویی و جایش بدهی.You own a pocket multi-tool that does everything a little. The day you start cooking seriously you buy a chef's knife, a peeler and a board. Every task gets better, and you now own three extra things to wash and store.

تشبیه و تصویر ذهنیThe analogy

پایگاه دادهٔ سنتی هم مثل همان چاقوی چندکاره است: ذخیره‌سازی، اجرای پرس‌وجو، فهرست، تراکنش، و هماهنگی همه زیر یک سقف، با یک تیم و یک رفتار. برای بیشتر کارها این خوب است؛ یک چیز را داری، یک چیز را یاد می‌گیری، یک چیز را پشتیبان می‌گیری. ولی وقتی بار تحلیلی سنگین می‌شود، یا وقتی الگوی دسترسی یک جدول با بقیه فرق می‌کند، همان یکپارچگی به سقف تبدیل می‌شود. واکاوی می‌گوید این اجزا را از هم جدا کن و هر کدام را جایی بگذار که برایش ساخته شده؛ و درست همان جا قیمتش را هم می‌دهی: چند سیستم، چند تیم، و مرزی که باید خودت حفظش کنی.A traditional database is that multi-tool: storage, query execution, indexing, transactions and coordination under one roof, with one team and one behaviour. For most work that is good — one thing to own, one thing to learn, one thing to back up. But when the analytical load grows, or when one table's access pattern differs from the rest, that togetherness becomes a ceiling. Unbundling says take the pieces apart and put each where it belongs; and that is exactly where the bill arrives: several systems, several teams, and a boundary you now have to maintain yourself.

پایگاه دادهٔ یکپارچهOne bundled databaseذخیره‌سازیStorageاجرای کوئریQuery executionایندکسIndexingهماهنگیCoordinationهر تیکه را می‌شود از جای دیگری آورد؛ به قیمت کارِ نگهداشتِ مرزEach piece can come from someone else, at the cost of owning the seam
یک پایگاه دادهٔ یکپارچه، و اجزایی که می‌شود جدا انتخابشان کرد.One bundled database, and the pieces you can now choose independently.

و بعدش، فنیAnd now, technically

در نسخهٔ دوم کتاب، این ایده پررنگ‌تر شده: پایگاه داده مجموعه‌ای از قابلیت‌هاست که می‌شود آن‌ها را جدا کرد. ذخیره‌سازی می‌تواند یک سرویس ابری باشد، اجرای پرس‌وجو موتور دیگری، هماهنگی و قفل‌ها سرویس سوم، و کش و ایندکس جای چهارم. مزیت اصلی این است که هر جزء را می‌شود مستقل مقیاس داد و مستقل ارتقا داد؛ عیب اصلی این است که مرز میان اجزا، که قبلاً داخل موتور و آزموده بود، حالا مسئولیت تو است. هر مرزی که خودت می‌سازی، به یک پروتکل، یک نسخه‌بندی و یک حالت شکستِ تازه نیاز دارد. در انتخاب، یک قاعدهٔ ساده کمک می‌کند: تا وقتی می‌توانی با یک موتور کار کنی، همان را نگه دار و فقط بخشی را جدا کن که واقعاً الگوی دسترسی متفاوتی دارد. هر جدا کردنی که بدون یک الگوی دسترسی متفاوت انجام شود، فقط یک مرز تازه و یک تیم تازه می‌سازد.The second edition pushes this idea harder: a database is a set of capabilities that can be separated. Storage can be a cloud service, query execution another engine, coordination and locks a third service, cache and index a fourth. The main advantage is that each piece scales and upgrades independently; the main cost is that the seams between them, previously inside a tested engine, are now your responsibility. Every seam you build needs a protocol, a versioning story and a new failure mode. One simple rule for the choice: stay with a single engine as long as you can, and split off only what genuinely has a different access pattern.

≥ 1 seamدو سیستم یعنی دست‌کم یک مرز که خودت نگه می‌داریtwo systems means at least one seam you own

کجا واکاوی جواب می‌دهدWhen unbundling pays off

وقتی الگوهای دسترسی واقعاً متفاوت‌اند. اگر یک جدول تحلیلی سنگین داری که فقط شبانه خوانده می‌شود و یک جدول تراکنشی که هزار بار در ثانیه نوشته می‌شود، نگه داشتن هر دو در یک موتور یعنی یکی همیشه قربانی می‌شود. جدا کردنشان، هر دو را از دست‌وپاگیری نجات می‌دهد. اما اگر همهٔ بار یک شکل است و یک تیم کوچک اداره‌اش می‌کند، واکاوی فقط پیچیدگی می‌خرد.When the access patterns genuinely differ. If you have a heavy analytical table read once a night and a transactional table written a thousand times a second, keeping both in one engine means one is always the victim. Separating them frees both. But if all the load has one shape and one small team runs it, unbundling buys complexity and nothing else.

قیمت پنهان: مرزThe hidden price is the seam

داخل یک پایگاه داده، یک کلمه کلیدی تضمین می‌دهد که دو تغییر با هم یا هر دو اعمال شوند یا هیچ‌کدام. وقتی ذخیره‌سازی و هماهنگی را جدا می‌کنی، آن تضمین دیگر رایگان نیست؛ باید خودت با شناسه، با 2PC، با saga یا با پذیرش سازگاری نهایی بازش بسازی. هر کدام از این‌ها یک انتخاب است، و انتخاب درست بدون فهمیدنِ حالت شکستِ همان مرز ممکن نیست.Inside one database, one keyword guarantees two changes are both applied or neither. Once you separate storage from coordination, that guarantee is no longer free; you rebuild it with identifiers, with 2PC, with a saga, or by accepting eventual consistency. Each of those is a choice, and the right choice is impossible without understanding the failure mode of that particular seam.

تلهٔ رایجThe usual trap

واکاوی برای اینکه «مدرن» به نظر برسی. بیشتر تیم‌هایی که یک پایگاه دادهٔ تک‌ماشینیِ سالم را به پنج سرویس شکستند، در سال بعد مشغول نوشتن ابزارهایی بودند که همان تضمین‌های قبلی را بازسازی کند — با کدِ خودشان، و با باگ‌های خودشان.Unbundling to look modern. Most teams that split a healthy single-machine database into five services spent the following year writing the tools that rebuild the guarantees they had — in their own code, with their own bugs.