[sr-dev] [kamailio/kamailio] Dispatcher : Re-distribution of messages when hash used and destination not available (#2361)

Kalki70 notifications at github.com
Tue Jun 16 22:50:57 CEST 2020


### Description

Selected algorithm is a hash, over Call-ID, From, etc. If destination is not available, a new one must be selected, without breaking the hash assignation (all messages with the same hash must be forwarded to the same destination)

### Expected behavior

The load to the failed destination to be (hopefully) evenly distributed over the remaining destinations.

#### Actual observed behavior

All the messages that were supposed to be sent to the failed destination are sent to only one of the remaining, causing it to receive double load, comparing with the rest

#### Debugging Data

In this test, 6000 Calls were sent to a group of six destinations, using algorithm "0" (hash over Call-ID)


  | All destinations active
-- | --
Dest1 | 996
Dest2 | 997
Dest3 | 999
Dest4 | 1006
Dest5 | 1005
Dest6 | 997
Total | 6000

![all_active](https://user-images.githubusercontent.com/20492105/84825429-6719a580-afef-11ea-971c-d59152fc6550.png)

Repeating the test, but with destination Dest4 down:

  | OriginalImplementation
-- | --
Dest1 | 975
Dest2 | 993
Dest3 | 2022
Dest4 | 0
Dest5 | 1019
Dest6 | 991
Total |  6000

![one_down_original](https://user-images.githubusercontent.com/20492105/84826132-8107b800-aff0-11ea-9663-f6e8992ed5e2.png)

We can see that poor destination Dest3 receives double traffic

### Possible Solutions

I implemented a solution that does not break the expected behavior (messages with same hash are assigned the same destination, but with a better distribution over remaining destinations)


  | New Implementation
-- | --
Dest1 | 1175
Dest2 | 1206
Dest3 | 1191
Dest4 | 0
Dest5 | 1216
Dest6 | 1212
Total | 6000

![one_down_new](https://user-images.githubusercontent.com/20492105/84826051-62092600-aff0-11ea-8f89-f06102e732d5.png)

Basically, the solution is as simple as to execute a rehash of the original hash. 

I will create a pull request with the proposed change, which I already tested, as it can be seen on the previous chart.

### Additional Information

  * **Kamailio Version** 

```
 kamailio 5.4.0-dev4 (x86_64/linux) 0c29e8-dirty
```

* **Operating System**:


```
Linux Rechitsa 5.4.19-100.fc30.x86_64 #1 SMP Tue Feb 11 22:27:11 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2361
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200616/b86c97e8/attachment.html>


More information about the sr-dev mailing list