-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in_kafka: boost throughput #9625
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,7 +161,7 @@ static int in_kafka_collect(struct flb_input_instance *ins, | |
ret = FLB_EVENT_ENCODER_SUCCESS; | ||
|
||
while (ret == FLB_EVENT_ENCODER_SUCCESS) { | ||
rkm = rd_kafka_consumer_poll(ctx->kafka.rk, 1); | ||
rkm = rd_kafka_consumer_poll(ctx->kafka.rk, ctx->poll_timeount_ms); | ||
|
||
if (!rkm) { | ||
break; | ||
|
@@ -180,8 +180,11 @@ static int in_kafka_collect(struct flb_input_instance *ins, | |
|
||
rd_kafka_message_destroy(rkm); | ||
|
||
/* TO-DO: commit the record based on `ret` */ | ||
rd_kafka_commit(ctx->kafka.rk, NULL, 0); | ||
|
||
if(!ctx->enable_auto_commit) { | ||
/* TO-DO: commit the record based on `ret` */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to sort all TODOs, we can't just leave them in there. I know it was in the original but we should attempt to sort or add more info. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well i din't introduce the TO-DO. It existed before. It just went into the if statement. Unfortunately github shows to little context so you can't see it. |
||
rd_kafka_commit(ctx->kafka.rk, NULL, 0); | ||
} | ||
|
||
/* Break from the loop when reaching the limit of polling if available */ | ||
if (ctx->polling_threshold != FLB_IN_KAFKA_UNLIMITED && | ||
|
@@ -243,6 +246,21 @@ static int in_kafka_init(struct flb_input_instance *ins, | |
goto init_error; | ||
} | ||
|
||
/* Set the kafka poll timeout dependend on wether we run in our own | ||
* or in the main event thread. | ||
* a) run in main event thread: | ||
* -> minimize the delay we might create | ||
* b) run in our own thread: | ||
* -> optimize for throuput and relay on 'fetch.wait.max.ms' | ||
* which is set to 500 by default default. lets set it to | ||
* twice that so that increasing fetch.wait.max.ms still | ||
* has an effect. | ||
*/ | ||
ctx->poll_timeount_ms = 1; | ||
if(ins->is_threaded) { | ||
ctx->poll_timeount_ms = 1000; | ||
} | ||
coreidcc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (ctx->buffer_max_size > 0) { | ||
ctx->polling_threshold = ctx->buffer_max_size; | ||
|
||
|
@@ -428,6 +446,11 @@ static struct flb_config_map config_map[] = { | |
0, FLB_TRUE, offsetof(struct flb_in_kafka_config, buffer_max_size), | ||
"Set the maximum size of chunk" | ||
}, | ||
{ | ||
FLB_CONFIG_MAP_BOOL, "enable_auto_commit", FLB_IN_KAFKA_ENABLE_AUTO_COMMIT, | ||
0, FLB_TRUE, offsetof(struct flb_in_kafka_config, enable_auto_commit), | ||
coreidcc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"Rely on kafka auto-commit and commit messages in batches" | ||
}, | ||
/* EOF */ | ||
{0} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current behaviour is to have auto-commit false but the default below is now true which means we are not maintaining the old behaviour by default.