<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <tt>Hi, Ravitez!<br>
      <br>
      You are right - if opensips gets multiple messages in parallel
      that need to get to a single destination, each process will open a
      different connection to that destination. However, all sequential
      messages will use a single TCP connection.<br>
      Synchronizing all the TCP actions to ensure you will have a single
      connection might be a bit overkill in terms of performance.<br>
      <br>
      May I ask if this is a problem for you? Can you detail a bit why?<br>
      <br>
      Best regards,<br>
    </tt>
    <pre class="moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 05/04/2017 04:11 PM, Ravitez Ravi
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CANs_LF-SSvZ9QqmzbiRW+fqM+FfHcLgpyBAh+CH7L5H_w-dLZg@mail.gmail.com">
      <div dir="ltr">Hi All,
        <div>        Good Day,</div>
        <div>        I have been seeing opensips creating
          mutiple(duplicate) TCP connections to the same destination if
          hit with heavy call load.</div>
        <div><br>
        </div>
        <div><b>What do i mean?</b></div>
        <div>opensips ip : 10.10.10.1</div>
        <div>Destination  : 10.10.10.2</div>
        <div>Tcp Children : 32</div>
        <div> </div>
        <div>    Ideally opensips will create only one tcp connections
          and reuses it,if there's a heavy call load i see there are
          several tcp connections which are created to the same
          destination.</div>
        <div>    I believe here's the root cause :</div>
        <div>    - When a child tries to find a connection to the
          destination it calls <span style="color:rgb(0,0,0)">_tcpconn_find</span>()
          (assuming we are using ip and not id) system checks
          tcpconn_aliases_hash for the connection info.<br>
        </div>
        <div>      this map is maintained by the parent process and each
          child lock its while reaing tcpconn_get().in order to simulate
          the scenario lets assume <span
            style="font-weight:bold;color:rgb(0,0,0)">a</span><span
            style="font-weight:bold;color:rgb(0,0,0)">-></span><span
            style="font-weight:bold;color:rgb(128,0,0)">parent</span><span
            style="font-weight:bold;color:rgb(0,0,0)">-></span><font
            style="font-weight:bold" color="#800000">state is BAD </font><font
            color="#000000">this method</font></div>
        <div><font color="#000000">      will return null and so the
            child tries to create a new connections,assuming there's a
            second child trying to find the same connections and goes
            through the same process</font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000">  - Now each child thinks there's no
            connection to the destination and calls tcpconn_connect()
            this will create a socket to the destination and passes over
            the fd to the </font></div>
        <div><font color="#000000">    main process to update the has
            map.</font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000">  - Not sure if tcp_connect() should
            have locking mechanism as in tcpconn_get().</font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000">Please correct me if my understanding
            is wrong,please share your thoughts.</font></div>
        <div><font color="#000000">Thank you.</font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font color="#000000">Regards,</font></div>
        <div><font color="#000000">Ravitez.D</font></div>
      </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>