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

add backend-shards command-line option #623

Merged
merged 1 commit into from
Jul 22, 2020
Merged

Conversation

jcmoraisjr
Copy link
Owner

Big clusters waste some time and cpu executing the haproxy template every time a configuration changes, even if such configuration is dinamically applied, leaving memory and disk configurations in sync. Most of the time is spent rebuilding all the referenced services, which is converted to haproxy backends.

Splitting the backends into smaller shards give haproxy ingress the ability to only update files that have changes to be applied, reducing io and cpu usage. The shard of a backend is chosen from the hash of its ID, so the same backend will always stay in the same shard provided that the number of shards isn't changed. Updating the number of shards will rebalance the backends.

Big clusters waste some time and cpu executing the haproxy template every time a configuration changes, even if such configuration is dinamically applied, leaving memory and disk configurations in sync. Most of the time is spent rebuilding all the referenced services, which is converted to haproxy backends.

Splitting the backends into smaller shards give haproxy ingress the ability to only update files that have changes to be applied, reducing io and cpu usage. The shard of a backend is chosen from the hash of its ID, so the same backend will always stay in the same shard provided that the number of shards isn't changed. Updating the number of shards will rebalance the backends.
@jcmoraisjr jcmoraisjr merged commit 552e8fe into master Jul 22, 2020
@jcmoraisjr jcmoraisjr deleted the jm-backend-shards branch July 22, 2020 00:52
@tsjnsn
Copy link

tsjnsn commented Apr 16, 2021

@jcmoraisjr any guidelines on picking the number of shards to use?

@jcmoraisjr
Copy link
Owner Author

The rule of thumb is: if the number of k8s-services/haproxy-backends is <500 you're fine and don't need to worry, otherwise use the result of <num-svc> / 100-150 which will create shards enough to leave no more than about 150-200 backends per configuration file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants