<!-- Kamailio Pull Request Template -->
<!-- IMPORTANT: - for detailed contributing guidelines, read: https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md - pull requests must be done to master branch, unless they are backports of fixes from master branch to a stable branch - backports to stable branches must be done with 'git cherry-pick -x ...' - code is contributed under BSD for core and main components (tm, sl, auth, tls) - code is contributed GPLv2 or a compatible license for the other components - GPL code is contributed with OpenSSL licensing exception -->
#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [x] Commit message has the format required by CONTRIBUTING guide - [x] Commits are split per component (core, individual modules, libs, utils, ...) - [x] Each component has a single commit (if not, squash them into one commit) - [x] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [ ] Small bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [ ] PR should be backported to stable branches - [x] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description <!-- Describe your changes in detail -->
Presented at Kamailio World 2018, load balancing doing congestion detection More information can be found http://www.castmm.com/KW2018.pdf https://github.com/jchavanton/kam_load_balancing You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1533
-- Commit Summary --
* dispatcher: congestion detection load balancing
-- File Changes --
M src/modules/dispatcher/dispatch.c (103) M src/modules/dispatcher/dispatch.h (2) M src/modules/dispatcher/doc/dispatcher.xml (2) M src/modules/dispatcher/doc/dispatcher_admin.xml (9)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1533.patch https://github.com/kamailio/kamailio/pull/1533.diff
Small modifications in this PR, improved the precisions when all Gw are congested, compare to the version I was using before the presentation, the graph in my presentation was showing a lack of precision, better now !

Couple of things to clarify:
* this is not a new algorithm, but an option to use with relative weights algorithm * I noticed a mutex (lock) was added per set -- it is required only in the context of using this new feature? Does it affect using relative weights without congestion control? * the cc attribute needs to be set in all destination records belonging to the same set when wanting to use this new feature?
Thanks for the comments and questions.
Q: this is not a new algorithm, but an option to use with relative weights algorithm A: This is correct, I think the documentation is accurate on this point, adding new one was not needed, let me know if you think this would be more clear ?
Q: I noticed a mutex (lock) was added per set -- it is required only in the context of using this new feature? Does it affect using relative weights without congestion control? A: Correct, it is only needed with CC, because the SIP OPTIONS ping are processed by each worker and they can endup redistributing the weight simultaneously. Do you think we should try make the lock optional (only enforced when absolutely needed) ? My tought was that without CC it will be used very unfrequently when a GW times out.
A: the cc attribute needs to be set in all destination records belonging to the same set when wanting to use this new feature? - correct this is more flexible I believe since you can activate congestion detection per gateway, if CC is not set the GW will always keeps its weight.
OK, clarified. I am going to merge it.
Merged #1533.