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

Adding variable and corresponding code for diverting percentage of requests which coming to a slave towards the master #530

Closed
wants to merge 3 commits into from

Conversation

vreitech
Copy link

The pull request adding variable and corresponding code for diverting specified percentage of requests which coming into HAProxy to a slave port towards the master.

Necessity of the feature is questionable and discussionable. AFAIK there's no any direct profit to use routing of a part of reading queries to master instead of a slave.

Changes

  • added haproxy_divert_to_master var into vars/main.yml

  • setting haproxy_divert_to_master to 0 to avoid changes in ansible deployment result with default configuration (which disabling any diverting of connections to master instead of slave)

  • added corresponding code into haproxy.cfg.j2 template

  • added corresponding code into haproxy.tmpl.j2 template

…quests which coming to a slave towards the master (#1)

* added `haproxy_divert_to_master` var and corresponding code into `haproxy.cfg.j2` template

* added `haproxy_divert_to_master` var and corresponding code into `haproxy.tmpl.j2` template

* added comment in `vars/main.yml`

* setting `haproxy_divert_to_master` to 0 to avoid changes in ansible deployment result with default configuration the variable setted to value 0 (which disabling any diverting of connections to master instead of slave)
…quests which coming to a slave towards the master (#2)

* rearrange haproxy configuration blocks
@vitabaks
Copy link
Owner

Necessity of the feature is questionable and discussionable. AFAIK there's no any direct profit to use routing of a part of reading queries to master instead of a slave.

@vreitech Thank you for submitting this PR. The idea of diverting a certain percentage of read queries from HAProxy to the master node is interesting, but its practical utility seems questionable. Generally, the purpose of directing traffic to a slave is to distribute the load and avoid overburdening the master with read queries, especially in high-traffic environments.

Your implementation suggests that a portion of read queries can be intentionally rerouted to the master. This might defy the typical use case of a read replica, which is to offload read operations from the master. Could you please elaborate on specific scenarios or use cases where this would be beneficial?

Additionally, if there's a need to direct more traffic to the master, wouldn't adjusting the existing load balancing setup or adding a new endpoint like '/read-only' to point to the master be a more straightforward solution? This approach could offer more transparency and control over traffic routing without the need for a new variable or complex configuration changes.

GET /read-only: like the above endpoint, but also includes the primary.
GET /read-only-sync: like the above endpoint, but also includes the primary.

https://patroni.readthedocs.io/en/latest/rest_api.html#health-check-endpoints

@vitabaks vitabaks closed this Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants