Building Real-Time Data Systems by Example
Mitch Seymour

#Kafka
#Kafka_streaming
#Apache_Kafka
#ksqlDB
#data_services
🌊 پردازش بلادرنگ داده با Kafka Streams و ksqlDB
⚡ کار با Data Streamهای سریع، پیوسته و بدون مرز همیشه دشوار بوده، اما Kafka Streams و ksqlDB ساخت برنامههای Stream Processing را سادهتر و لذتبخشتر میکنن. این راهنمای عملی نشان میده چطور برنامههایی بسیار مقیاسپذیر برای جابهجایی، غنیسازی و تبدیل حجم بزرگی از دادهها در Real Time بسازی.
✨ ویژگیهای کلیدی
📨 مبانی Kafka و الگوی ارتباطی Publish/Subscribe یا Pub/Sub را بهصورت سریع و کاربردی توضیح میده.
⚙️ ساخت برنامههای Stateless و Stateful Stream Processing را با Kafka Streams و ksqlDB آموزش میده.
⏱️ عملیات پیشرفته Stateful مثل Windowed Joinها، Aggregationها، Time Semantics و Windowها را پوشش میده.
🧠 سازوکار داخلی Stateful Processing، Local State و روشهای پیشرفته State Management را بررسی میکنه.
🔌 قابلیتهای Data Integration در ksqlDB را با کمک Kafka Connect توضیح میده و کار با Collectionهای مختلف و Push و Pull Queryها را آموزش میده.
🚀 مسیر Testing، Monitoring و استقرار برنامههای Kafka Streams و ksqlDB در Production را پوشش میده.
📘 توضیح کتاب
🌊 دادههای مدرن فقط حجم بالایی ندارن؛ آنها بهصورت جریانهایی مداوم و پایانناپذیر روی Network حرکت میکنن. Kafka Streams و ksqlDB برای پردازش همین جریانهای پیوسته در Real Time طراحی شدن و به کسبوکارها اجازه میدن دادهها را همان لحظه ورود، Enrich، Transform یا پردازش کنن.
🧑💻 میچ سیمور، مهندس Data Services در Mailchimp، مفاهیم مهم Stream Processing را در بستر چند مسئله جذاب تجاری توضیح میده. کتاب Strengthهای Kafka Streams و ksqlDB را کنار هم قرار میده تا بتونی برای هر پروژه Stream Processing، ابزار مناسبتر را انتخاب کنی. مسیر ksqlDB بهخصوص برای Developerهایی که با Java کار نمیکنن، مقدمهای سادهتر و ملایمتر برای ورود به Stream Processing فراهم میکنه.
⚙️ آموزش با مبانی Kafka و الگوی Pub/Sub شروع میشه و سپس به ساخت برنامههای Stateless و Stateful میرسه. در ادامه، عملیات پیشرفتهای مثل Join، Aggregation، Windowed Processing، State Store و Processor API بررسی میشن تا درک روشنی از عملکرد Stateful Processing در لایههای داخلی به دست بیاری.
🔌 بخش ksqlDB نشان میده چطور با قابلیتهای Data Integration مبتنی بر Kafka Connect کار کنی، انواع مختلف Collectionها را مدیریت کنی و Push Query و Pull Query اجرا کنی. مباحث از پردازش پایه Stream شروع میشن و به تکنیکهای متوسط و پیشرفته میرسن.
📊 کتاب برای Data Engineerهایی نوشته شده که قصد دارن برنامههای بسیار مقیاسپذیر برای جابهجایی، غنیسازی و تبدیل حجم زیادی از داده در Real Time بسازن. این مهارتها در Business Intelligence، Analytic Pipeline، Threat Detection، Event Processing و کاربردهای متعدد دیگه استفاده میشن. Data Scientistها و Analystهایی که میخوان از فضای سنتی Batch Processing به تحلیل Real-Time Data Stream وارد بشن هم از مطالب کتاب استفاده میکنن.
🌐 در دنیای Data Engineering و Data Science، فناوریهای زیادی برای جلب توجه رقابت میکنن؛ از مطالب Subredditها و Hacker News گرفته تا Tech Blogها و صدها غرفه در کنفرانسهای فناوری. وقتی این هیاهو کنار گذاشته بشه، یک Pattern مهم دیده میشه: خیلی از فناوریها برای ذخیره و پردازش داده در Scale بالا ساخته شدن، اما تمرکز صرف روی Data Volume فقط نیمی از مسئله است.
🌊 فناوریهایی که تنها مشکل حجم داده را حل میکنن، معمولا از روشهای Batch-Oriented استفاده میکنن؛ یعنی Job روی حجم بزرگی از داده اجرا میشه که طی مدتی جمع شده است. نویسنده این کار را به نوشیدن یکباره تمام آب اقیانوس تشبیه میکنه. بعضی فناوریها با قدرت و الگوهای محاسباتی مدرن از پس آن برمیان، اما معمولا هزینه این کار Latency بالاست.
⚡ Kafka Streams و ksqlDB بهجای انتظار برای انباشتهشدن دادهها، جریانهای پیوسته را همان لحظه پردازش میکنن. از آنجا که بسیاری از مسائل تجاری به زمان حساس هستن، این روش نسبت به رویکردهای Batch مزیت رقابتی بزرگی ایجاد میکنه و امکان واکنش سریعتر و کارآمدتر به داده را فراهم میکنه.
🧠 یادگیری این دو فناوری، راهی برای درک مفاهیم عمومیتر Stream Processing هم هست؛ از مدلسازی داده بهشکل Stream و Table گرفته تا Stateless Transformation، استفاده از Local State برای Join و Aggregation، شناخت Time Semantics و گروهبندی داده در Time Bucket یا Window. این دانش کمک میکنه راهکارهای فعلی و آینده Stream Processing را بهتر مقایسه و ارزیابی کنی.
🎨 این فناوریها در مسیر حرفهای نویسنده تأثیر زیادی داشتن و به او کمک کردن کارهایی انجام بده که قبلا فراتر از توان خودش تصور میکرد. طبق Preface کتاب، تا پایان خواندن یکی از جملههای آن، یکی از برنامههای Kafka Streams نویسنده نه میلیون Event را پردازش کرده است. زبان مختصر و Expressive این ابزارها هم باعث میشه فرایند توسعه بیشتر شبیه یک هنر باشه تا کاری طاقتفرسا.
🎯 نویسنده کتاب را مثل Mixtapeای از تجربهها و ترکیبهای موردعلاقهاش در دنیای Stream Processing معرفی میکنه: Kafka Streams and ksqlDB, Volume 1. در پایان، میتونی این فناوریها را در Production مستقر کنی و از آنها برای ساخت راهکارهایی استفاده کنی که بدون صرف زمان غیرمنطقی، ارزش واقعی تجاری تولید میکنن.
🎯 چیزهایی که یاد میگیری
📨 با مبانی Kafka و الگوی ارتباطی Pub/Sub آشنا میشی.
⚙️ یاد میگیری برنامههای Stateless و Stateful را با Kafka Streams و ksqlDB بسازی.
⏱️ میتونی Windowed Joinها، Aggregationها و عملیات پیشرفته Stateful را پیادهسازی کنی.
🧠 درک میکنی Stateful Processing و Local State در لایههای داخلی چطور کار میکنن.
🔌 یاد میگیری از قابلیتهای Data Integration در ksqlDB که با Kafka Connect پشتیبانی میشن استفاده کنی.
🗃️ میتونی با Collectionهای مختلف ksqlDB کار کنی و Push و Pull Query اجرا کنی.
🧪 با Testing، Monitoring و Configuration برنامههای Kafka Streams و ksqlDB آشنا میشی.
🚀 یاد میگیری برنامههای Stream Processing را برای محیط Production آماده و Deploy کنی.
👤 این کتاب برای چه کسانیه؟
🗃️ این کتاب برای Data Engineerهایی نوشته شده که میخوان برنامههای بسیار مقیاسپذیر Stream Processing برای جابهجایی، غنیسازی و تبدیل حجم زیادی از داده در Real Time بسازن. این مهارتها در Business Intelligence، Analytic Pipeline، Threat Detection، Event Processing و کاربردهای دیگر موردنیاز هستن.
📊 Data Scientistها و Analystهایی که میخوان مهارتهای خود را با تحلیل Real-Time Data Stream ارتقا بدن هم از کتاب استفاده میکنن. این مسیر، فاصلهای هیجانانگیز از Batch Processing سنتی ایجاد میکنه که معمولا بر این حوزهها غالب بوده است.
📌 تجربه قبلی کار با Apache Kafka لازم نیست، اما مقداری آشنایی با زبان Java دنبالکردن آموزشهای Kafka Streams را سادهتر میکنه. مسیر ksqlDB هم برای Non-Java Developerها نقطه شروع قابلدسترستریه.
📖 فهرست مطالب
بخش اول. Kafka
فصل ۱. مقدمهای سریع بر Kafka
بخش دوم. Kafka Streams
فصل ۲. شروع کار با Kafka Streams
فصل ۳. Stateless Processing
فصل ۴. Stateful Processing
فصل ۵. Windowها و Time
فصل ۶. مدیریت پیشرفته State
فصل ۷. Processor API
بخش سوم. ksqlDB
فصل ۸. شروع کار با ksqlDB
فصل ۹. Data Integration با ksqlDB
فصل ۱۰. مبانی Stream Processing با ksqlDB
فصل ۱۱. Stream Processing متوسط و پیشرفته با ksqlDB
بخش چهارم. مسیر رسیدن به Production
فصل ۱۲. Testing، Monitoring و Deployment
ضمیمه A. پیکربندی Kafka Streams
ضمیمه B. پیکربندی ksqlDB
👤 درباره نویسنده
🧑💻 میچ سیمور Senior Data Systems Engineer در Mailchimp است. او با استفاده از Kafka Streams و KSQL چندین برنامه Stream Processing ساخته که روزانه میلیاردها Event را با Latency کمتر از یک ثانیه پردازش میکنن.
🌐 او در جامعه Open Source فعاله و درباره فناوریهای Stream Processing در کنفرانسهای بینالمللی، از جمله Kafka Summit London 2019، ارائه داشته است.
🎤 میچ سیمور در Meetupهای محلی درباره Kafka Streams و KSQL صحبت میکنه و از Contributorهای Blog شرکت Confluent است.
Working with unbounded and fast-moving data streams has historically been difficult. But with Kafka Streams and ksqlDB, building stream processing applications is easy and fun. This practical guide shows data engineers how to use these tools to build highly scalable stream processing applications for moving, enriching, and transforming large amounts of data in real time.
Mitch Seymour, data services engineer at Mailchimp, explains important stream processing concepts against a backdrop of several interesting business problems. You'll learn the strengths of both Kafka Streams and ksqlDB to help you choose the best tool for each unique stream processing project. Non-Java developers will find the ksqlDB path to be an especially gentle introduction to stream processing.
Table of Contents
Part I. Kafka
Chapter 1. A Rapid Introduction to Kafka
Part II. Kafka Streams
Chapter 2. Getting Started with Kafka Streams
Chapter 3. Stateless Processing
Chapter 4. Stateful Processing
Chapter 5. Windows and Time
Chapter 6. Advanced State Management
Chapter 7. Processor API
Part III. ksqlDB
Chapter 8. Getting Started with ksqlDB
Chapter 9. Data Integration with ksqlDB
Chapter 10. Stream Processing Basics with ksqlDB
Chapter 11. Intermediate and Advanced Stream Processing with ksqlDB
Part IV. The Road to Production
Chapter 12. Testing, Monitoring, and Deployment
Appendix A. Kafka Streams Configuration
Appendix B. ksqlDB Configuration
This book is for data engineers who want to learn how to build highly scalable stream processing applications for moving, enriching, and transforming large amounts of data in real time. These skills are often needed to support business intelligence initiatives, analytic pipelines, threat detection, event processing, and more. Data scientists and analysts who want to upgrade their skills by analyzing real-time data streams will also find value in this book, which is an exciting departure from the batch processing space that has typically dominated these fields. Prior experience with Apache Kafka is not required, though some familiarity with the Java programming language will make the Kafka Streams tutorials easier to follow.
For data engineers and data scientists, there’s never a shortage of technologies that are competing for our attention. Whether we’re perusing our favorite subreddits, scanning Hacker News, reading tech blogs, or weaving through hundreds of tables at a tech conference, there are so many things to look at that it can start to feel overwhelming.
But if we can find a quiet corner to just think for a minute, and let all of the buzz fade into the background, we can start to distinguish patterns from the noise. You see, we live in the age of explosive data growth, and many of these technologies were created to help us store and process data at scale. We’re told that these are modern solutions for modern problems, and we sit around discussing “big data” as if the idea is avant-garde, when really the focus on data volume is only half the story.
Technologies that only solve for the data volume problem tend to have batch-oriented techniques for processing data. This involves running a job on some pile of data that has accumulated for a period of time. In some ways, this is like trying to drink the ocean all at once. With modern computing power and paradigms, some technologies actually manage to achieve this, though usually at the expense of high latency.
Instead, there’s another property of modern data that we focus on in this book: data moves over networks in steady and never-ending streams. The technologies we cover in this book, Kafka Streams and ksqlDB, are specifically designed to process these continuous data streams in real time, and provide huge competitive advantages over the ocean-drinking variety. After all, many business problems are time-sensitive, and if you need to enrich, transform, or react to data as soon as it comes in, then Kafka Streams and ksqlDB will help get you there with ease and efficiency.
Learning Kafka Streams and ksqlDB is also a great way to familiarize yourself with the larger concepts involved in stream processing. This includes modeling data in different ways (streams and tables), applying stateless transformations of data, using local state for more advanced operations (joins, aggregations), understanding the different time semantics and methods for grouping data into time buckets/windows, and more. In other words, your knowledge of Kafka Streams and ksqlDB will help you distinguish and evaluate different stream processing solutions that currently exist and may come into existence sometime in the future.
I’m excited to share these technologies with you because they have both made an impact on my own career and helped me accomplish technological feats that I thought were beyond my own capabilities. In fact, by the time you finish reading this sentence, one of my Kafka Streams applications will have processed nine million events. The feeling you’ll get by providing real business value without having to invest exorbitant amounts of time on the solution will keep you working with these technologies for years to come, and the succinct and expressive language constructs make the process feel more like an art form than a labor. And just like any other art form, whether it be a life-changing song or a beautiful painting, it’s human nature to want to share it. So consider this book a mixtape from me to you, with my favorite compilations from the stream processing space available for your enjoyment: Kafka Streams and ksqlDB, Volume 1.
Mitch Seymour is a Senior Data Systems Engineer at Mailchimp. Using Kafka Streams and KSQL, he has built several stream processing applications that process billions of events per day with sub-second latency. He is active in the open source community, has presented about stream processing technologies at international conferences (Kafka Summit London, 2019), speaks about Kafka Streams and KSQL at local meetups, and is a contributor to the Confluent blog.









