<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Mateusz,<br>
      <br>
      You have 2 approaches:<br>
      <br>
      1) send the calls to the carriers as you get them (same rate) - 90
      calls will be rejected and you can capture that in failure route
      (I guess they will use a given reply code to indicate rejection
      when exceeding cps); in failure route, do a async sleep (or
      usleep) and send the call again to the carrier (serial forking).
      Hopefully, 10 more will be accepted to this new iteration, and you
      will have to get in failure route only 80.<br>
      This is a bit of a brutal approach, but it is the simple.<br>
      <br>
      2) on the carrier side, use ratelimit module to control the cps
      (not more than 10 cps) - each time you send a call to the carrier,
      check the cps for that carrier -&gt; if more than 10 -&gt; do
      sleep / usleep (in async mode !) and retry (you can do a
      "while(cps&gt;10) usleep()" )<br>
      <br>
      Regards,<br>
    </tt>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 28.03.2016 01:03, Mateusz Bartczak
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAJWEF2YmiCSmU00O-L+Umv_ca6=udr5G6cgAum6-0cGZ5c2fAg@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi
        <div><br>
        </div>
        <div>I'm looking for a solution to nicely handle call spikes</div>
        <div><br>
        </div>
        <div>The issue is like this: </div>
        <div><br>
        </div>
        <div>I have customer generating 100 calls every 10 seconds. Not
          during 10 seconds, but exactly every 10 seconds I get 100
          calls in one second, next 9 seconds nothing and then next 100
          calls...</div>
        <div><br>
        </div>
        <div>On the other side, I have provider that has 10 CPS limit</div>
        <div><br>
        </div>
        <div>In current setup I can only handle every 10 first calls, 90
          are discarded by the provider. So I can handle only 10% of
          customer's traffic</div>
        <div><br>
        </div>
        <div>I'm thinking about a solution to delay calls above CPS
          limit to the nearly future. If I could delay calls 10-20 by
          one second, 20-30 by two seconds and so on. This way, in
          theory, I could handle 100% of calls not just 10%</div>
        <div><br>
        </div>
        <div>I can implement such thing with FreeSWITCH, call parking
          and some fancy scripting, but FS is many, many times slower
          than OpenSIPS and I'd like to avoid using it in such high CPS
          scenario</div>
        <div><br>
        </div>
        <div>Is there any pure OpenSIPS solution to this kind of
          problem?</div>
        <div><br>
        </div>
        <div>Best Regards</div>
      </div>
      <div id="DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
        <table style="border-top:1px solid #aaabb6">
          <tbody>
            <tr>
              <td
style="width:470px;padding-top:20px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Ten
                e-mail został wysłany z komputera wolnego od wirusów
                chronionego przez Avast. <br>
                <a moz-do-not-send="true"
href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail"
                  target="_blank" style="color:#4453ea">www.avast.com</a>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>