Skip to content
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

upstream: fix logic to restrict number of connections #7680

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

edsiper
Copy link
Member

@edsiper edsiper commented Jul 11, 2023

In the previous version a new option called net.max_worker_connections was introduced to provide control around the maximum number of allowed TCP connections per worker inside an output plugin, the logic was wrong.

In the upstream logic, connections are linked to one of these lists:

  • av_queue : connections ready to be used (available)
  • busy_queue: connections that are busy (someone is using them)
  • drop_queue: connections in the cleanup phase (to be drop)

Fluent Bit don't create connections ahead of time, just on demand. When a connection is created is placed into the busy_queue, when is not longer needed one of these things happen:

  • if keepalive is enabled (default), the connection is moved to the 'av_queue'.
  • if keepalive is disabled, the connection is moved to 'drop_queue' then is closed and destroyed.

Based on the logic described above, to limit the number of total connections in the worker, we only need to count the number of connections linked into the 'busy_queue' list because if there are connections available 'av_queue' it won't create a one.

This patch fixes the logic by only using the busy_queue to count the limit.


Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

In the previous version a new option called net.max_worker_connections was introduced
to provide control around the maximum number of allowed TCP connections per worker inside
an output plugin, the logic was wrong.

In the upstream logic, connections are linked to one of these lists:

  - av_queue  : connections ready to be used (available)
  - busy_queue: connections that are busy (someone is using them)
  - drop_queue: connections in the cleanup phase (to be drop)

Fluent Bit don't create connections ahead of time, just on demand. When
a connection is created is placed into the busy_queue, when is not longer
needed one of these things happen:

  - if keepalive is enabled (default), the connection is moved to the 'av_queue'.
  - if keepalive is disabled, the connection is moved to 'drop_queue' then is
    closed and destroyed.

Based on the logic described above, to limit the number of total connections
in the worker, we only need to count the number of connections linked into
the 'busy_queue' list because if there are connections available 'av_queue' it
won't create a one.

This patch fixes the logic by only using the busy_queue to count the limit.

Signed-off-by: Eduardo Silva <[email protected]>
@edsiper edsiper temporarily deployed to pr July 11, 2023 02:30 — with GitHub Actions Inactive
@edsiper edsiper temporarily deployed to pr July 11, 2023 02:30 — with GitHub Actions Inactive
@edsiper edsiper temporarily deployed to pr July 11, 2023 02:30 — with GitHub Actions Inactive
@edsiper edsiper temporarily deployed to pr July 11, 2023 02:55 — with GitHub Actions Inactive
@edsiper edsiper merged commit 10274c9 into master Jul 11, 2023
@edsiper edsiper deleted the max_worker_connections branch July 11, 2023 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant