Test latency and throughput in Redpanda using Redpanda CLI (rpk):
To test latency and throughput in Redpanda, follow these steps. You'll use tools like rpk (Redpanda’s CLI)
or existing Kafka benchmarking tools (since Redpanda is Kafka
API-compatible). Below are approaches to measure both metrics effectively:
Prerequisites
- Install
Redpanda:
- Follow
the installation instructions from Redpanda’s official website to set up
a Redpanda cluster (single-node or multi-node).
- Install
Redpanda CLI (rpk):
- rpk
(Redpanda's CLI) is essential for running benchmarks and managing the
cluster. Install it as per the official instructions:
Install RedPanda
apt install redpanda
- Kafka-compatible
Tools:
- Since
Redpanda is compatible with Kafka, tools like Kafka Producer
Performance (kafka-producer-perf-test.sh) and Kafka Consumer
Performance (kafka-consumer-perf-test.sh) can be used.
1. Testing Throughput
Throughput measures the rate of data transfer in terms of
messages per second or megabytes per second.
a) Using rpk to Measure Throughput
- rpk
has built-in benchmarking capabilities to test the producer and consumer
throughput.
- Producer
Throughput Test: You can generate test data and measure the throughput
of producing messages to a Redpanda topic.
bash
rpk topic produce --brokers localhost:9092 --key test-key --value test-value -n 10000 --rate 500
Here:
- --brokers:
The address of your Redpanda broker.
- -n
10000: Number of messages to send.
- --rate
500: Send messages at a rate of 500 messages per second.
- Consumer
Throughput Test: Consume messages from a topic to measure how fast
consumers can process them.
bash
rpk topic consume test-topic --offset oldest --num 10000
This will consume 10,000 messages and show you the
processing speed.
b) Using Kafka Performance Test Scripts
If you want to simulate heavy traffic and measure
throughput:
- Producer
Throughput (Kafka):
bash
kafka-producer-perf-test.sh \
--topic test-topic
\
--num-records
100000 \
--record-size 1024
\
--throughput -1 \
--producer-props
bootstrap.servers=localhost:9092
Here:
- --num-records
100000: Sends 100,000 messages.
- --record-size
1024: Each message is 1024 bytes.
- --throughput
-1: No limit on throughput (send as fast as possible).
- --producer-props:
Kafka producer properties, including the Redpanda broker address.
- Consumer
Throughput (Kafka):
bash
kafka-consumer-perf-test.sh \
--broker-list
localhost:9092 \
--topic test-topic
\
--messages 100000
This will consume 100,000 messages from the topic and
provide throughput results.
2. Testing Latency
Latency measures the time taken to deliver a message from
producer to consumer.
a) Using rpk to Measure Latency
To test the latency of messages, you can produce and consume
messages while observing the latency of message delivery.
- Producer
Latency Test: Measure the time it takes for each message to be
produced:
bash
rpk topic produce --brokers localhost:9092 --key test-key --value test-value -n 10000 --latency
This command will measure the time each message takes to be
delivered to the broker.
- End-to-End
Latency Test: You can measure end-to-end latency by producing
and consuming messages in real-time. This is done by observing the time
when a message is produced and when it's consumed.
- Produce
messages to a topic:
bash
rpk topic produce test-topic -n 10000 --rate 100 --value "Message with latency test"
- At
the same time, start a consumer:
bash
rpk topic consume test-topic --offset oldest
- Compare
the timestamps of when messages were produced and when they were consumed.
b) Using Kafka Tools
To perform a detailed latency test using Kafka’s producer
performance tool, you can look at how long it takes to acknowledge a sent
message.
- Producer
Latency (Kafka):
bash
kafka-producer-perf-test.sh \
--topic test-topic
\
--num-records
10000 \
--record-size 1024
\
--throughput 500 \
--producer-props
bootstrap.servers=localhost:9092 \
--print-metrics
- --print-metrics:
This will print out detailed producer metrics, including message send
latency.
3. Benchmarking with Multiple Brokers
If you're using a multi-node Redpanda cluster, you
can stress-test the system by producing/consuming from multiple nodes.
- Modify
the --brokers argument to list all the brokers in your Redpanda cluster:
bash
rpk topic produce --brokers broker1:9092,broker2:9092
--topic test-topic -n 100000
This helps to measure latency and throughput across multiple
brokers in a real-world distributed setup.
4. Monitoring Performance Metrics
- rpk
metrics: Use rpk to observe performance and resource usage metrics in
real-time.
bash
rpk cluster info
rpk metrics stream
This gives you detailed statistics like message throughput,
disk usage, and network metrics.
5. Cloud-Based Testing
If you're testing Redpanda in a cloud environment,
consider using monitoring solutions like Prometheus and Grafana
to track latency, throughput, and system metrics (CPU,
memory, disk I/O) during the test.
Conclusion:
- Throughput
can be measured using rpk or Kafka’s producer/consumer performance scripts
by stressing the cluster with a high volume of messages and measuring
message rates.
- Latency
can be measured using tools like rpk to observe end-to-end message
delivery times or producer acknowledgment times.
Make sure to run tests in a production-like environment to
get accurate insights into how Redpanda performs under load.
No comments:
Post a Comment