14 Feb, 2024 - About 5 minutes
Redpanda
Intro
In this article I’ll go through the Redpanda quickstart guide.
Spinning up a Redpanda cluster in Docker to evaluate in Linux
Requirements
Make sure you have docker
and docker-compose
Setup
For lightweight testing, we are going to start a single Redpanda broker.
Create the following docker-compose.yml
file with the content:
version: "3.7" |
And start the execution with docker-compose up -d
Start Streaming
Let’s use the rpk
command-line tool to create a topic, produce messages to it, and consume messages.
Get information about the cluster with the command
docker exec -it redpanda-0 rpk cluster info |
Now lets create a topic called chat-room:
docker exec -it redpanda-0 rpk topic create chat-room |
Producing messages for that topic
docker exec -it redpanda-0 rpk topic produce chat-room |
Consuming one message from the topic
docker exec -it redpanda-0 rpk topic consume chat-room --num 1 |
You can install rpk
on your system directly and connect with the broker
curl -LO https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-linux-amd64.zip |
Then unzip the file and put the rpk binary on bin path ex: unzip rpk-linux-amd64.zip -d ~/.local/bin/
You can test the connection to your broker with:
rpk cluster info -X brokers=127.0.0.1:19092 |
Generating Mock Data
Let’s use the following command from our references to product mock data.
Leave one terminal open with the following command
rpk topic consume Products -X brokers=127.0.0.1:19092 |
On a different terminal create the following file schema.avsc
{ |
Make sure to install datagen
npm install -g @materializeinc/datagen |
Create the following .env
file
# Kafka Brokers |
Then execute the following command
datagen -s schema.avsc -n 10 |
And you just generated mock data based on the provided json file.
Take a look on the following repo for more details on datagen.
Conclusion
Redpanda provides a very quick alternative to have a quick kafka environment, which is especially good for developers. This article didn’t go deep on performance evaluations of Kafka vs Redpanda but their benchmarks worth assessing if that means reducing your kafka footprint.
Probably would let that for another article. Also I would like to test the SASL options and schema register option.