Bird
Raised Fist0
Kafkadevops~30 mins

Standalone vs distributed mode in Kafka - Hands-On Comparison

Choose your learning style10 modes available
Understanding Standalone vs Distributed Mode in Kafka
📖 Scenario: You are learning how Apache Kafka works in two main modes: standalone and distributed. Kafka is a system that helps send messages between programs quickly and reliably. Understanding these modes helps you set up Kafka correctly for small or big projects.
🎯 Goal: You will create simple Kafka configuration files for both standalone and distributed modes. Then, you will write commands to start Kafka in each mode and observe the differences.
📋 What You'll Learn
Create a Kafka configuration file for standalone mode named server-standalone.properties with specific settings.
Create a Kafka configuration file for distributed mode named server-distributed.properties with specific settings.
Write commands to start Kafka using each configuration file.
Print messages explaining which mode is running.
💡 Why This Matters
🌍 Real World
Kafka is widely used in companies to handle large streams of data. Knowing how to set it up in standalone or distributed mode helps you manage data pipelines effectively.
💼 Career
Many jobs in data engineering and backend development require understanding Kafka's deployment modes to build scalable and reliable systems.
Progress0 / 4 steps
1
Create Kafka configuration for standalone mode
Create a file named server-standalone.properties with these exact lines:
broker.id=0,
log.dirs=/tmp/kafka-logs-standalone,
zookeeper.connect=localhost:2181
Kafka
Hint

These settings tell Kafka to run as a single broker using local Zookeeper.

2
Create Kafka configuration for distributed mode
Create a file named server-distributed.properties with these exact lines:
broker.id=1,
log.dirs=/tmp/kafka-logs-distributed,
zookeeper.connect=localhost:2181,
num.network.threads=3
Kafka
Hint

These settings prepare Kafka to run as part of a cluster with multiple brokers.

3
Write commands to start Kafka in both modes
Write two commands:
1. bin/kafka-server-start.sh config/server-standalone.properties & to start standalone mode.
2. bin/kafka-server-start.sh config/server-distributed.properties & to start distributed mode.
Kafka
Hint

Use the kafka-server-start.sh script with the correct config file and run in background.

4
Print messages explaining the running mode
Write two print statements:
1. print("Kafka is running in standalone mode")
2. print("Kafka is running in distributed mode")
Kafka
Hint

Use print statements exactly as shown to display the mode messages.

Practice

(1/5)
1. What is the main purpose of running Kafka Connect in standalone mode?
easy
A. To run multiple workers for high scalability
B. To run Kafka Connect in a single process for simple or testing use
C. To enable fault tolerance across multiple machines
D. To connect Kafka with distributed databases automatically

Solution

  1. Step 1: Understand standalone mode context

    Standalone mode runs Kafka Connect in one process, suitable for simple or testing scenarios.
  2. Step 2: Compare with distributed mode

    Distributed mode runs multiple workers for scalability and fault tolerance, unlike standalone mode.
  3. Final Answer:

    To run Kafka Connect in a single process for simple or testing use -> Option B
  4. Quick Check:

    Standalone mode = single process for testing [OK]
Hint: Standalone = single process, simple use [OK]
Common Mistakes:
  • Confusing standalone with distributed mode
  • Thinking standalone supports fault tolerance
  • Assuming standalone is for large scale pipelines
2. Which of the following is the correct command to start Kafka Connect in distributed mode?
easy
A. kafka-connect.sh start-standalone
B. connect-standalone.sh config/connect-standalone.properties
C. kafka-connect.sh start-distributed
D. connect-distributed.sh config/connect-distributed.properties

Solution

  1. Step 1: Identify the script for distributed mode

    The script connect-distributed.sh is used to start Kafka Connect in distributed mode.
  2. Step 2: Confirm the configuration file

    The configuration file config/connect-distributed.properties is the standard config for distributed mode.
  3. Final Answer:

    connect-distributed.sh config/connect-distributed.properties -> Option D
  4. Quick Check:

    Distributed mode uses connect-distributed.sh [OK]
Hint: Distributed mode uses connect-distributed.sh script [OK]
Common Mistakes:
  • Using connect-standalone.sh for distributed mode
  • Mixing config files between modes
  • Assuming kafka-connect.sh is a valid command
3. Given the following scenario: You start Kafka Connect with connect-standalone.sh and add two connectors. What will happen if the process crashes?
medium
A. Both connectors will automatically restart on another worker
B. Connectors will continue running without interruption
C. The connectors will stop and require manual restart
D. Kafka Connect will switch to distributed mode automatically

Solution

  1. Step 1: Understand standalone mode fault tolerance

    Standalone mode runs in a single process without fault tolerance or automatic recovery.
  2. Step 2: Consequence of process crash

    If the process crashes, connectors stop and need manual restart because no other worker is available.
  3. Final Answer:

    The connectors will stop and require manual restart -> Option C
  4. Quick Check:

    Standalone mode lacks automatic recovery [OK]
Hint: Standalone mode needs manual restart after crash [OK]
Common Mistakes:
  • Assuming automatic failover in standalone mode
  • Thinking distributed mode starts automatically
  • Believing connectors run independently of the process
4. You configured Kafka Connect in distributed mode but notice that only one worker is running and no failover happens. What is the likely cause?
medium
A. You started Kafka Connect with connect-standalone.sh instead of connect-distributed.sh
B. You did not configure the Kafka cluster correctly
C. You forgot to add connectors to the worker
D. Distributed mode does not support multiple workers

Solution

  1. Step 1: Check the startup script used

    If connect-standalone.sh is used, only one worker runs without failover, even if config is for distributed mode.
  2. Step 2: Understand distributed mode requirements

    Distributed mode requires starting with connect-distributed.sh to run multiple workers and enable failover.
  3. Final Answer:

    You started Kafka Connect with connect-standalone.sh instead of connect-distributed.sh -> Option A
  4. Quick Check:

    Wrong startup script causes single worker [OK]
Hint: Use connect-distributed.sh to run multiple workers [OK]
Common Mistakes:
  • Assuming config alone enables distributed mode
  • Believing distributed mode runs with standalone script
  • Ignoring startup script importance
5. You have a data pipeline that must handle high volume and remain available even if one worker fails. Which Kafka Connect mode should you choose and why?
hard
A. Distributed mode, because it supports multiple workers and fault tolerance
B. Standalone mode, because it is simpler to configure
C. Standalone mode, because it automatically restarts connectors on failure
D. Distributed mode, because it runs connectors in a single process

Solution

  1. Step 1: Analyze pipeline requirements

    High volume and availability require scalability and fault tolerance.
  2. Step 2: Match requirements to Kafka Connect modes

    Distributed mode runs multiple workers and supports fault tolerance, meeting these needs.
  3. Final Answer:

    Distributed mode, because it supports multiple workers and fault tolerance -> Option A
  4. Quick Check:

    High volume + fault tolerance = distributed mode [OK]
Hint: Choose distributed mode for scalability and fault tolerance [OK]
Common Mistakes:
  • Choosing standalone for high availability
  • Thinking standalone auto-restarts connectors
  • Misunderstanding distributed mode runs single process
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard