Skip to content

Commit

Permalink
added graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkumarjain committed Jan 19, 2024
1 parent f39e8c5 commit 9ca1ad9
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 179 deletions.
22 changes: 15 additions & 7 deletions kafka-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,27 @@ docker-compose -p kafka -f docker-compose.yml up

## Results

All the [benchmarks](/results.out) are performed in the `Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz` machine with `100K` samples and `5` iterations.
All the [benchmarks](/results.out) are performed in the `Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz` machine by running with `10K` samples and `5` iterations.

![Average](/in-memory-cache/results/Average_Cache.png)
### Producer

### Average ns / operation
#### Microsecond / Operation

#### Set Function
| Sync Producer | Async Producer |
| -------- | ------- |
|![SyncProducerTime.png](/kafka-client/results/SyncProducerTime.png)|![AsyncProducerTime.png](/kafka-client/results/AsyncProducerTime.png)|

![Average_ns_per_operation_set.png](/in-memory-cache/results/Average_ns_per_operation_set.png)
#### Memory Allocation / Operation

#### Get & Remove Function
| Sync Producer | Async Producer |
| -------- | ------- |
|![SyncProducerTime.png](/kafka-client/results/SyncProducerMemoryAllocations.png)|![AsyncProducerTime.png](/kafka-client/results/AsyncProducerMemoryAllocations.png)|

![Average_ns_per_operation_get_remove](/in-memory-cache/results/Average_ns_per_operation_get_remove.png)
#### Bytes / Operation

| Sync Producer | Async Producer |
| -------- | ------- |
|![SyncProducerTime.png](/kafka-client/results/SyncProducerBytes.png)|![AsyncProducerTime.png](/kafka-client/results/AsyncProducerBytes.png)|

## Libraries

Expand Down
4 changes: 2 additions & 2 deletions kafka-client/confluent/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewProducer(bootstrapServers string) *Producer {
return producer
}

func (p *Producer) Produce(topic string, key string, value string) {
func (p *Producer) ProduceSync(topic string, key string, value string) {
deliveryChan := make(chan kafka.Event, 1)
p.instance.Produce(&kafka.Message{
TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny},
Expand All @@ -36,7 +36,7 @@ func (p *Producer) Produce(topic string, key string, value string) {
<-deliveryChan
}

func (p *Producer) ProduceChannel(topic string, key string, value string) {
func (p *Producer) ProduceAsync(topic string, key string, value string) {
p.wg.Add(1)
p.instance.Produce(&kafka.Message{
TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny},
Expand Down
4 changes: 2 additions & 2 deletions kafka-client/franz/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func NewProducer(bootstrapServers string) *Producer {
return producer
}

func (p *Producer) Produce(topic string, key string, value string) {
func (p *Producer) ProduceSync(topic string, key string, value string) {
p.instance.ProduceSync(context.Background(), &kgo.Record{Topic: topic, Key: []byte(key), Value: []byte(value)})
}

func (p *Producer) ProduceChannel(topic string, key string, value string) {
func (p *Producer) ProduceAsync(topic string, key string, value string) {
p.wg.Add(1)
p.instance.Produce(context.Background(), &kgo.Record{Topic: topic, Key: []byte(key), Value: []byte(value)}, p.DeliveryReport)
}
Expand Down
4 changes: 2 additions & 2 deletions kafka-client/goka/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func NewProducer(bootstrapServers string, topic string) *Producer {
return producer
}

func (p *Producer) Produce(key string, value string) {
func (p *Producer) ProduceSync(key string, value string) {
p.instance.EmitSync(key, value)
}

func (p *Producer) ProduceChannel(key string, value string) {
func (p *Producer) ProduceAsync(key string, value string) {
p.wg.Add(1)
promise, err := p.instance.Emit(key, value)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions kafka-client/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func benchmarkConfluentProducer(b *testing.B, prefix string, valueGenerator func
b.Run(testName(prefix, "Confluent@Produce"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.Produce(topicName, generateKey(prefix, i), valueGenerator(i))
producer.ProduceSync(topicName, generateKey(prefix, i), valueGenerator(i))
}
b.StopTimer()
})

b.Run(testName(prefix, "Confluent@ProduceChannel"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.ProduceChannel(topicName, generateKey(prefix, i), valueGenerator(i))
producer.ProduceAsync(topicName, generateKey(prefix, i), valueGenerator(i))
}
producer.Wait()
b.StopTimer()
Expand All @@ -47,7 +47,7 @@ func benchmarkFranzProducer(b *testing.B, prefix string, valueGenerator func(int
b.Run(testName(prefix, "Franz@Produce"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.Produce(topicName, generateKey(prefix, i), valueGenerator(i))
producer.ProduceSync(topicName, generateKey(prefix, i), valueGenerator(i))
}

b.StopTimer()
Expand All @@ -56,7 +56,7 @@ func benchmarkFranzProducer(b *testing.B, prefix string, valueGenerator func(int
b.Run(testName(prefix, "Franz@ProduceChannel"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.ProduceChannel(topicName, generateKey(prefix, i), valueGenerator(i))
producer.ProduceAsync(topicName, generateKey(prefix, i), valueGenerator(i))
}

producer.Wait()
Expand All @@ -70,7 +70,7 @@ func benchmarkGokaProducer(b *testing.B, prefix string, valueGenerator func(int)
b.Run(testName(prefix, "Goka@Produce"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.Produce(generateKey(prefix, i), valueGenerator(i))
producer.ProduceSync(generateKey(prefix, i), valueGenerator(i))
}

b.StopTimer()
Expand All @@ -79,7 +79,7 @@ func benchmarkGokaProducer(b *testing.B, prefix string, valueGenerator func(int)
b.Run(testName(prefix, "Goka@ProduceChannel"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.ProduceChannel(generateKey(prefix, i), valueGenerator(i))
producer.ProduceAsync(generateKey(prefix, i), valueGenerator(i))
}

producer.Wait()
Expand All @@ -93,15 +93,15 @@ func benchmarkSaramaProducer(b *testing.B, prefix string, valueGenerator func(in
b.Run(testName(prefix, "Sarama@Produce"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.Produce(topicName, generateKey(prefix, i), valueGenerator(i))
producer.ProduceSync(topicName, generateKey(prefix, i), valueGenerator(i))
}
b.StopTimer()
})

b.Run(testName(prefix, "Sarama@ProduceChannel"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.ProduceChannel(topicName, generateKey(prefix, i), valueGenerator(i))
producer.ProduceAsync(topicName, generateKey(prefix, i), valueGenerator(i))
}
producer.Wait()
b.StopTimer()
Expand All @@ -114,7 +114,7 @@ func benchmarkSegmentioProducer(b *testing.B, prefix string, valueGenerator func
b.Run(testName(prefix, "Segmentio@Produce"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.Produce(generateKey(prefix, i), valueGenerator(i))
producer.ProduceSync(generateKey(prefix, i), valueGenerator(i))
}

b.StopTimer()
Expand All @@ -123,7 +123,7 @@ func benchmarkSegmentioProducer(b *testing.B, prefix string, valueGenerator func
b.Run(testName(prefix, "Segmentio@ProduceChannel"), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
producer.ProduceChannel(generateKey(prefix, i), valueGenerator(i))
producer.ProduceAsync(generateKey(prefix, i), valueGenerator(i))
}

producer.Wait()
Expand Down
Binary file added kafka-client/results/AsyncProducerBytes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kafka-client/results/AsyncProducerTime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kafka-client/results/SyncProducerBytes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kafka-client/results/SyncProducerTime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9ca1ad9

Please sign in to comment.