Best practices for Stream service configuration
Follow these guidelines for the recommended configuration of the Stream service in your system. These best practices apply only to on-premises deployments.
Data throughput depends on the number of nodes, CPUs, and partitions, as well as the replication factor and bandwidth
Review the results of tests on three running stream service nodes on machines with the following configuration:
- CPU cores: 2
- Memory (GB): 8
- Bandwidth (Mbps): 450
- Number of partitions: 20
- Replication factor: 2
The following table shows the test results for writing messages to the stream (producer):
Producer throughput – test results
|Records||Record size (bytes)||Threads||Throughput (rec/sec)||Average latency (ms)||MB/sec|
The following table presents the test results for reading messages from the stream (consumer):
For the consumer, the replication factor is not important because the consumer reads from the leading partition.
Consumer throughput – test results
|Records||Record size (bytes)||Threads||Throughput (rec/sec)||MB/sec|
Disk space requirements
By default, the Kafka cluster stores data for 60 hours (2.5 days). You can change the
retention period for specific stream categories by modifying the
property in the
prconfig.xml file, where
categoryName can have one of the following values:
For example, you can set the retention period for streams in the QueueProcessor
category by using the following property:
Your goal is to process 100,000 messages per second, 500 bytes each, and to keep messages on the disk for one day. The replication factor is set to 2.
The expected throughput is 50 MB/sec:
- 3 GB is used in one minute for a single copy of the data.
- 6 GB of disk space is used in one minute due to the replication factor of 2.
- The total throughput is 360 GB in one hour and 8.64 TB in one day.
- Apart from your data, the Kafka cluster uses additional disk space for internal data (around 10% of the data size).
In that sample scenario, the total minimal disk size should be 9.5 TB.
Depending on your needs, you can choose data compression using one of the algorithms that Kafka supports: gzip, Snappy, or LZ4. Consider the following aspects:
- Gzip requires less bandwidth and disk space, but this algorithm might not saturate your network while the maximum throughput is reached.
- Snappy is much faster than gzip, but the compression ratio is low, which means that throughput might be limited when the maximum network capacity is reached.
- LZ4 maximizes the performance.
Review the following table and diagram with throughput and bandwidth usage per codec:
Throughput and bandwidth per codec (%)
|Codec||Throughput %||Bandwidth %|