Kafka troubleshooting

Introduction to Apache Kafka

Mike Metzger

Data Engineering Consultant

"Helpful" behaviors

  • Kafka tries to be helpful to users
  • Sometimes causes issues instead
  • By default, a topic does not need to exist before writing
  • Consider what happens if you misspell a topic name (ie, ordrs instead of orders)

Picture of a confused dog

1 Image courtesy Dex Ezekiel on Unsplash
Introduction to Apache Kafka

"Helpful" example

$ bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
orders
$ echo "Test message" | bin/kafka-console-producer.sh 
   --bootstrap-server localhost:9092 \
   --topic ordrs
$ bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
orders
ordrs
Introduction to Apache Kafka

Connectivity issues

  • Kafka is a networked service
  • Any networking issues can cause problems with Kafka communications
  • Look at the output of commands to determine potential issues

bin\kafka-topics.sh --bootstrap-server localhost:9092 --list

WARN [AdminClient clientId=adminclient-1] 
  Connection to node -1 (localhost/127.0.0.1:9092) could not be established.
  Node may not be available. (org.apache.kafka.clients.NetworkClient)
  • Check Kafka service is running (ps ax | grep kafka, netstat -tlnp | grep 9092)
  • Check for firewall issues
  • Verify correct port / IP
Introduction to Apache Kafka

Other common problems

  • Consumers:
    • Use --from-beginning if you need older messages
    • Remember --max-messages to only read a specific message quantity
  • All tools:
    • Remember to include the --bootstrap-server
    • Most error messages are pretty clear and point you to likely solutions
    • Tools also have a --help option to get further details
Introduction to Apache Kafka

Let's practice!

Introduction to Apache Kafka

Preparing Video For Download...