Docsity

Apache Kafka and ElasticSEarch, Lecture notes of Computer Security

Partial preview of the text

Download Apache Kafka and ElasticSEarch and more Lecture notes Computer Security in PDF only on Docsity!

8/ 06 /2 0X X 1

APACHE KAFKA

2

APACHE KAFKA

  • Definition: Apache Kafka is a distributed event streaming platform that handles real-time data feeds.
  • (^) Kafka provides the infrastructure and environment to manage the flow of data in real-time, with built-in support for data storage, partitioning, replication, and distributed processing.
  • (^) It can act as a central hub for data that multiple systems or applications can read from or write to.
  • (^) It’s open-source and designed to allow high-throughput, low- latency transmission of data.
  • (^) Core Concepts:
    • (^) Producers: Write data related to a particular topic into partitions within Kafka.
    • (^) Topics: Split into partitions to enable scalability and parallelism.
    • (^) Consumers: Read data from specific partitions of topics.
    • Data Flow: Kafka ingests data from various sources (e.g., databases, applications, IoT devices) for real-time access by multiple systems..

APACHE KAFKA APPLICATIONS

  • (^) This allows Kafka to handle batch processing and data replay. If a consumer fails, it can resume reading from where it left off or reprocess past data as needed.
  • (^) Replay and Historical Data Access: Because Kafka stores data in a durable, fault-tolerant way, consumers can go back and re- read data from any point within the retention period. Applications:
  • (^) Processing payments and financial transactions
  • (^) Tracking and monitoring shipments
  • (^) Capturing and analyzing sensor data
  • (^) Monitoring patients in hospital care
  • (^) Streaming live match data

WHY APACHE KAFKA?

PARTITIONS IN APACHE KAFKA

CONSUMER GROUPS IN APACHE KAFKA

KAFKA TOPICS, PARTITIONS, AND DATA

FLOW

  • (^) Topic and Partition Structure: In Kafka, a topic is split into partitions for scalability and parallelism.
  • (^) A producer sends messages to a specific topic, but those messages are actually stored in partitions within that topic.
  • (^) Partitioning Logic: The producer might choose a specific partition based on a key, round-robin, or other logic, meaning each partition holds part of the data stream for that topic.
  • (^) Consumer Offset Tracking: Consumers read from these partitions, allowing them to process data in parallel across partitions while maintaining ordering within each partition

CONCEPT OF PARTITION

  • Partition 0 - Batting Events
  • This partition could store data related to batting events.
  • (^) Partition 1 - Bowling Events
  • (^) This partition could store data related to bowling event

APACHE KAFKA

  • (^) In Kafka, a broker is a server that holds partitions for topics.
  • (^) Manages partitions and handles requests for read and write operations.
  • If you have three partitions (partition 0, partition 1 and partition 2) on a single server, that server would be called a broker holding those three partitions.
  • (^) Typically, in a Kafka cluster, there are multiple brokers, each holding partitions for various topics, which allows Kafka to handle large-scale data distribution, redundancy, and fault tolerance across multiple servers.

FAULT TOLERANCE IN APACHE KAFKA

  • (^) If you have three partitions for a topic on Broker 0, and you want to ensure fault tolerance, Kafka can create replicas of those three partitions on Broker 1.
  • (^) Here’s how this setup would work for fault tolerance:
  • (^) Suppose you have Partition 0, Partition 1, and Partition 2 on Broker
  • (^) You can configure Kafka with a replication factor of 2 for this topic, meaning Kafka will create a second copy of each partition on Broker 1.
  • (^) On Broker 0, the partitions are the leaders (primary copies).
  • (^) On Broker 1, the partitions are followers (backup copies).
  • (^) If Broker 0 fails, Broker 1 can take over by promoting the follower replicas to leaders, allowing uninterrupted service for consumers.

ENCRYPTION IN APACHE KAFKA

  • (^) Encryption
  • (^) Brokers can be configured to use SSL/TLS to encrypt data in transit.
  • When clients connect to brokers, the data exchanged (both producer-to-broker and broker-to-consumer) is encrypted to protect it from eavesdropping and tampering. - (^) AES (Advanced Encryption Standard)- Used as the primary symmetric encryption algorithm to secure the data during transmission - (^) RSA (Rivest-Shamir-Adleman)-An asymmetric encryption scheme commonly used to securely exchange keys during the SSL/TLS handshake process.

ENCRYPTION IN APACHE KAFKA

  • (^) Producer Side: Data is prepared and encrypted using AES before sending to Kafka.
  • (^) A symmetric key is generated for encryption.
  • The ciphertext is sent to the Kafka topic.
  • (^) Broker Side: Kafka brokers store the encrypted messages in partitions without decrypting them, ensuring data remains secure during storage.
  • (^) Consumer Side: Consumers retrieve the encrypted messages and use the same AES key to decrypt them back into plaintext for processing.
  • (^) Secure key management is essential for maintaining confidentiality.