After 10 concurrent users in chat room I've got "The timeout specified has expired.." errors and had to take it down.

I'm using a shared hosting environment:

PHP Version 5.2.9
max_execution_time 30
max_input_nesting_level 64
max_input_time 60
memory_limit 128M

MySQL 5.1.37
mysql.connect_timeout 60

Tormi

Comments

Anonymous’s picture

Assigned: Unassigned »

ouch! i'll try to test this out a bit, but its hard to make too many suggestions without being able to see the live setup.

tormi’s picture

I enabled throttle module to reduce the burdening effect of chatroom module for my site with following settings:

Auto-throttle on anonymous users: 100
Auto-throttle on authenticated users: 10
Auto-throttle probability limiter: 10%

Throttle disabled active chats and chatroom blocks with 4 only registered users online - strange..

Justin, I did send some details to you about my site via e-mail.

Tormi

Anonymous’s picture

tormi: i'm a bit busy right now, i'll get to looking at your site shortly.

can you confirm that caching is working? i.e., look at chatroomread.php, and make sure that requests for new chat messages hit the cache? if this is not working, the module is very heavy.

tormi’s picture

Justin,

yes, chatroomread.php uses files/tmp as chat_cache_directory and there are cache files in that dir. I will upgrade my hosting plan and hope it will help.

Thanks,
Tormi

adam_b’s picture

I'm having problems with performance also - no timeout, but it's extremely slow with only about 5 users.

I don't have a files/tmp directory and can't find any reference to it in chatroomread.php - any other suggestions?

tormi’s picture

This is how part of my today's 100 MB (unpacked) access_log file looks like:

...
90.191.223.188 - - [20/Jan/2010:00:04:49 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
213.219.91.153 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
195.50.200.164 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB6 (.NET CLR 3.5.30729)"
90.191.223.188 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
88.196.39.145 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.17) Gecko/2009122116 Firefox/3.0.17 (.NET CLR 3.5.30729)"
213.219.91.153 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
90.191.196.144 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 272 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)"
195.50.200.164 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB6 (.NET CLR 3.5.30729)"
90.191.196.144 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)"
90.191.196.144 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)"
90.190.136.57 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6"
213.35.230.45 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
90.191.223.188 - - [20/Jan/2010:00:04:50 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
213.219.91.153 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
195.50.200.164 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB6 (.NET CLR 3.5.30729)"
90.191.223.188 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
88.196.39.145 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.17) Gecko/2009122116 Firefox/3.0.17 (.NET CLR 3.5.30729)"
213.219.91.153 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
195.50.200.164 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB6 (.NET CLR 3.5.30729)"
90.190.136.57 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6"
213.35.230.45 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
90.191.223.188 - - [20/Jan/2010:00:04:51 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
195.50.200.164 - - [20/Jan/2010:00:04:52 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB6 (.NET CLR 3.5.30729)"
213.219.91.153 - - [20/Jan/2010:00:04:52 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
90.191.223.188 - - [20/Jan/2010:00:04:52 +0200] "POST /chatroomread.php HTTP/1.1" 200 271 "" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
...

I had update frequency = 1 sec in chat's settings. I changed it to 5 sec (Manual > Update frequency: http://drupal.org/node/637286) in a hope it will improve the current very 503-ish situation..

Tormi

tormi’s picture

adam_b,

Yes, it's a bit hidden ;)

See

00861: 'cacheDirectory' => file_directory_temp(),

in chatroom.module and

00116: chat_cache_directory: Drupal.settings.chatroom.cacheDirectory,

in chatroom.js and

00038: $chat_cache_file = $_POST['chat_cache_directory'] . '/chatroom.chat.' . $chat_id . '.cache';

in chatroomread.php

Tormi

tormi’s picture

I had update frequency = 1 sec in chat's settings. I changed it to 5 sec (Manual > Update frequency: http://drupal.org/node/637286) in a hope it will improve the current very 503-ish situation..

Unfortunately it didn't help..

adam_b’s picture

Thanks Tormi - I can see all of those references in the code, but it's still not clear to me exactly where I should be looking? Apologies, but I'm not a developer so I'm probably missing something very obvious here.

I'm not sure I'm getting the same problem as you, since I haven't actually had timeouts - just extremely slow response when a chat user tries to post a new message. Let me know if I should take this into a separate issue.

tormi’s picture

adam_b,

you can see/set the path to your tmp folder in admin/settings/file-system

cache is enabled if there are files called chatroom.chat.' . $chat_id . '.cache in tmp folder

Tormi

adam_b’s picture

Okay, this is odd... The directory was set to /tmp/, but there was no such directory and therefore no files of those names. I tried creating the directory manually and using the chat, but still no files appeared.

I changed it to /sites/default/files/tmp/ and used the chat again, and files appeared. My initial impression is that it's still slow, but I'll do some more testing. Many thanks for the help.

tormi’s picture

Okay, this is odd... The directory was set to /tmp/, but there was no such directory and therefore no files of those names

It was probably somewhere above the web root, try this PHP snippet to find out:

print file_directory_temp();

Tormi

tormi’s picture

Need to investigate the effect to change from MyISAM to InnoDB for better performance, see also http://drupal.org/node/275645

Tormi

BenK’s picture

Subscribing...

hlevinson’s picture

subscribing

adam_b’s picture

I have to say that I wouldn't be very happy about making major changes to the db just to fix problems for this one module - particularly since 6.x-1.x performed very well.

tormi’s picture

Justin,

are you still there? ;)

In my Drupal's Recent log entries there are lots of stuff like this:

Type Date Message User Operations
access denied 14.02.2010 - 21:48 chatroom/chat/get/latest/messages/49/40300 Anonymous
access denied 14.02.2010 - 21:48 chatroom/chat/get/latest/messages/49/40300 Anonymous
access denied 14.02.2010 - 21:48 chatroom/chat/get/latest/messages/49/40300 Anonymous

Top 'access denied' errors
Count Message
5273 chatroom/chat/get/latest/messages/49/40300

And error_log shows this:
somedomain.com [Sat Feb 13 23:17:54 2010] [error] [client xxx.xxx.xx.xxx] Invalid URI in request Accept: application/json, text/javascript, */*

Any hints?

adam_b’s picture

I just did a test session with 4 users total, with the following results:
- no errors in log entries (re tormi's comments in #17)
- cache file appeared in appropriate location
- behaviour was basically OK up to 3 users (chat was set for up to 10 users) - about 3 seconds between clicking Chat button and message appearing in window

When a fourth user joined:
- it usually showed only three users in the user list at the top - but it wasn't consistent about which user it dropped
- messages could take up to 3 minutes to appear - though some of them still took only 3 seconds
- some messages never appeared at all
- some users suffered more problems than others - eg the fourth user to join only saw one or two messages out of ~10 submitted

When I tried changing the block update interval in /admin/settings/chatroom, I got an error message:

Site off-line

The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.

If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the handbook, or contact your hosting provider.

The mysqli error was: User xxxxxxxxxx already has more than 'max_user_connections' active connections.

My settings.php file has no setting for the number of active connections; I'm running this in a shared hosting environment so I doubt I'd be able to change this.

adam_b’s picture

Is there anything that can be done about this? My clients are getting irritated.

If nothing else, could version 6.x-1.x be restored? While there were a lot of things that weren't good about it, I never had any performance problems and it was at least useable.

Anonymous’s picture

i've committed early support for APC caching here:

http://drupal.org/cvs?commit=341232

much faster, please test. let me know if you need help testing it, don't want to roll a release with it until i get some feedback.

context is here:

http://drupal.org/node/735964#comment-2717348

adam_b’s picture

Sorry, I haven't worked with CVS before so can't do much without something that resembles a release.

Following my previous comment [#19] I found a copy of 6.x-1.0-beta9 that I'd archived, so removed 6.x-2.x-dev and reinstalled the previous version instead; it's been working fine.

Farreres’s picture

I have tried 2.7 version and I have seen that for every chat a user has opened a new php thread is being opened, each consuming about 40% of my machine CPU. I am in a vps with low memory setup but it's just too high requirements for just showing a text in a window. It must have something to do with this non escalability.

Anonymous’s picture

Version: 6.x-2.x-dev » 6.x-2.9
Status: Active » Needs review

please try again with the 6.x-2.9 release. if you have APC caching, you'll find the module is much, much faster.

roald’s picture

Subscribing.
Had the same errormessage as in #18 yesterday, just a few users in the chatroom. It actually choked the shared server and I was suspended for 12 hours. Am using 6.x-2.9. No APC

Peter Bex’s picture

I guess it's mostly slow when it needs to fallback into a full Drupal bootstrap. When you have a lot of modules enabled, that's killing for performance.

I'm not sure I completely understand why it needs to do that yet, instead of doing the complete chat from chatroomread.php

Update: Obviously it needs to go through Drupal's permission checks (and the numerous override hooks involved) as well as load the correct theme stack. All these things cannot be done without either taking away the power of Drupal's extensive hook support or reinventing everything in Drupal core.

gausarts’s picture

Subscribing. Thanks

Anonymous’s picture

@roald: there's not much i can do to help if you don't have APC. that will make all of drupal slow, and make the chatroom's constant polling kill your server.

can you get memcached or another cache backend on your server/hosting?

artscoop’s picture

Hi,
I tested the module in several configurations :
1- No cache
2- DB Cache
3- Memcached + XCache
4- APC + Memcached

1. With a 1 second polling, this is overkill. Speed is ok if you don't type too much but 100% CPU. Even when idle.
1. With a 3 second interval, the CPU makes a square wave.
2. Well, I can't see any difference with 1 (1 user in the chat room)
3. This is much faster than 1 and 2. When Idle, the CPU is not used. When posting a message, the CPU peak (30% to 100%) lasts something like 0.3sec. That means I can't expect users to type more than 3 messages a second :/
4. Pretty much like 3. Maybe slower, I may have failed somewhere.

The cache file for the node has also never got above 4 bytes. (it contains "205").

Is this expected ?

tormi’s picture

I don't have APC caching available and can't test chatroom with it.

Tormi

zcrosher’s picture

Subscribed - I'm having the exact same problem regarding speed. Am concerned as well about adding users and having the performance seriously compromised. Does anyone have a suggestion for another drupal chat room space?
Thanks, ZC

Anonymous’s picture

Status: Needs review » Active

there's no patch here.

adam_b’s picture

I found Tribune works pretty well, though I haven't tried it with a lot of users.

Anonymous’s picture

Status: Active » Closed (fixed)

please take this to the forums.