Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Creating a Topic with Custom Configurations in Kafka

There are many custom configurations that we can apply to topics in Kafka. In this hands-on lab, we'll go through creating a topic, applying a custom configuration to that topic, and then testing the custom configuration by alerting the state of the partitions tied to that topic.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 21, 2025
Duration
45m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Set Up the Cluster

    Use Docker Compose to build the Kafka Cluster:

    cd content-kafka-deep-dive
    
    docker-compose up -d --build
    

    Now, let's make sure Java is installed (if you receive a dpkg frontend lock message, wait a few minutes and then try again):

    sudo apt install default-jdk
    

    Unzip and change into the Kafka binaries directory:

    tar -xvf kafka_2.12-2.2.0.tgz && mv kafka_2.12-2.2.0/ kafka
    
  2. Challenge

    Create a Topic with Three Partitions and a Replication Factor of `3`

    Create a topic named transaction:

    bin/kafka-topics.sh --zookeeper localhost:2181 
    --create 
    --topic transaction 
    --replication-factor 3 
    --partitions 3
    
  3. Challenge

    Add a Custom Configuration to the Topic

    Add the custom configuration min.insync.replicas=3 to the topic transaction:

    bin/kafka-configs.sh --zookeeper localhost:2181 
    --alter 
    --entity-type topics 
    --entity-name transaction 
    --add-config min.insync.replicas=3
    

    Verify the topic configuration applied:

    bin/kafka-configs.sh --zookeeper localhost:2181 
    --describe 
    --entity-type topics 
    --entity-name transaction
    
  4. Challenge

    Change the Replica Count for the Topic

    First off, let's create a JSON file named replicacount.json with these contents:

    {"partitions":
     [{"topic": "transaction", "partition": 0,
     "replicas": [
     2
     ]
     }
     ],
     "version":1
    }
    

    Now, we can execute the replica count change but using that JSON file:

    bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 
    --execute 
    --reassignment-json-file replicacount.json
    

    Once we get a "Successfully started..." message, let's describe the topic to see the replica change:

    bin/kafka-topics.sh --zookeeper localhost:2181 
    --topic transaction 
    --describe
    
  5. Challenge

    Run a Producer to Get an Error Message

    Open a producer and send some messages to your topic:

    bin/kafka-console-producer.sh --broker-list localhost:9092 
    --topic transaction 
    --producer-property acks=all
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight