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

dispatcher: algorithm 13 latency optimized round-robin with failover #2493

Merged
merged 1 commit into from Nov 19, 2020

Conversation

jchavanton
Copy link
Member

@jchavanton jchavanton commented Oct 1, 2020

Type Of Change

  • New feature (non-breaking change which adds new functionality)

Checklist:

  • Tested changes locally

Description

Previously discussed in the mailing list :

“13” - latency optimized dispatching .

  • The algorithm will load balance using round-robin prioritizing the gateways with the highest priority.
  • If ds_ping_latency_stats is active the algorithm will adjust the priority of the gateway automatically,
    the priority will be lowered by 1 point every time the latency ms is as high as the priority.
  • If the attribute 'cc=1' is set, the latency used is congestion ms : estimate (current latency ms) - average (normal condition latency ms).

Using this simple formula :
ADJUSTED_PRIORITY = PRIORITY - (ESTIMATED_LATENCY/PRIORITY)

GATEWAY PRIORITY ESTIMATED_LATENCY ADJUSTED_PRIORITY LOAD DISTRIBUTION
1 30 21 30 33%
2 30 91 27 0%
3 30 61 28 0%
4 30 19 30 33%
5 30 32 29 0%
6 30 0 30 33%
7 30 201 24 0%

With congestion control the formula becomes :

CONGESTION_MS = CURRENT_LATENCY_MS - NORMAL_CONDITION_LATENCY_MS
ADJUSTED_PRIORITY = PRIORITY - (CONGESTION_MS/PRIORITY)

@jchavanton
Copy link
Member Author

  • I will make sure the GW are well sorted, not only the first pick.
  • I am considering additional support for weight based distribution with optional congestion control at equal priority.

@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch 5 times, most recently from 51c155f to f7c98e2 Compare October 8, 2020 23:45
@lgtm-com
Copy link

lgtm-com bot commented Oct 9, 2020

This pull request introduces 1 alert when merging f7c98e2 into 9935dc8 - view on LGTM.com

new alerts:

  • 1 for Comparison result is always the same

@jchavanton
Copy link
Member Author

jchavanton commented Oct 9, 2020

This pull request introduces 1 alert when merging f7c98e2 into 9935dc8 - view on LGTM.com

new alerts:

* 1 for Comparison result is always the same

looked at it, hash is returned and can be -1 , unless I am blind

@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch from f7c98e2 to dbfe2d8 Compare October 14, 2020 17:50
@lgtm-com
Copy link

lgtm-com bot commented Oct 14, 2020

This pull request introduces 1 alert when merging dbfe2d8 into e3e6471 - view on LGTM.com

new alerts:

  • 1 for Comparison result is always the same

@lgtm-com
Copy link

lgtm-com bot commented Oct 26, 2020

This pull request introduces 1 alert when merging 46745e5 into a1620fa - view on LGTM.com

new alerts:

  • 1 for Comparison result is always the same

@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch from 46745e5 to 8dfe043 Compare November 9, 2020 23:57
@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch 4 times, most recently from dffc88f to b793b96 Compare November 10, 2020 04:48
@lgtm-com
Copy link

lgtm-com bot commented Nov 10, 2020

This pull request introduces 1 alert when merging b793b96 into e9624bc - view on LGTM.com

new alerts:

  • 1 for Comparison result is always the same

@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch 2 times, most recently from b16fc8d to 1c819e0 Compare November 10, 2020 23:10
@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch 2 times, most recently from dfacc80 to b2ac69e Compare November 11, 2020 17:51
- latency optimized round-robin with failover
- optionally congestion can be use instead of latency

- thanks to Salman Ali (asalman18) for the review
@jchavanton jchavanton force-pushed the jchavanton/dispatcher_algorithm13 branch from b2ac69e to cf6e89c Compare November 12, 2020 00:46
@jchavanton
Copy link
Member Author

jchavanton commented Nov 13, 2020

Load tested Friday the 13th :)
250CPS

3 gateways, one with excessive ( latency >30ms delta with the 2 others since a priority of 30 is set)

URI: sip:65.75.65.247:5072
FLAGS: AP
PRIORITY: 30
ATTRS: {
	BODY: latency=10
}
LATENCY: {
	AVG: 10.039000
	STD: 1.381000
	EST: 10.001000
	MAX: 10
	TIMEOUT: 0
}

URI: sip:65.75.65.247:5071
FLAGS: AP
PRIORITY: 30
ATTRS: {
	BODY: latency=250
}
LATENCY: {
	AVG: 249.847000
	STD: 5.377000
	EST: 141.598000
	MAX: 250
	TIMEOUT: 0
}

URI: sip:65.75.65.247:5073
FLAGS: AP
PRIORITY: 30
LATENCY: {
	AVG: 0.000000
	STD: 0.000000
	EST: 0.000000
	MAX: 1
	TIMEOUT: 0
}

algorithm is doing round-robin on GW5072 and GW5073 and keep GW5071 for failover

 2(51) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[0]uri[sip:65.75.65.247:5072]priority[30-0=30]latency[10ms]flag[8]
 2(51) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[1]uri[sip:65.75.65.247:5071]priority[30-8=22]latency[250ms]flag[8]
 2(51) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[2]uri[sip:65.75.65.247:5073]priority[30-0=30]latency[0ms]flag[8]
 2(51) INFO: dispatcher [dispatch.c:2224]: ds_manage_route_algo13(): priority[30]gateway_selected[0]next_index[1]

 1(50) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[1]uri[sip:65.75.65.247:5071]priority[30-8=22]latency[250ms]flag[8]
 1(50) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[2]uri[sip:65.75.65.247:5073]priority[30-0=30]latency[0ms]flag[8]
 1(50) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[0]uri[sip:65.75.65.247:5072]priority[30-0=30]latency[10ms]flag[8]
 1(50) INFO: dispatcher [dispatch.c:2224]: ds_manage_route_algo13(): priority[30]gateway_selected[2]next_index[0]

 5(54) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[0]uri[sip:65.75.65.247:5072]priority[30-0=30]latency[10ms]flag[8]
 5(54) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[1]uri[sip:65.75.65.247:5071]priority[30-8=22]latency[250ms]flag[8]
 5(54) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[2]uri[sip:65.75.65.247:5073]priority[30-0=30]latency[0ms]flag[8]
 5(54) INFO: dispatcher [dispatch.c:2224]: ds_manage_route_algo13(): priority[30]gateway_selected[0]next_index[1]

 2(51) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[1]uri[sip:65.75.65.247:5071]priority[30-8=22]latency[250ms]flag[8]
 2(51) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[2]uri[sip:65.75.65.247:5073]priority[30-0=30]latency[0ms]flag[8]
 2(51) INFO: dispatcher [dispatch.c:2207]: ds_manage_route_algo13(): [active]idx[0]uri[sip:65.75.65.247:5072]priority[30-0=30]latency[10ms]flag[8]
 2(51) INFO: dispatcher [dispatch.c:2224]: ds_manage_route_algo13(): priority[30]gateway_selected[2]next_index[0]
Total 20000 INVITE calls sent in 79433 ms at rate of 251/sec
Total 20000 connection responses received in 82101 ms at rate of 243/sec:
>> Detailed connection responses received:
 - 200 connection responses:    20000     (OK)
>> Detailed disconnection responses received:
 - 200 disconnection responses:    20000     (OK)
                    ------
 TOTAL responses:    20000 (rate=243/sec)

Maximum outstanding job: 719

@henningw
Copy link
Contributor

Thank you for the pull request, and also the announcement on the list.
Are there any more additions/refinements done from your side? Otherwise if there are no objections it can be merged, i think.

@jchavanton jchavanton merged commit 90e3033 into master Nov 19, 2020
@jchavanton jchavanton deleted the jchavanton/dispatcher_algorithm13 branch March 30, 2021 17:38
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.

None yet

3 participants