Skip to content

Instantly share code, notes, and snippets.

@mkocsar
mkocsar / test-prefetch-impact.js
Created August 22, 2023 14:12
KafkaJS topic metadata prefetch performance impact measurement
import { Kafka } from 'kafkajs';
import { hrtime } from 'node:process';
// This script measures the performance impact of prefetching topic metadata before sending events.
// More specifically, the script measures how long each `send` call takes while it iterates through thousands of topics and sends an event to each.
// If PREFETCH is set to true, the script prefetches the metadata for each topic the cluster hosts before sending the events.
// The measurement results are output in CSV format and can be easily visualized with e.g. rawgraphs.io
// ---
@mkocsar
mkocsar / test-send-duration.js
Last active August 18, 2023 11:02
KafkaJS send duration measurement with thousands of topics
import { hrtime } from 'node:process';
import { Kafka } from 'kafkajs';
// ---
const CLUSTER_URL = 'localhost:9092';
const TOPIC_COUNT = 3500;
const TPS = 25;
const REPORT_WINDOW_S = 1;
const TEST_DURATION_S = 60;