Skip to content

Commit 48493f6

Browse files
authored
Merge pull request #3134 from redpanda-data/consumer_group
kafka franz: support consumer group timeout configs
2 parents 2752d1b + 16233f2 commit 48493f6

File tree

6 files changed

+180
-0
lines changed

6 files changed

+180
-0
lines changed

docs/modules/components/pages/inputs/kafka_franz.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ input:
7171
regexp_topics: false
7272
rack_id: ""
7373
instance_id: ""
74+
rebalance_timeout: 45s
75+
session_timeout: 1m
76+
heartbeat_interval: 3s
7477
start_from_oldest: true
7578
fetch_max_bytes: 50MiB
7679
fetch_max_wait: 5s
@@ -564,6 +567,33 @@ When using a consumer group, an instance ID specifies the groups static membersh
564567
565568
*Default*: `""`
566569
570+
=== `rebalance_timeout`
571+
572+
When using a consumer group, `rebalance_timeout` sets how long group members are allowed to take when a rebalance has begun. This timeout is how long all members are allowed to complete work and commit offsets, minus the time it took to detect the rebalance (from a heartbeat).
573+
574+
575+
*Type*: `string`
576+
577+
*Default*: `"45s"`
578+
579+
=== `session_timeout`
580+
581+
When using a consumer group, `session_timeout` sets how long a member in hte group can go between heartbeats. If a member does not heartbeat in this timeout, the broker will remove the member from the group and initiate a rebalance.
582+
583+
584+
*Type*: `string`
585+
586+
*Default*: `"1m"`
587+
588+
=== `heartbeat_interval`
589+
590+
When using a consumer group, `heartbeat_interval` sets how long a group member goes between heartbeats to Kafka. Kafka uses heartbeats to ensure that a group member's sesion stays active. This value should be no higher than 1/3rd of the `session_timeout`. This is equivalent to the Java heartbeat.interval.ms setting.
591+
592+
593+
*Type*: `string`
594+
595+
*Default*: `"3s"`
596+
567597
=== `start_from_oldest`
568598
569599
Determines whether to consume from the oldest available offset, otherwise messages are consumed from the latest offset. The setting is applied when creating a new consumer group or the saved offset no longer exists.

docs/modules/components/pages/inputs/ockam_kafka.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ input:
7676
regexp_topics: false
7777
rack_id: ""
7878
instance_id: ""
79+
rebalance_timeout: 45s
80+
session_timeout: 1m
81+
heartbeat_interval: 3s
7982
start_from_oldest: true
8083
fetch_max_bytes: 50MiB
8184
fetch_max_wait: 5s
@@ -361,6 +364,33 @@ When using a consumer group, an instance ID specifies the groups static membersh
361364
362365
*Default*: `""`
363366
367+
=== `kafka.rebalance_timeout`
368+
369+
When using a consumer group, `rebalance_timeout` sets how long group members are allowed to take when a rebalance has begun. This timeout is how long all members are allowed to complete work and commit offsets, minus the time it took to detect the rebalance (from a heartbeat).
370+
371+
372+
*Type*: `string`
373+
374+
*Default*: `"45s"`
375+
376+
=== `kafka.session_timeout`
377+
378+
When using a consumer group, `session_timeout` sets how long a member in hte group can go between heartbeats. If a member does not heartbeat in this timeout, the broker will remove the member from the group and initiate a rebalance.
379+
380+
381+
*Type*: `string`
382+
383+
*Default*: `"1m"`
384+
385+
=== `kafka.heartbeat_interval`
386+
387+
When using a consumer group, `heartbeat_interval` sets how long a group member goes between heartbeats to Kafka. Kafka uses heartbeats to ensure that a group member's sesion stays active. This value should be no higher than 1/3rd of the `session_timeout`. This is equivalent to the Java heartbeat.interval.ms setting.
388+
389+
390+
*Type*: `string`
391+
392+
*Default*: `"3s"`
393+
364394
=== `kafka.start_from_oldest`
365395
366396
Determines whether to consume from the oldest available offset, otherwise messages are consumed from the latest offset. The setting is applied when creating a new consumer group or the saved offset no longer exists.

docs/modules/components/pages/inputs/redpanda.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ input:
6969
regexp_topics: false
7070
rack_id: ""
7171
instance_id: ""
72+
rebalance_timeout: 45s
73+
session_timeout: 1m
74+
heartbeat_interval: 3s
7275
start_from_oldest: true
7376
fetch_max_bytes: 50MiB
7477
fetch_max_wait: 5s
@@ -590,6 +593,33 @@ When using a consumer group, an instance ID specifies the groups static membersh
590593
591594
*Default*: `""`
592595
596+
=== `rebalance_timeout`
597+
598+
When using a consumer group, `rebalance_timeout` sets how long group members are allowed to take when a rebalance has begun. This timeout is how long all members are allowed to complete work and commit offsets, minus the time it took to detect the rebalance (from a heartbeat).
599+
600+
601+
*Type*: `string`
602+
603+
*Default*: `"45s"`
604+
605+
=== `session_timeout`
606+
607+
When using a consumer group, `session_timeout` sets how long a member in hte group can go between heartbeats. If a member does not heartbeat in this timeout, the broker will remove the member from the group and initiate a rebalance.
608+
609+
610+
*Type*: `string`
611+
612+
*Default*: `"1m"`
613+
614+
=== `heartbeat_interval`
615+
616+
When using a consumer group, `heartbeat_interval` sets how long a group member goes between heartbeats to Kafka. Kafka uses heartbeats to ensure that a group member's sesion stays active. This value should be no higher than 1/3rd of the `session_timeout`. This is equivalent to the Java heartbeat.interval.ms setting.
617+
618+
619+
*Type*: `string`
620+
621+
*Default*: `"3s"`
622+
593623
=== `start_from_oldest`
594624
595625
Determines whether to consume from the oldest available offset, otherwise messages are consumed from the latest offset. The setting is applied when creating a new consumer group or the saved offset no longer exists.

docs/modules/components/pages/inputs/redpanda_common.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ input:
5757
regexp_topics: false
5858
rack_id: ""
5959
instance_id: ""
60+
rebalance_timeout: 45s
61+
session_timeout: 1m
62+
heartbeat_interval: 3s
6063
start_from_oldest: true
6164
fetch_max_bytes: 50MiB
6265
fetch_max_wait: 5s
@@ -190,6 +193,33 @@ When using a consumer group, an instance ID specifies the groups static membersh
190193
191194
*Default*: `""`
192195
196+
=== `rebalance_timeout`
197+
198+
When using a consumer group, `rebalance_timeout` sets how long group members are allowed to take when a rebalance has begun. This timeout is how long all members are allowed to complete work and commit offsets, minus the time it took to detect the rebalance (from a heartbeat).
199+
200+
201+
*Type*: `string`
202+
203+
*Default*: `"45s"`
204+
205+
=== `session_timeout`
206+
207+
When using a consumer group, `session_timeout` sets how long a member in hte group can go between heartbeats. If a member does not heartbeat in this timeout, the broker will remove the member from the group and initiate a rebalance.
208+
209+
210+
*Type*: `string`
211+
212+
*Default*: `"1m"`
213+
214+
=== `heartbeat_interval`
215+
216+
When using a consumer group, `heartbeat_interval` sets how long a group member goes between heartbeats to Kafka. Kafka uses heartbeats to ensure that a group member's sesion stays active. This value should be no higher than 1/3rd of the `session_timeout`. This is equivalent to the Java heartbeat.interval.ms setting.
217+
218+
219+
*Type*: `string`
220+
221+
*Default*: `"3s"`
222+
193223
=== `start_from_oldest`
194224
195225
Determines whether to consume from the oldest available offset, otherwise messages are consumed from the latest offset. The setting is applied when creating a new consumer group or the saved offset no longer exists.

docs/modules/components/pages/inputs/redpanda_migrator.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ input:
7171
regexp_topics: false
7272
rack_id: ""
7373
instance_id: ""
74+
rebalance_timeout: 45s
75+
session_timeout: 1m
76+
heartbeat_interval: 3s
7477
start_from_oldest: true
7578
fetch_max_bytes: 50MiB
7679
fetch_max_wait: 5s
@@ -567,6 +570,33 @@ When using a consumer group, an instance ID specifies the groups static membersh
567570
568571
*Default*: `""`
569572
573+
=== `rebalance_timeout`
574+
575+
When using a consumer group, `rebalance_timeout` sets how long group members are allowed to take when a rebalance has begun. This timeout is how long all members are allowed to complete work and commit offsets, minus the time it took to detect the rebalance (from a heartbeat).
576+
577+
578+
*Type*: `string`
579+
580+
*Default*: `"45s"`
581+
582+
=== `session_timeout`
583+
584+
When using a consumer group, `session_timeout` sets how long a member in hte group can go between heartbeats. If a member does not heartbeat in this timeout, the broker will remove the member from the group and initiate a rebalance.
585+
586+
587+
*Type*: `string`
588+
589+
*Default*: `"1m"`
590+
591+
=== `heartbeat_interval`
592+
593+
When using a consumer group, `heartbeat_interval` sets how long a group member goes between heartbeats to Kafka. Kafka uses heartbeats to ensure that a group member's sesion stays active. This value should be no higher than 1/3rd of the `session_timeout`. This is equivalent to the Java heartbeat.interval.ms setting.
594+
595+
596+
*Type*: `string`
597+
598+
*Default*: `"3s"`
599+
570600
=== `start_from_oldest`
571601
572602
Determines whether to consume from the oldest available offset, otherwise messages are consumed from the latest offset. The setting is applied when creating a new consumer group or the saved offset no longer exists.

internal/impl/kafka/franz_reader.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const (
5757
kfrFieldFetchMinBytes = "fetch_min_bytes"
5858
kfrFieldFetchMaxPartitionBytes = "fetch_max_partition_bytes"
5959
kfrFieldFetchMaxWait = "fetch_max_wait"
60+
kfrFieldSessionTimeout = "session_timeout"
61+
kfrFieldRebalanceTimeout = "rebalance_timeout"
62+
kfrFieldHeartbeatInterval = "heartbeat_interval"
6063
)
6164

6265
// FranzConsumerFields returns a slice of fields specifically for customising
@@ -87,6 +90,18 @@ Finally, it's also possible to specify an explicit offset to consume from by add
8790
Description("When using a consumer group, an instance ID specifies the groups static membership, which can prevent rebalances during reconnects. When using a instance ID the client does NOT leave the group when closing. To actually leave the group one must use an external admin command to leave the group on behalf of this instance ID. This ID must be unique per consumer within the group.").
8891
Default("").
8992
Advanced(),
93+
service.NewDurationField(kfrFieldRebalanceTimeout).
94+
Description("When using a consumer group, `rebalance_timeout` sets how long group members are allowed to take when a rebalance has begun. This timeout is how long all members are allowed to complete work and commit offsets, minus the time it took to detect the rebalance (from a heartbeat).").
95+
Default("45s").
96+
Advanced(),
97+
service.NewDurationField(kfrFieldSessionTimeout).
98+
Description("When using a consumer group, `session_timeout` sets how long a member in hte group can go between heartbeats. If a member does not heartbeat in this timeout, the broker will remove the member from the group and initiate a rebalance.").
99+
Default("1m").
100+
Advanced(),
101+
service.NewDurationField(kfrFieldHeartbeatInterval).
102+
Description("When using a consumer group, `heartbeat_interval` sets how long a group member goes between heartbeats to Kafka. Kafka uses heartbeats to ensure that a group member's sesion stays active. This value should be no higher than 1/3rd of the `session_timeout`. This is equivalent to the Java heartbeat.interval.ms setting.").
103+
Default("3s").
104+
Advanced(),
90105
service.NewBoolField(kfrFieldStartFromOldest).
91106
Description("Determines whether to consume from the oldest available offset, otherwise messages are consumed from the latest offset. The setting is applied when creating a new consumer group or the saved offset no longer exists.").
92107
Default(true).
@@ -115,6 +130,9 @@ Finally, it's also possible to specify an explicit offset to consume from by add
115130
type FranzConsumerDetails struct {
116131
RackID string
117132
InstanceID string
133+
SessionTimeout time.Duration
134+
RebalanceTimeout time.Duration
135+
HeartbeatInterval time.Duration
118136
InitialOffset kgo.Offset
119137
Topics []string
120138
TopicPartitions map[string]map[int32]kgo.Offset
@@ -137,6 +155,15 @@ func FranzConsumerDetailsFromConfig(conf *service.ParsedConfig) (*FranzConsumerD
137155
if d.InstanceID, err = conf.FieldString(kfrFieldInstanceID); err != nil {
138156
return nil, err
139157
}
158+
if d.SessionTimeout, err = conf.FieldDuration(kfrFieldSessionTimeout); err != nil {
159+
return nil, err
160+
}
161+
if d.RebalanceTimeout, err = conf.FieldDuration(kfrFieldRebalanceTimeout); err != nil {
162+
return nil, err
163+
}
164+
if d.HeartbeatInterval, err = conf.FieldDuration(kfrFieldHeartbeatInterval); err != nil {
165+
return nil, err
166+
}
140167

141168
startFromOldest, err := conf.FieldBool(kfrFieldStartFromOldest)
142169
if err != nil {
@@ -207,6 +234,9 @@ func (d *FranzConsumerDetails) FranzOpts() []kgo.Opt {
207234
kgo.FetchMinBytes(d.FetchMinBytes),
208235
kgo.FetchMaxPartitionBytes(d.FetchMaxPartitionBytes),
209236
kgo.FetchMaxWait(d.FetchMaxWait),
237+
kgo.SessionTimeout(d.SessionTimeout),
238+
kgo.RebalanceTimeout(d.RebalanceTimeout),
239+
kgo.HeartbeatInterval(d.HeartbeatInterval),
210240
}
211241

212242
if d.RegexPattern {

0 commit comments

Comments
 (0)