-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add multiple beat.Clients #37657
Add multiple beat.Clients #37657
Changes from 1 commit
e23799d
477173c
407a984
e5c4e55
13f4901
17fe15b
34d4bd7
44bded7
5880235
ee3f7af
36b90f0
e7cf429
82345b4
9ece5ef
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 |
---|---|---|
|
@@ -72,7 +72,13 @@ func defaultConfig() config { | |
c.ForwarderConfig = harvester.ForwarderConfig{ | ||
Type: "gcp-pubsub", | ||
} | ||
// Since we now support multiple beat.Clients, having multiple NumGoroutines | ||
// greatly improves ingestion performance. Hence, default values are being | ||
// adjusted to get the most of the input. | ||
// It is not increased too high to cause high CPU usage. | ||
c.Subscription.NumGoroutines = 2 | ||
// The input gets blocked until flush.min_events or flush.timeout is reached. | ||
// Hence max_outstanding_message has to be atleast flush.min_events to avoid this blockage. | ||
c.Subscription.MaxOutstandingMessages = 1600 | ||
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. It's unfortunate that there is not a globally visible variable/constant that could be used for this that would ensure that this is both explained in code an robust to source mutation. Is there a way for the input to know 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. Since the queue config is defined inside publisher, I don't see any quick way to get this check without a considerable refactor of Input. 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. Indeed. It was a wistful desire rather than an expectation of change. |
||
c.Subscription.Create = true | ||
return c | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,7 +217,6 @@ func (in *pubsubInput) run() error { | |
var workerWg sync.WaitGroup | ||
|
||
for ctx.Err() == nil { | ||
|
||
workers, err := in.workerSem.AcquireContext(numGoRoutines, ctx) | ||
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'm not sure we should proceed the approach of adding multiple pub/sub readers (pending resolution to previous comments), but if we do, then: I think this can be simplified to not use a semaphore. A plain for loop (e.g. |
||
if err != nil { | ||
break | ||
|
@@ -231,13 +230,12 @@ func (in *pubsubInput) run() error { | |
go func() { | ||
client, err := in.newPubsubClient(ctx) | ||
defer func() { | ||
workerWg.Done() | ||
in.workerSem.Release(1) | ||
workerWg.Done() | ||
}() | ||
if err != nil { | ||
in.log.Error("failed to create pub/sub client: ", err) | ||
in.log.Errorw("failed to create pub/sub client: ", "error", err) | ||
cancel() | ||
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. It looks like this should be calling |
||
// return err | ||
} else { | ||
defer client.Close() | ||
} | ||
|
@@ -247,7 +245,6 @@ func (in *pubsubInput) run() error { | |
if err != nil { | ||
in.log.Error("failed to subscribe to pub/sub topic: ", err) | ||
cancel() | ||
// return fmt.Errorf("failed to subscribe to pub/sub topic: %w", err) | ||
} | ||
sub.ReceiveSettings.NumGoroutines = in.Subscription.NumGoroutines | ||
sub.ReceiveSettings.MaxOutstandingMessages = in.Subscription.MaxOutstandingMessages | ||
|
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.
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.
updated as suggested