Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix shard render when the last backend is removed #1015

Merged
merged 1 commit into from
Jul 5, 2023
Merged

Conversation

jcmoraisjr
Copy link
Owner

Backend template rendering is the most CPU consumption of the reconciliation process, so sharding backends reduces haproxy ingress processing on workloads with thousands of services. Once sharding, haproxy ingress can update only the shards whose backends were changed since the last update.

When a full reconciliation happens, usually triggered by changing a global config, all the resources need to be parsed again, and this happen by clearing the state and building it again from scratch. This building process clears old states, removing from the controller the ability to find shards that had backends and doesn't have anymore. Since the file continues on the disk, the backend is registered on HAProxy, although it's not referenced anymore.

This is likely not to happen with ingress resources because the removal of a service triggers a partial parsing, which preserves the old state and old shards are always found, despite of being empty or not. However, if a global is changed exactly at the same time of a service removal, the backend of that service should leak if it's the last one of a backend shard. When using gateway API this is more likely to happen because currently gateway API uses full reconciliation.

Backend template rendering is the most CPU consumption of the
reconciliation process, so sharding backends reduces haproxy ingress
processing on workloads with thousands of services. Once sharding,
haproxy ingress can update only the shards whose backends were changed
since the last update.

When a full reconciliation happens, usually triggered by changing a
global config, all the resources need to be parsed again, and this
happen by clearing the state and building it again from scratch. This
building process clears old states, removing from the controller the
ability to find shards that had backends and doesn't have anymore.
Since the file continues on the disk, the backend is registered on
HAProxy, although it's not referenced anymore.

This is likely not to happen with ingress resources because the removal
of a service triggers a partial parsing, which preserves the old state
and old shards are always found, despite of being empty or not. However,
if a global is changed exactly at the same time of a service removal,
the backend of that service should leak if it's the last one of a
backend shard. When using gateway API this is more likely to happen
because currently gateway API uses full reconciliation.
@jcmoraisjr jcmoraisjr merged commit 7c4ad9c into master Jul 5, 2023
@jcmoraisjr jcmoraisjr deleted the jm-clear-shard branch July 5, 2023 23:45
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant