<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/16 Olle E. Johansson <span dir="ltr"><<a href="mailto:oej@edvina.net" target="_blank">oej@edvina.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><br><div><div>16 nov 2013 kl. 00:10 skrev Leandro Dardini <<a href="mailto:ldardini@gmail.com" target="_blank">ldardini@gmail.com</a>>:</div><div class="im"><br><blockquote type="cite">
<div dir="ltr">Please read again your answer, because something is wrong ... on one side you are saying asterisk starts getting behind having to track the reponse of 7000 packets being sent every 10 seconds ... but if no answers are received due to network issue, is asterisk busy doing what? I don't think asterisk is becoming busy waiting for something not arriving. On the other side, you are blaming writes to the database for the slowdown. Are you seeing high load on the mysql database while the network is down or when the network is just back up?<div>
<br></div><div>However the solution is pretty simple. Just patch chan_sip to not update lastms and test the system. I am pretty interested in the result.</div><div><br></div></div></blockquote></div>In the longer run we need to abandon the current realtime system. It's not written for this. Realtime peers are in general a bad solution and not what you want. You can load static in-memory peers from database too and get a better solution. The question is what's lacking from that alternative?</div>
</div></blockquote><div><br></div><div><br></div><div>I really like the current realtime database and even if I am sure I can achieve the same results I have with peers stored in the database using static in-memory peers and DUNDI for locating the server where the peer is registered, the database is my preferred solution. Maybe loading and deleting peers from memory will be the same, but having them in a database will be a lots more comfortable. You can just add a new peer to the database and that is all. Instead, with the memory approach, you need to connect to every server (how? via AMI?) and add the peer. Using the database, I can use transaction, so if I need to change few peers at once, I am sure all changes take place or they are roll back. If I start changing peers on a server and something bad happens, I can end in a situation where half are changed and half are not. Again... using the database I can use locking if I need to make complex changes...<br>
</div><div><br></div><div>Leandro</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>/O<div><div class="h5">
<br><blockquote type="cite"><div dir="ltr"><div>Leandro</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/11/15 Damon Estep <span dir="ltr"><<a href="mailto:damon@soho-systems.com" target="_blank">damon@soho-systems.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It is not 1000 queries in 60 seconds, it starts as 1000 MORE queries in 60 seconds and compounds as it starts thrashing.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thousands of other queries also taking place all the time. WAY over 300/second total.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Not DNS related, DNS is local, hostnames are IPs anyways, so no DNS needed.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">We have done the port 5060 block test, and can duplicate this very easily.<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Tables are InnoDB, binary logged, and circular replication.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Remember that when 1000 peers are offline there are an extra 7000 packets being sent every 10s to try and reach them. Asterisk gets behind in processing the good responses, and the calculated RTT time for GOOD peers starts exceeding the maxms threshold, then the GOOD peers go offline too. Big snowball comes rolling down the hill and all is lost, all peers start flapping reachable/unreachable, and a quick restart of asterisk calms it down.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The best confirmation that this is the issue is that it was resolved by patching chan_sip.c so it does not update lastms when state changes or when a qualify is not answered at all. Only updates on registration or registration expire.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Still doing more testing, but pretty confident this is the answer.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I understand that you are using the lastms in the realtime db for call routing, so my solution won't work for you. Probably need a configuration flag like rtupdatequalify=yes|no<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:asterisk-dev-bounces@lists.digium.com" target="_blank">asterisk-dev-bounces@lists.digium.com</a> [mailto:<a href="mailto:asterisk-dev-bounces@lists.digium.com" target="_blank">asterisk-dev-bounces@lists.digium.com</a>] <b>On Behalf Of </b>Leandro Dardini<br>
<b>Sent:</b> Friday, November 15, 2013 3:47 PM</span></p><div><div><br><b>To:</b> Asterisk Developers Mailing List<br><b>Subject:</b> Re: [asterisk-dev] scalability issue with realtime lastms update on qualify state change<u></u><u></u></div>
</div><div><br></div></div></div><div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">My system are far less populated, so I think to be far from hitting your problems, but still, even after having read again your case, I can't believe asterisk is trashing that way. 1000 queries in 60 seconds are nothing compared with the load I have on the database even with far less peers. I had mysql databases (not voip related) running flawless with 300 queries every second... <u></u><u></u></p>
<div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Are you sure the trashing of your asterisk is not due to something other? I experienced problems with asterisk (not realtime) when the DNS servers were not reachable due to network outage... It will be nice to make a test... firewalling port 5060 inbound, so asterisk will think all peers are unreachable... I suspect it will not trash...<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Which kind of table type are you using? Are you still using MyISAM? Having a lots of contemporary "write" to a MyISAM table can bring a lots of slowdowns... just move to InnoDB.<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Leandro<u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p><div><p class="MsoNormal">2013/11/15 Damon Estep <<a href="mailto:damon@soho-systems.com" target="_blank">damon@soho-systems.com</a>><u></u><u></u></p>
<div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">This is helpful, so I understand how some people are using lastms in the database.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I also have a multiserver solution, and I use INVITE (Dial) to see if the peer is registered. If the user is not reachable the Dial will return a status from the other box that can be handled.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">My experience is that a multi-server solution can't scale past limits in the range listed below the way it works now unless you never experience a network issue that makes 25% or more of the peers go unreachable:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">10 servers, 2000 qualified peers per server</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">120 second qualify interval</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">qualify=3000</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">default retransmit time of 1 second</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Database load split between two reasonably powerful MySQL servers with circular replication enabled</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">at this scale, as soon as you have an event that takes down a large percentage of peers the database activity will back up, the qualify options packets will not be processed in real time, and the system will become unstable, with all peers flapping between reachable/unreachable, even after the network event is gone. It simply won't recover until you restart asterisk.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I am sure the limits vary with environment, but there is a limit with the current strategy, and it is caused by excessive database updates of lastms during periods with high unreachable peer counts.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Have you seen this yet? What is the scale of your deployment?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:asterisk-dev-bounces@lists.digium.com" target="_blank">asterisk-dev-bounces@lists.digium.com</a> [mailto:<a href="mailto:asterisk-dev-bounces@lists.digium.com" target="_blank">asterisk-dev-bounces@lists.digium.com</a>] <b>On Behalf Of </b>Leandro Dardini<br>
<b>Sent:</b> Friday, November 15, 2013 2:26 PM<br><b>To:</b> Asterisk Developers Mailing List<br><b>Subject:</b> Re: [asterisk-dev] scalability issue with realtime lastms update on qualify state change</span><u></u><u></u></p>
</div></div><div><p class="MsoNormal"> <u></u><u></u></p><p><br>Il 15/nov/2013 22:00 "Damon Estep" <<a href="mailto:damon@soho-systems.com" target="_blank">damon@soho-systems.com</a>> ha scritto:<br>><br>
> peer_lastms in memory tells you that, not lastms in the realtime database.<br>><br>> As far as I can see the lastms value in the realtime database is loaded only when the peer is created and quickly overwritten as soon as the first qualify is sent.<u></u><u></u></p>
<p>I have a realtime multiserver solution so I need to rely on database lastms otherwise how can I know if a peer usually registered on the other server is reachable or not?<u></u><u></u></p><p>Not only... on the web interface, the lastms is really pretty...<u></u><u></u></p>
<p>><br>> On Nov 15, 2013, at 1:29 PM, "Leandro Dardini" <<a href="mailto:ldardini@gmail.com" target="_blank">ldardini@gmail.com</a>> wrote:<br>><br>>><br>>> Il 15/nov/2013 21:11 "Damon Estep" <<a href="mailto:damon@soho-systems.com" target="_blank">damon@soho-systems.com</a>> ha scritto:<br>
>> ><br>>> > I have run into an issue with 1.8.15 with mysql realtime peers, qualify=3000, and about 2000 peers.<br>>> ><br>>> > <br>>> ><br>>> > In the event of a network degradation event (high packet loss, network down) the system gets into an unusable state.<br>
>> ><br>>> > <br>>> ><br>>> > let's say you have 2000 peers with qualify=yes (or 2000), and they are all reachable.<br>>> ><br>>> > <br>>> ><br>>> > Qualify frequency is 60 seconds (user definable), qualify unreachable is 10 seconds, and default retransmit timer of 1 second (both hardcoded in sip.h)<br>
>> ><br>>> > <br>>> ><br>>> > 1000 peers go offline due to a network event<br>>> ><br>>> > <br>>> ><br>>> > The database has to be updated 1000 times in 60 seconds to mark the lastms -1 for these 1000 peers<br>
>> ><br>>> > <br>>> ><br>>> > The same 1000 peers are now on a OPTIONS query schedule of once per 10 seconds, with 6 retransmits at 1 second intervals, total of 7 packets every 10 seconds for 1000 peers, or 700 new packets per second.<br>
>> ><br>>> > <br>>> ><br>>> > So, we experienced a major network issue, and our response is to increase the load on the asterisk server dramatically by updating the database 1000 times and starting a new campaign to reach unreachable peers that are offline.<br>
>> ><br>>> > <br>>> ><br>>> > In practice we see that when this happens, the calculated RTT time for peers that are not part of the network outage starts to increase (delay somewhere in hardware, code, who knows, but it does increase), and many of them start flapping between unreachable and reachable.<br>
>> ><br>>> > <br>>> ><br>>> > The database query load goes through the roof, the number of packets coming out of the asterisk box goes through the roof, and asterisk will not recover until it is restarted, even after the network event is cleared.<br>
>> ><br>>> > <br>>> ><br>>> > This is a new issue that came into play when lastms was added to the realtime database and the qualify code started updating it on every state change. 1.2 before lastms would handle this event gracefully, 1.8 wont, can't comment on 1.2 or 1.6.<br>
>> ><br>>> > <br>>> ><br>>> > My thinking is that the lastms value in the db has little to no value. The only time I see it used is when a realtime peer is built from the database on registration. If the lastms value is -1 the peer registers and is set to unreachable, gets an option query and becomes reachable right away.<br>
>> ><br>>> > <br>>> ><br>>> > rtupdate=no will stop the lastms updates, but it also stops the registration data from being updated in the database, which has unintended consequences.<br>
>> ><br>>> > <br>>> ><br>>> > Also, the 10 second qualify timer when unreachable might make sense in small environments, but is way too aggressive for larger environments. It needs to be user configurable.<br>
>> ><br>>> > <br>>> ><br>>> > Before I start patching, can anyone tell me what value lastms has and why it needs to be in the database?<br>>> ><br>>> > <br>>><br>
>> I disagree about the no value for lastms. How can I know if a peer is reachable without the lastms field?<br>>><br>>> Leandro<br>>><br>>> -- <br>>> _____________________________________________________________________<br>
>> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com/" target="_blank">http://www.api-digital.com</a> --<br>>><br>>> asterisk-dev mailing list<br>>> To UNSUBSCRIBE or update options visit:<br>
>> <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>><br>><br>> --<br>> _____________________________________________________________________<br>
> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com/" target="_blank">http://www.api-digital.com</a> --<br>><br>> asterisk-dev mailing list<br>> To UNSUBSCRIBE or update options visit:<br>
> <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><u></u><u></u></p></div></div></div><p class="MsoNormal"><br>--<br>
_____________________________________________________________________<br>-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com/" target="_blank">http://www.api-digital.com</a> --<br><br>asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><u></u><u></u></p></div><p class="MsoNormal">
<u></u> <u></u></p></div></div></div></div></div></div></div><br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com/" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br></blockquote></div><br></div>
-- <br>_____________________________________________________________________<br>-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br><br>asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a></blockquote></div></div></div><br><div>
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div>
---</div><div>* Olle E Johansson - <a href="mailto:oej@edvina.net" target="_blank">oej@edvina.net</a></div><div>* Cell phone <a href="tel:%2B46%2070%20593%2068%2051" value="+46705936851" target="_blank">+46 70 593 68 51</a>, Office <a href="tel:%2B46%208%2096%2040%2020" value="+468964020" target="_blank">+46 8 96 40 20</a>, Sweden</div>
<div><br></div></span><br>
</div>
<br></div><br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br></blockquote></div><br></div></div>