- عنوان کتاب: Cockroachdb -The Definitive Guide Distributed Data at Scale
- نویسنده: Guy Harrison
- حوزه: راهنمای CockroachDB
- سال انتشار: 2025
- تعداد صفحه: 541
- زبان اصلی: انگلیسی
- نوع فایل: pdf
- حجم فایل: 5.91 مگابایت
به CockroachDB: راهنمای قطعی خوش آمدید و از حضور شما متشکریم! با این کتاب، میخواهیم به شما در یادگیری ساخت و استقرار برنامهها با CockroachDB، پایگاه داده SQL توزیعشدهای که در هر کجای مسیرتان – در فضای ابری، در محل یا ترکیبی – با شما همراه میشود، کمک کنیم. اول، سوالی که همه میپرسند: چرا نام CockroachDB؟ یک واقعیت تغییرناپذیر مهندسی این است که همه چیز خراب میشود. در مقیاس به اندازه کافی بزرگ، همه چیز همیشه در حال خراب شدن است. انواع خرابیهایی که ممکن است سالی یک بار در یک دستگاه واحد اتفاق بیفتد، وقتی هزاران دستگاه از آنها را اجرا میکنید، به اتفاقات روزانه تبدیل میشوند. سیستمی که میخواهد در مقیاس بزرگ کار کند، باید تحمل خطا را به عنوان یک مسئولیت اصلی در نظر بگیرد. این یکی از بینشهای کلیدی چارچوب MapReduce گوگل بود. با الزام به اینکه تمام محاسبات در یک چارچوب نسبتاً محدود قرار گیرند، برای سیستم ساده شد که پس از یک خرابی، به طور خودکار قطعات لازم کار را دوباره اجرا کند. ما معتقدیم که باید اینگونه باشد: تکثیر با دسترسی بالا باید حالت پیشفرض یک پایگاه داده از روز اول باشد، نه نتیجه کار پیکربندی پر زحمت. و با نگاهی به روز دوم (یا روز دویستم)، پایگاه داده باید بتواند همراه با برنامه رشد کند تا موفقیت ناگهانی دلیلی برای جشن گرفتن باشد، نه وحشت. وقتی Cockroach Labs شروع به ساخت یک پایگاه داده رابطهای از ابتدا کرد، میخواستیم ثبات، انعطافپذیری بومی، محلی بودن دادهها و مقیاسپذیری گسترده را به برنامههای مدرن بیاوریم. چشمانداز ما سیستمی بود که بتواند هر منبعی را که به آن میدهید، استعمار کند و سپس بیوقفه خود را بهینه کند. پایگاه دادهای که از فضای موجود استفاده کند و در مجموعهای هماهنگ از گرههای توزیعشده به تعادل برسد، به طوری که نه تنها منابع جدید را در خود جای دهد، بلکه – اگر یک ماشین یا مرکز داده یا حتی کل یک منطقه از کار بیفتد – پایگاه داده به سادگی منابع موجود باقیمانده را متعادل کند. منشأ CockroachDB داستان ضرورت است. به معنای واقعی کلمه، اسپنسر کیمبال، پیتر متیس و من، بن دارنل، شروع به ساخت پایگاه داده رابطهای کردیم که خودمان به آن نیاز داشتیم. پس از همکاری در گوگل، هر سه نفر ما مدتی در مسیرهای مختلفی حرکت کردیم. در نهایت ما (به همراه برادر اسپنسر، اندی، که از کهنهکاران مایکروسافت SQL Server بود) دوباره در یک استارتاپ به نام Viewfinder با هم همکاری کردیم و یک اپلیکیشن برای سازماندهی عکس و اشتراکگذاری اجتماعی ساختیم. البته ما امیدوار بودیم که این پروژه موفقیتآمیز باشد، بنابراین میخواستیم برای مقیاسپذیری بسازیم. از این گذشته، همانطور که اسپنسر میگوید، “گاهی اوقات اتفاقات بدی میافتد. و در مقیاس بزرگ، اتفاقات بدی همیشه در حال رخ دادن است.” مشخص شد که با توجه به سابقه آن پروژه، ما به اندازه کافی خوب عمل نکردیم که به مقیاسپذیری گسترده نیاز داشته باشیم، اما میخواستیم از همان ابتدا برای آن برنامهریزی کنیم. ما همچنین نمیخواستیم خودمان را در یک پایگاه داده یکپارچه، تقسیمبندی MySQL یا چیزی شبیه به آن حبس کنیم. ما قبلاً این مسیر را طی کرده بودیم و میدانستیم که به جایی که میخواهیم نمیرسیم. این باعث شد که ما به گزینههای NoSQL به عنوان بهترین جایگزین نگاه کنیم و در نهایت به DynamoDB رسیدیم. DynamoDB بسیاری از موارد را داشت: مقیاسپذیر، سریع و قابل پیشبینی است. این بسیار شبیه به Bigtable است که من در زمان حضورم در گوگل از آن به عنوان بکاند برای گوگل ریدر استفاده میکردم. و بنابراین، حداقل روی کاغذ، ما واقعاً آن مدل را دوست داشتیم. اما با کسب تجربه با آن، متوجه شدیم که چند مشکل اساسی با NoSQL داریم. بزرگترین مشکل این بود که متوجه شدیم واقعاً به شاخصهای ثانویه نیاز داریم. مدل Bigtable/DynamoDB در واقع فقط کلیدهای اصلی است؛ هیچ مفهومی از شاخصهای ثانویه وجود ندارد. برای به دست آوردن آنها، مجبور شدیم پیادهسازی جزئی خودمان از تراکنشها را بر روی DynamoDB بسازیم که قابل اجرا بود. با این حال، هنگامی که از این سیستم استفاده کردیم، با یک مشکل بعدی مواجه شدیم. DynamoDB به خودی خود بسیار سریع، قابل پیشبینی و مقیاسپذیر است – اما وقتی شروع به انجام کارهایی میکنید که چندین رکورد را ترکیب میکنند، همانطور که ما با شاخصهای ثانویه خود انجام میدادیم، اوضاع دشوار شد. در نهایت، ما به سیستمی رسیدیم که کار میکرد، اما لایهبندی تراکنشها و شاخصها بر روی DynamoDB، هم از نظر عملکرد و هم از نظر تلاشهای مهندسی ما، ناکارآمد بود. در این مدت، ما شروع به صحبت در مورد ایده ساخت یک پایگاه داده خودمان کردیم، اما Viewfinder یک استارتاپ با یک تیم کوچک بود. ما تصمیم گرفتیم، میدانید، DynamoDB ایدهآل نیست، اما وجود دارد و ما میتوانیم امروز از آن استفاده کنیم، بنابراین این کاری است که ما انجام خواهیم داد. اما یک یا دو سال بعد، Square Viewfinder را خرید و متوجه شدیم که آنها با MySQL تکه تکه شده مشکل دارند. آن موقع متوجه شدیم، خب، فقط ما نیستیم، این یک نیاز واقعی به پایگاه داده است که برآورده نمیشود. در Square، ما اکنون در موقعیت خوبی بودیم تا سعی کنیم سیستمی بسازیم که ذاتاً مقیاسپذیر باشد و از شاخصهای ثانویه پشتیبانی کند. بنابراین، از آنجا بود که تلاش واقعاً به طور جدی آغاز شد. اسپنسر در ابتدا آن را به عنوان یک پروژه جانبی در شبها و آخر هفتهها شروع کرد. و سپس او مشارکتکنندگان بیشتری پیدا کرد و در نهایت حتی به یک پروژه رسمی در Square تبدیل شد. اما ما میدانستیم که سرنوشت واقعی این پروژه خدمت به کل بازار پایگاه داده است، بنابراین آن زمان بود که تصمیم گرفتیم آنجا را ترک کنیم.
Welcome to CockroachDB: The Definitive Guide, and thank you for being here! With this book, we want to help you learn to build and deploy applications with CockroachDB, the distributed SQL database that meets you where you’re at on your journey—in the cloud, on-premises, or hybrid. First, the question everyone asks: Why the name CockroachDB? One immutable fact of engineering is that things break. At large enough scale, things are breaking all the time. The kinds of failures that might happen once a year on a single machine become daily occurrences when you’re running thousands of them. A system that aspires to handle large scale must treat fault tolerance as a core responsibility. This was one of the key insights of Google’s MapReduce framework. By requiring all computation to fit within a relatively restrictive framework, it became straightforward for the system to automatically rerun the necessary pieces of work after a failure. We believe that this is how it should be: highly available replication should be the default state of a database from Day One, not the result of painstaking configuration work. And looking ahead to Day Two (or Day Two Hundred), the database must be able to grow along with the application so that runaway success is a cause for celebration, not panic. When Cockroach Labs set out to build a relational database from scratch, we wanted to bring consistency, native resilience, data locality, and massive scale to modern applications. Our vision was of a system able to colonize any resource that you gave it and then relentlessly optimize itself. A database that would use available space and reach equilibrium across a coordinated set of distributed nodes so that it would not only incorporate new resources, but—if a machine or data center or even an entire region went down—the database would simply equalize the remaining available resources. CockroachDB’s origin is a tale of necessity. Quite literally, Spencer Kimball, Peter Mattis, and I, Ben Darnell, set out to build the relational database that we ourselves needed. After working together at Google, the three of us went in different directions for a while. Eventually we ended up back together (along with Spencer’s brother Andy, a Microsoft SQL Server veteran) at a startup called Viewfinder, building an application for photo organization and social sharing. We, of course, hoped it would be successful, so we wanted to build for scale. After all, as Spencer says, “Sometimes shit happens. And, at scale, shit’s always happening.” It turns out that, given the history of that project, we didn’t do well enough to ever need massive scalability, but we wanted to plan for it from the beginning. We also didn’t want to lock ourselves into a monolithic database, sharding MySQL or anything like that. We had been down that road before and knew it didn’t lead where we wanted to go. This left us looking at NoSQL options as the best alternative and eventually we settled on DynamoDB. DynamoDB ticked a lot of boxes: it’s scalable, it’s fast, it’s predictable. It’s very similar to Bigtable, which I had used as the backend for Google Reader while I was at Google. And so, on paper at least, we really liked that model. But as we got experience with it, we realized we had a couple of fundamental problems with NoSQL. The biggest one was we found that we really needed secondary indexes. The Bigtable/ DynamoDB model is really primary keys only; there’s no concept of secondary indexes. To get them, we had to build our own partial implementation of transactions on top of DynamoDB, which was workable. Once we were using this system, however, we found a subsequent problem. DynamoDB on its own is very fast, predictable, and scalable—but once you start doing things that combine multiple records, as we were doing with our secondary indexes, then things got difficult. Ultimately, we came up with a system that worked, but the layering of transactions and indexes on top of DynamoDB was inefficient, both in terms of performance and our engineering efforts. During this time we did start talking about the idea of building a database ourselves, but Viewfinder was a startup with a small team. We decided, You know, DynamoDB is not ideal, but it exists and we can use it today, so that’s what we’ll do. But then a year or two later Square bought Viewfinder, and we found out they were struggling with sharded MySQL. We realized then, Okay, it’s not just us, this is a real database need that’s not getting met. At Square we were now in a good position to try building a system that was both inherently scalable and supported secondary indexes. So that’s where the effort really started in earnest. Spencer started on it as a side project on nights and weekends at first. And then he got some more contributors, and eventually it even became an official project at Square. But we knew that the real destiny of this project was to serve the entire database market, so that’s when we decided to leave Square and start a company to do just that: Cockroach Labs was founded in 2015.
این کتاب را میتوانید از لینک زیر بصورت رایگان دانلود کنید:
Download: Cockroachdb The Definitive Guide Distributed Data at Scale

نظرات کاربران