<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>there was an issue on the tracker, but this looks like the
      redistribution due to percentage not being an integer number.  I
      referred to the docs (being noted there), closed the issue and
      pointed to sr-users for further discussions.</p>
    <p>So, for example, if there are 30 routes each with rweight of 50,
      that means total rweight of 1500. With that, each route has the
      percentage of 50*100/1500=3.33, which is rounded to 3, meaning
      that each destination gets 3 calls in 100, total 90, with the last
      one (which can be the first in the dispatcher list file, depending
      on internal sorting and instert) getting the remaining 10, overall
      13 go to this route (so 19 routes will get 3 calls, and 1 will get
      13 calls). Now, depending on the number of routes, one of them may
      get a different value, but the fact is that if the percentage
      isn't an integer number, then the distribution is not equal for
      one of them. For example, with the 6 routes:</p>
    <p>total rweight => 6 * 50 = 300; then percentage per route is
      50*100/300 = 16.6, rounded to 16, meaning one will get 20.<br>
    </p>
    <p>You may want to do a double check of the rweight algorithm code,
      I haven't implemented it, but for weight the above remarks apply.</p>
    <p>That was discussed in the past on the mailing list, and very
      likely it is not a bug also in this case, but how the distribution
      can be spread across 100 calls.</p>
    <p>Even more, for r/weight algorithms, it really makes no sense to
      use them when there are so many routes with same weight,
      practically on more than 50, each one will get 1 call and the last
      in the memory least will get 51. So one gets more than 50% of the
      calls. From the other perspective, this is not even feasible to
      route to all of them in the same step, because by default kamailio
      can create 12 branches for a request, with a maximum configurable
      value of 31 (iirc). I think round robin or call load distribution
      is better for such large number of routes.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 30.03.21 18:57, Julien Chavanton
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAKmcL2=t8Jk1yrW3BRFz_Qa=GKC0Mvz1xDLrSQ6sN3E2inW2sA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Ivan, must be a limitation/problem in the
        computation, can you open an issue.<br>
        <br>
        Since I have built on top of algorithm 11, I could have a look,
        we may also notify the original author to see what can be done.<br>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, Mar 30, 2021 at 8:52
          AM Ivan Matvieiev <<a href="mailto:i.matvieiev@kwebbl.com"
            moz-do-not-send="true">i.matvieiev@kwebbl.com</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello
          Community,<br>
          <br>
          There is a module dispatcher and sharing algorithm 11 that
          features<br>
          the ability to redistribute load when the host is enabled or
          disabled<br>
          that is quite valuable for me.<br>
          In the test lab I faced unexpected behavior:<br>
          - when I add to group <=25 hosts algorithm behaves as per
          description.<br>
          - when a group includes 26 or more hosts, and 100 calls are
          done for<br>
          instance, then about 25 go to the first host and 75 are
          distributed<br>
          among the rest of hosts.<br>
          <br>
          Expected behavior: all hosts of the group having the same
          rweight<br>
          value must receive the same amount of calls no mater what
          number of<br>
          hosts is in the group.<br>
          <br>
          Could you please to help to figure out what is wrong and why
          when the<br>
          dispatcher group consists of 26+ hosts dispatching algorithm
          11<br>
          behaves differently than when group consists of 25 or less of
          hosts?<br>
          <br>
          Some configuration notes:<br>
          # module configs<br>
          modparam("dispatcher", "list_file",
          "/etc/kamailio/dispatcher.list")<br>
          modparam("dispatcher", "flags", 2)<br>
          modparam("dispatcher", "ds_ping_method", "OPTIONS")<br>
          modparam("dispatcher", "ds_probing_threshold", 3)<br>
          modparam("dispatcher", "ds_inactive_threshold", 10)<br>
          modparam("dispatcher", "ds_probing_mode", 3)<br>
          modparam("dispatcher", "ds_ping_interval", 10)<br>
          modparam("dispatcher", "ds_ping_reply_codes",
          "501,403,404,400,200")<br>
          modparam("dispatcher", "ds_ping_from",DS_PING_FROM_PARAM)<br>
          modparam("dispatcher", "use_default", 0)<br>
          <br>
          # dispatching algorithm call<br>
          if ( ds_is_from_list("101")) {<br>
               sl_send_reply("100","My calls");<br>
               ds_select_dst("100", "11");<br>
               return;<br>
          }<br>
          <br>
          # dispatcher list group config<br>
          100 sip:<a href="http://10.60.27.123:7000" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7000</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7001" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7001</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7002" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7002</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7003" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7003</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7004" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7004</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7005" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7005</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7006" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7006</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7007" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7007</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7008" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7008</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7009" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7009</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7010" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7010</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7011" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7011</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7012" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7012</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7013" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7013</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7014" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7014</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7015" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7015</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7016" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7016</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7017" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7017</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7018" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7018</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7019" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7019</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7020" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7020</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7021" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7021</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7022" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7022</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7023" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7023</a>
          0 10 rweight=50<br>
          100 sip:<a href="http://10.60.27.123:7024" rel="noreferrer"
            target="_blank" moz-do-not-send="true">10.60.27.123:7024</a>
          0 10 rweight=50<br>
          <br>
          Kamailio version:<br>
          kamailio -v<br>
          version: kamailio 5.4.4 (x86_64/linux) e16352<br>
          flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS,<br>
          DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC,
          Q_MALLOC,<br>
          F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX,<br>
          FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER,
          USE_NAPTR,<br>
          USE_DST_BLACKLIST, HAVE_RESOLV_RES<br>
          ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144,
          MAX_URI_SIZE<br>
          1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB<br>
          poll method support: poll, epoll_lt, epoll_et, sigio_rt,
          select.<br>
          id: e16352<br>
          compiled on 15:56:46 Feb 15 2021 with gcc 4.8.5<br>
          <br>
          System info<br>
          CentOS Linux release 7.7.1908 (Core)<br>
          Linux test-carrier-1.loc 3.10.0-1062.4.1.el7.x86_64 #1 SMP Fri
          Oct 18<br>
          17:15:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux<br>
          <br>
          _______________________________________________<br>
          Kamailio (SER) - Users Mailing List<br>
          <a href="mailto:sr-users@lists.kamailio.org" target="_blank"
            moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
          <a
            href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>