This topic describes the rules for configuring client parameters of Message Queue for Apache Kafka. We recommend that you specify proper values for these parameters based on your business requirements.
The following tables describe parameters for different clients:
Parameter | Description |
---|---|
retries | The number of retries that is allowed for a message that fails to be sent. |
retry.backoff.ms | The interval between retries when a message fails to be sent. We recommend that you set this parameter to 1000. Unit: milliseconds. |
acks | The persistence mechanism for sending messages. To improve message sending performance, we recommend that you set this parameter to 1 .
|
batch.size | The volume of cached messages to be delivered to each partition. When the volume of cached messages reaches the specified upper limit, a network request is triggered. Then, the producer sends the messages to the broker in a batch. If you set the batch.size parameter to a small value, the message sending performance and stability may be affected. We recommend that you use the default value 16384. Unit: bytes. |
linger.ms | The maximum storage duration for each message in the cache. If a message is stored in the cache for a period of time that exceeds the maximum storage duration, the producer immediately sends the message to the broker without using the batch.size parameter. We recommend that you set the linger.ms parameter to a value that ranges from 100 to 1000 based on your business requirements. Unit: milliseconds. |
partitioner.class | The strategy that you use for partitioning. We recommend that you use the sticky partitioning strategy to improve message sending performance. If the version of your producer client is 2.4 or later, the sticky partitioning strategy is used by default. |
buffer.memory | The size of memory pool on the client. If you set this parameter to a small value, the time that is consumed to apply for memory may be long. This causes low message sending performance or message sending timeout. We recommend that you set this parameter to a value that is equal to or greater than the value of Value of the batch.size parameter × Number of partitions × 2 . Unit: bytes. |
Parameter | Description |
---|---|
fetch.min.bytes | The minimum amount of data that the consumer can pull from the broker. Before you configure this parameter, you must evaluate the number of messages to be sent by the producer. If you set this parameter to an excessively large value, message delay may be increased when the consumer consumes messages. If you set this parameter to an excessively small value, the frequency at which the consumer pulls messages may be increased. Unit: bytes. |
fetch.max.wait.ms | The maximum amount of time that the broker waits to return a response. Unit: milliseconds.
|
max.partion.fetch.bytes | The maximum amount of data that each partition returns. Unit: bytes. |
session.timeout.ms | The interval at which the consumer sends heartbeats. If no heartbeat is sent within the interval, the broker determines that the consumer is dead, and a rebalance is triggered. During the rebalance, the client stops consuming data and waits for the rebalance to complete. We recommend that you set this parameter to a value that ranges from 30000 to 60000. Unit: milliseconds. Valid values: 6000 to 300000. |
max.poll.records | The maximum number of messages returned in a single call to poll(). If you set this parameter to an excessively large value, you must process the message consumption logic at the earliest opportunity. If the message consumption logic is processed at a low speed, data in the next call to poll() is affected. As a result, no heartbeat is sent during the interval that is specified by the session.timeout.ms parameter, and a rebalance is triggered. We recommend that you set this parameter to a value that is smaller than the value of Important In Java Client 0.10.1 and later versions, a separate thread is used to send heartbeats. If you use a Java Client of earlier versions or a client in another language, you must specify proper values for parameters that are related to data processing time and heartbeat sending interval. This helps prevent frequent rebalances from affecting normal consumption. |
max.poll.interval.ms | The maximum interval between invocations of poll(). This parameter is required only in Java client 0.10.1 and later versions. If the consumer does not call poll() during the interval that is specified by the session.timeout.ms parameter, the broker determines that the consumer is dead, and a rebalance is triggered. Therefore, you must set this parameter to a proper value. We recommend that you set this parameter to a value that is greater than the value of <Time consumed to consume a message> × <Number of data records pulled by poll()> . In most cases, you can use the default value. Unit: milliseconds. Default value: 300000. |
enable.auto.commit | Specifies whether to automatically commit the consumer offset. Valid values:
Default value: true. |
auto.commit.interval.ms | The interval at which the consumer offsets are automatically committed. Default value: 1000. Unit: milliseconds. |
auto.offset.reset | The policy that is used to reset the consumer offset.
Note
|