Posted in Cloud Technology

Kafka as a Services

In Big Data, an enormous volume of data is used. Regarding data, we have two main challenges.The first challenge is how to collect large volume of data and the second challenge is to analyze the collected data. To overcome those challenges, you must need a messaging system.

Kafka is designed for distributed high throughput systems. Kafka tends to work very well as a replacement for a more traditional message broker. In comparison to other messaging systems, Kafka has better throughput, built-in partitioning, replication and inherent fault-tolerance, which makes it a good fit for large-scale message processing applications.

Trong BigData, một khối lượng dữ liệu khổng lồ được sử dụng. Về dữ liệu, chúng ta có hai thách thức chính, thách thức đầu tiên là làm thế nào để thu thập khối lượng lớn dữ liệu và thách thức thứ hai là phân tích dữ liệu thu thập được. Để vượt qua những thách thức đó, bạn phải cần một hệ thống nhắn tin.

Kafka được thiết kế cho các hệ thống thông lượng cao phân tán. Kafka có xu hướng hoạt động rất hiệu quả khi thay thế cho một nhà môi giới tin nhắn truyền thống hơn. So với các hệ thống nhắn tin khác, Kafka có thông lượng tốt hơn, phân vùng tích hợp, sao chép và khả năng chịu lỗi vốn có, điều này làm cho nó phù hợp với các ứng dụng xử lý tin nhắn quy mô lớn.

Translate to Vietnamese

What is a Messaging System?

A Messaging System is responsible for transferring data from one application to another, so the applications can focus on data, but not worry about how to share it. Distributed messaging is based on the concept of reliable message queuing. Messages are queued asynchronously between client applications and messaging system. Two types of messaging patterns are available − one is point to point and the other is publish-subscribe (pub-sub) messaging system. Most of the messaging patterns follow pub-sub.

Hệ thống Nhắn tin chịu trách nhiệm chuyển dữ liệu từ ứng dụng này sang ứng dụng khác, vì vậy các ứng dụng có thể tập trung vào dữ liệu, nhưng không phải lo lắng về cách chia sẻ dữ liệu đó. Nhắn tin phân tán dựa trên khái niệm xếp hàng tin nhắn đáng tin cậy. Tin nhắn được xếp hàng đợi không đồng bộ giữa các ứng dụng khách và hệ thống nhắn tin. Có hai kiểu nhắn tin – một kiểu là trỏ tới điểm và kiểu kia là hệ thống nhắn tin đăng ký xuất bản (pub-sub). Hầu hết các kiểu nhắn tin đều tuân theo pub-sub.

Translate to Vietnamese

Point to Point Messaging System

In a point-to-point system, messages are persisted in a queue. One or more consumers can consume the messages in the queue, but a particular message can be consumed by a maximum of one consumer only. Once a consumer reads a message in the queue, it disappears from that queue. The typical example of this system is an Order Processing System, where each order will be processed by one Order Processor, but Multiple Order Processors can work as well at the same time. The following diagram depicts the structure.

Trong point to point system, các thông báo được lưu trong một hàng đợi. Một hoặc nhiều người tiêu dùng có thể sử dụng các tin nhắn trong hàng đợi, nhưng một tin nhắn cụ thể chỉ có thể được sử dụng bởi tối đa một người tiêu dùng. Khi người tiêu dùng đọc một tin nhắn trong hàng đợi, tin nhắn đó sẽ biến mất khỏi hàng đợi đó. Ví dụ điển hình của hệ thống này là Hệ thống xử lý đơn hàng, trong đó mỗi đơn hàng sẽ được xử lý bởi một Bộ xử lý đơn hàng, nhưng Nhiều Bộ xử lý đơn hàng cũng có thể hoạt động cùng một lúc. Sơ đồ sau đây mô tả cấu trúc.

Translate to Vietnamese
point-to-point Messaging system

Publish-Subscribe Messaging System

In the publish-subscribe system, messages are persisted in a topic. Unlike point-to-point system, consumers can subscribe to one or more topic and consume all the messages in that topic. In the Publish-Subscribe system, message producers are called publishers and message consumers are called subscribers. A real-life example is Dish TV, which publishes different channels like sports, movies, music, etc., and anyone can subscribe to their own set of channels and get them whenever their subscribed channels are available.

Publish-Subscribe Messaging system

What is Kafka?

Apache Kafka is a distributed publish-subscribe messaging system and a robust queue that can handle a high volume of data and enables you to pass messages from one end-point to another. Kafka is suitable for both offline and online message consumption. Kafka messages are persisted on the disk and replicated within the cluster to prevent data loss. Kafka is built on top of the ZooKeeper synchronization service. It integrates very well with Apache Storm and Spark for real-time streaming data analysis.

Benefits

Following are a few benefits of Kafka −

  • Reliability − Kafka is distributed, partitioned, replicated and fault tolerance.
  • Scalability − Kafka messaging system scales easily without down time..
  • Durability − Kafka uses Distributed commit log which means messages persists on disk as fast as possible, hence it is durable..
  • Performance − Kafka has high throughput for both publishing and subscribing messages. It maintains stable performance even many TB of messages are stored.

Kafka is very fast and guarantees zero downtime and zero data loss.

Use Cases

Kafka can be used in many Use Cases. Some of them are listed below −

  • Metrics − Kafka is often used for operational monitoring data. This involves aggregating statistics from distributed applications to produce centralized feeds of operational data.
  • Log Aggregation Solution − Kafka can be used across an organization to collect logs from multiple services and make them available in a standard format to multiple con-sumers.
  • Stream Processing − Popular frameworks such as Storm and Spark Streaming read data from a topic, processes it, and write processed data to a new topic where it becomes available for users and applications. Kafka’s strong durability is also very useful in the context of stream processing.

Need for Kafka

Kafka is a unified platform for handling all the real-time data feeds. Kafka supports low latency message delivery and gives guarantee for fault tolerance in the presence of machine failures. It has the ability to handle a large number of diverse consumers. Kafka is very fast, performs 2 million writes/sec. Kafka persists all data to the disk, which essentially means that all the writes go to the page cache of the OS (RAM). This makes it very efficient to transfer data from page cache to a network socket.

Author:

My name is Truong Thanh, graduated Master of Information Technology and Artificial Intelligent in Frankfurt University,Germany. I create this Blog to share my experience about life, study, travel...with friend who have the same hobbies.

Leave a comment