blak3r / yaai

SugarCRM Asterisk integration
http://www.sugarforge.org/projects/yaai
GNU General Public License v3.0
84 stars 85 forks source link

Yaai response is slow #123

Open ivo123 opened 11 years ago

ivo123 commented 11 years ago

Hi,

I wonder if you can give some hints what possible is wrong with our setup. We are using Sugar 6.5 Pro and the latest release of the yaai plugin. Everything is working (click to dial, popups for inbound / outbound calls) but it is quite slow and delayed. The Asterisk produces an event rate of nearly 1 per second and it looks like the plugin is not able to process that rate. If we filter out all events so only the events of one phone is going through everything is working fine and responsive. We tried already to use a faster machine , apc and so on but without success. We hope to deal with 30 - 100+ phones ...

Any hints?

Thanks, Ivo

blak3r commented 11 years ago

Try disabling logging to file. That code is pretty inefficient.

I'll have to think more. Are most of your calls inbound? And are they going to ring groups?

I have a v3 I'm doing beta testing on. It have some significant performance improvements. Send me an email.

From: ivo123 Sent: ‎March‎ ‎13‎, ‎2013 ‎10‎:‎15‎ ‎AM To: blak3r/yaai Subject: [yaai] Yaai response is slow (#123)

Hi,

I wonder if you can give some hints what possible is wrong with our setup. We are using Sugar 6.5 Pro and the latest release of the yaai plugin. Everything is working (click to dial, popups for inbound / outbound calls) but it is quite slow and delayed. The Asterisk produces an event rate of nearly 1 per second and it looks like the plugin is not able to process that rate. If we filter out all events so only the events of one phone is going through everything is working fine and responsive. We tried already to use a faster machine , apc and so on but without success. We hope to deal with 30 - 100+ phones ...

Any hints?

Thanks, Ivo

— Reply to this email directly or view it on GitHub.

ivo123 commented 11 years ago

Hi,

thanks for your fast answer. I tried without log file but without any success. Inbound / outbound calls are more or less 50% / 50% . We don't use any ring groups here.

Would be fine to beta test your latest version :)

Cheers, Ivo

blak3r commented 11 years ago

The update provided is more performance improvements related to your logged in SugarCRM users. It may have more events filtered out though... So, maybe it'll be better. What is your CPU usage like on your box?

I've been thinking about performance on really large systems so i'm definitely interested to see what happens. PHP is somewhat limited in the lack of ability to have threads and callbacks. So, each of the SOAP calls could be the bottle neck if you have a ton of them.

  1. What mysql database engine are you using? Are you using Inno-db? That'd probably be better in your case.
  2. Try commenting out the "dumpEvent" line around 398 of /custom/modules/Asterisk/asteriskLogger.php

           $e = getEvent($event);
           dumpEvent($e); // prints to screen   <--- comment this line, that'll keep things from printing to screen.
  3. Alternatively just make the logLine method return immediately (this will stop all printing for the most part)... by commenting the existing method out and replacing it with (Line 1964)

    function logLine($str, $logFile = "default") {
      return;
    }
  4. I'm also wondering if the performance is neccessarily related to asteriskLogger. It might be AMI in general.
  5. If the lag you're seeing is only a couple seconds, it could be you just need to improve your ajax poll rate. The default is 5000. Could drop that down to 2000.
ivo123 commented 11 years ago

I did some checks now. I turned off logging and exchanged the soap calls by rest ones. But without effect. But I found the bottleneck which seems to be the expensive regex sql query that takes several seconds to lookup the contact / account by the phone numbers. I will try to find a workaround for this

blak3r commented 11 years ago

Yeah that's a beast... But, that's shouldn't be happening too often in asteriskLogger. One time per call. How long is that query taking?

Make sure you have query cache enabled also.

Finally, for your code, are you working on V3 branch? Make sure you are... made some performance improvements. Make sure you're looking at V3 branch. Could you send me your rest version? I want to phase out all the soap stuff.

On Mon, Mar 18, 2013 at 12:11 PM, ivo123 notifications@github.com wrote:

I did some checks now. I turned off logging and exchanged the soap calls by rest ones. But without effect. But I found the bottleneck which seems to be the expensive regex sql query that takes several seconds to lookup the contact / account by the phone numbers. I will try to find a workaround for this

— Reply to this email directly or view it on GitHubhttps://github.com/blak3r/yaai/issues/123#issuecomment-15063943 .

ivo123 commented 11 years ago

the query took several seconds while one call per second arrived so it was just a question of time till the logger was delaying.

I was using the 2.6 code, I can send you a patch after some cleanups. If I find time I will check the latest 3.x

First I will try to use some kind of normalization in the phone numbers so I can search for them by sql queries while have the benefit of the index. If this will fail I was wondering to use a search server like ElasticSearch / Solr for the lookups.

blak3r commented 11 years ago

Any idea how many contacts you have? Must be a lot if its taking seconds.

Or is your database server just have poor performance?

Definitely checkout V3, It's more stable then master at this point.

As for improving the performance. If recommend creating a new table and formatting the phone numbers into e164. There are several discussions about this on here. I'd basically require logic hooks to keep it in sync with contact records.

~blake

On Mar 19, 2013, at 9:10 AM, ivo123 notifications@github.com wrote:

the query took several seconds while one call per second arrived so it was just a question of time till the logger was delaying.

I was using the 2.6 code, I can send you a patch after some cleanups. If I find time I will check the latest 3.x

First I will try to use some kind of normalization in the phone numbers so I can search for them by sql queries while have the benefit of the index. If this will fail I was wondering to use a search server like ElasticSearch / Solr for the lookups.

— Reply to this email directly or view it on GitHub.

blak3r commented 11 years ago

@ivo123 I'm working on some rest stuff this weekend for yaai. Could you send me your code "as is" so I could look at your queries?