-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkafka-benchmarks.sh
82 lines (62 loc) · 2.27 KB
/
kafka-benchmarks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# debug flag on
#set -x
printf "\n"
# Stay in KAFKA_HOME Directory
cd $KAFKA_HOME
# List kafka Brokers
KAFKA_CONNECT=${1:-null}
N=${2:-null}
echo "Total $N brokers=$KAFKA_CONNECT"
# Each Node Should be able to create a new topic
./bin/kafka-topics.sh --create --zookeeper $HOSTNAME:2181 --replication-factor 1 --partitions 1 --topic topic-$HOSTNAME
# Duplicate topics should not be created
TOPIC_REP_ONE="test-topic-rep-one"
RESULT=$(./bin/kafka-topics.sh --list --zookeeper $HOSTNAME:2181 | grep -i $TOPIC_REP_ONE)
if [[ -z $RESULT ]] ; then
./bin/kafka-topics.sh --zookeeper $HOSTNAME:2181 --create --topic $TOPIC_REP_ONE --partitions 1 --replication-factor 1
fi
TOPIC_REP_N="test-topic-rep-$N"
RESULT=$(./bin/kafka-topics.sh --list --zookeeper $HOSTNAME:2181 | grep -i $TOPIC_REP_N)
if [[ -z $RESULT ]] ; then
./bin/kafka-topics.sh --zookeeper $HOSTNAME:2181 --create --topic $TOPIC_REP_N --partitions $N --replication-factor $N
fi
echo "$HOSTNAME - KAFKA TOPICS:"
./bin/kafka-topics.sh --list --zookeeper $HOSTNAME:2181
NUM_RECORDS=15000000
THROUGHPUT=$NUM_RECORDS
MESSAGES=$NUM_RECORDS
# Begin Benchmarking Apache Kafka
if [[ $HOSTNAME == "testbed-1" ]] ; then
echo "PRODUCER PROCESS @ $HOSTNAME -"
echo "$N-thread, async $N times replication, no compression"
./bin/kafka-producer-perf-test.sh --topic $TOPIC_REP_N \
--num-records $NUM_RECORDS \
--record-size 100 \
--throughput $THROUGHPUT \
--producer-props \
acks=1 \
bootstrap.servers=$KAFKA_CONNECT \
buffer.memory=67108864 \
compression.type=none \
batch.size=8196
printf "\n\n"
echo "1-thread, no replication, no compression"
./bin/kafka-producer-perf-test.sh --topic $TOPIC_REP_ONE \
--num-records $NUM_RECORDS \
--record-size 100 \
--throughput $THROUGHPUT \
--producer-props \
acks=1 \
bootstrap.servers=$KAFKA_CONNECT \
buffer.memory=67108864 \
compression.type=none \
batch.size=8196
else
echo "CONSUMER PROCESS @ $HOSTNAME -"
echo "1-thread, no replication, no compression"
./bin/kafka-consumer-perf-test.sh --topic $TOPIC_REP_ONE \
--zookeeper $HOSTNAME:2181 \
--messages $MESSAGES \
--threads 1
fi