diff options
author | Dana Powers <dana.powers@gmail.com> | 2017-06-19 10:16:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-19 10:16:02 -0700 |
commit | b1cc966439a65f8be1b3973b16753dfba2b51c37 (patch) | |
tree | fb25aec1147ef9dfc6758c72fcc87130e557b53d /kafka/producer/kafka.py | |
parent | cceaf4ae0982a78bdaef39ce1c9635e260bff709 (diff) | |
download | kafka-python-b1cc966439a65f8be1b3973b16753dfba2b51c37.tar.gz |
KIP-144: Exponential backoff for broker reconnections (#1124)
Diffstat (limited to 'kafka/producer/kafka.py')
-rw-r--r-- | kafka/producer/kafka.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 51c2182..1f78c89 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -199,6 +199,14 @@ class KafkaProducer(object): reconnect_backoff_ms (int): The amount of time in milliseconds to wait before attempting to reconnect to a given host. Default: 50. + reconnect_backoff_max_ms (int): The maximum amount of time in + milliseconds to wait when reconnecting to a broker that has + repeatedly failed to connect. If provided, the backoff per host + will increase exponentially for each consecutive connection + failure, up to this maximum. To avoid connection storms, a + randomization factor of 0.2 will be applied to the backoff + resulting in a random range between 20% below and 20% above + the computed value. Default: 1000. max_in_flight_requests_per_connection (int): Requests are pipelined to kafka brokers up to this number of maximum requests per broker connection. Default: 5. @@ -276,6 +284,7 @@ class KafkaProducer(object): 'send_buffer_bytes': None, 'socket_options': [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)], 'reconnect_backoff_ms': 50, + 'reconnect_backoff_max': 1000, 'max_in_flight_requests_per_connection': 5, 'security_protocol': 'PLAINTEXT', 'ssl_context': None, |