Skip to content

Commit 8c50972

Browse files
abhishekshaw21copybara-github
authored andcommitted
Add Apache Kafka benchmark skeleton
PiperOrigin-RevId: 930568061
1 parent 484fd27 commit 8c50972

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

CHANGES.next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@
284284
- Re-enable support for Rocky Linux 8, 9, and 10 for the Azure provider.
285285
- Add Ubuntu 26.04 support for GCP, AWS, and Azure Providers.
286286
- Add a kubernetes-native benchmark for MySQL using sysbench
287+
- Add `kafka_benchmark` support.
287288

288289
### Enhancements:
289290

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright 2026 PerfKitBenchmarker Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Runs Apache Kafka benchmarks."""
15+
16+
import concurrent.futures
17+
from typing import Any, Mapping
18+
19+
from perfkitbenchmarker import benchmark_spec as bm_spec
20+
from perfkitbenchmarker import configs
21+
from perfkitbenchmarker import sample
22+
23+
BENCHMARK_NAME = 'kafka'
24+
BENCHMARK_CONFIG = """
25+
kafka:
26+
description: Runs Apache Kafka benchmarks
27+
vm_groups:
28+
broker:
29+
vm_spec: *default_dual_core
30+
producer:
31+
vm_spec: *default_dual_core
32+
consumer:
33+
vm_spec: *default_dual_core
34+
"""
35+
36+
BENCHMARK_DATA = {}
37+
KAFKA_VERSION = '2.13-4.2.0'
38+
KAFKA_TAR = f'kafka_{KAFKA_VERSION}.tgz'
39+
KAFKA_URL = f'https://downloads.apache.org/kafka/4.2.0/{KAFKA_TAR}'
40+
41+
42+
def _InstallKafka(vm):
43+
"""Installs Kafka on a VM."""
44+
vm.InstallPackages('openjdk-17-jdk')
45+
vm.Install('build_tools')
46+
vm.Install('pip')
47+
vm.RemoteCommand(f'wget {KAFKA_URL}')
48+
vm.RemoteCommand(f'tar -xzf {KAFKA_TAR}')
49+
50+
51+
def GetConfig(user_config: Mapping[Any, Any]) -> Mapping[Any, Any]:
52+
"""Merge BENCHMARK_CONFIG with user_config to create benchmark_spec.
53+
54+
Args:
55+
user_config: user-defined configs (through FLAGS.benchmark_config_file or
56+
FLAGS.config_override).
57+
58+
Returns:
59+
The resulting configs that come from merging user-defined configs with
60+
BENCHMARK_CONFIG.
61+
"""
62+
return configs.LoadConfig(BENCHMARK_CONFIG, user_config, BENCHMARK_NAME)
63+
64+
65+
def Prepare(benchmark_spec: bm_spec.BenchmarkSpec) -> None:
66+
"""Prepares VM to run Kafka.
67+
68+
Args:
69+
benchmark_spec: The benchmark specification.
70+
"""
71+
vms = benchmark_spec.vms
72+
with concurrent.futures.ThreadPoolExecutor(max_workers=len(vms)) as executor:
73+
executor.map(_InstallKafka, vms)
74+
75+
76+
def Run(benchmark_spec: bm_spec.BenchmarkSpec) -> list[sample.Sample]:
77+
"""Runs Kafka benchmarks."""
78+
return []
79+
80+
81+
def Cleanup(benchmark_spec: bm_spec.BenchmarkSpec) -> None:
82+
"""Cleans up the benchmark."""
83+
pass

0 commit comments

Comments
 (0)