<div dir="ltr">Hello Razvan,<div> God Day,</div><div> Thank you for the update,it seems that though we create multiple TCP connections opensips uses only one tcp connection to send the data out.</div><div> should a child be locking the tcp connection mechanism? while creating a new tcp connection as we will be overwriting the tcpconn_aliases_has to the</div><div> latest/recent fd. </div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div> I believe here's the root cause :</div><div> - When a child tries to find a connection to the destination it calls _tcpconn_find() (assuming we are using ip and not id) system checks <u><i><b>tcpconn_aliases_hash </b></i></u>for the connection info.<br></div><div> <b><i> 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 a-><span style="color:rgb(128,0,0)">parent</span>-><font color="#800000">state is BAD </font><font color="#000000">this method</font></i></b></div><div><font color="#000000"><b><i> 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</i></b></font></div><div><font color="#000000"><br></font></div><div><font color="#000000"> - <b><i>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 </i></b></font></div><div><font color="#000000"><b><i> main process to update the has map.</i></b></font></div><div><font color="#000000"><br></font></div><div><font color="#000000"> - <b><i>Not sure if tcp_connect() should have locking mechanism as in tcpconn_get().</i></b></font></div></div></blockquote></div><div><div class="gmail_extra"> Thank you :)</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Ravitez.D</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 8, 2017 at 10:48 AM, Răzvan Crainea <span dir="ltr"><<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div 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="gmail-m_-6377956126017792630moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="gmail-m_-6377956126017792630moz-txt-link-abbreviated" href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
<div class="gmail-m_-6377956126017792630moz-cite-prefix">On 05/04/2017 04:11 PM, Ravitez Ravi
wrote:<br>
</div>
<blockquote type="cite">
<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="gmail-m_-6377956126017792630mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
Users mailing list
<a class="gmail-m_-6377956126017792630moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a class="gmail-m_-6377956126017792630moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</div>
<br>______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div></div></div>