more than Max Number of concurrent users

more than Max Number of concurrent users

by Colin Peters -
Number of replies: 26

Hi All,

I'm looking for a little help in identifying what I'm doing wrong.

I run a moodle site for a small number of students (40 tops) and have been finding that users are being disconnected especially in chats but not only chats.  There are 3 courses but only two being used. At times I can see that there are only 2 or 3 logged in users and I get the error message below in my log file.

neonataltraining.eu [Tue Oct 14 08:57:31 2014] [error] [client 81.145.165.2:39041] AH01215: PHP Warning:  mysqli::mysqli(): (42000/1203): User myusername already has more than 'max_user_connections' active connections in /home/sites/neonataltraining.eu/public_html/moodle2/lib/dml/mysqli_native_moodle_database.php on line 375

I tried to check and repair the MYSQL tables but understand I can't do that for an INNODB database.


On the live site I get the following from debugging...

3.404709 secsRAM: 70.3MBRAM peak: 71.5MBIncluded 408 filesget_string calls: 5140DB reads/writes: 169/5DB queries time: 0.13984 secsticks: 340 user: 97 sys: 48 cuser: 0 csys: 0Load average: 7.18Session (core\session\database): 73.4KBCaches used (hits/misses/sets)core/databasemeta** static acceleration **: 0 / 5 / 0cachestore_file: 5 / 0 / 0core/string** static acceleration **: 4673 / 662 / 0cachestore_file: 662 / 0 / 0core/langmenu** static acceleration **: 6 / 1 / 0cachestore_file: 1 / 0 / 0core/plugin_managercachestore_file: 3 / 0 / 0core/yuimodulescachestore_file: 3 / 0 / 0core/coursecatcachestore_session: 7 / 0 / 2core/eventinvalidation** static acceleration **: 0 / 2 / 0cachestore_file: 0 / 2 / 0core/coursemodinfocachestore_file: 1 / 0 / 0core/repositoriescachestore_static: 0 / 9 / 18Total: 5361 / 681 / 20


From a duplicate site on the same server I ran perspective.php and got...


Moodle System Benchmarks
Note for Moodle 1.7 and above:
Disable the record cache (Site Admin -> Server -> Performance) for realistic results!
Processor performance
Function calls40620003577000
Regular expression replaces over 1KB of text2270025800
Disk performance
16KB files read from disk (cache)39005300
16KB files written to disk (cache)800200
Database performance
Get_record calls on the course table9301010
Insert_record calls on the course table80280
Update_record calls on the course table601050
Maximum concurrent users (approx):115



The system...

php 5.3.28

moodle 2.6.5+ (Build: 20141002)  Only additional modules are 'questionnaire' and bootstrap theme.

mysql 5.5.33

apache 2.4.9


Shared hosting with Heart Internet in the UK

Redhat Linux

From the host info regarding the server I'm on:

  • Dual Quad Core Intel(r) Xeon(r) processors
  • 32 GB RAM
  • Dual SAS Drive (for the operating system)
  • RAID Mirroring (for the operating system)
  • Dual Power Supplies
  • Quad Gigabit Network Adapters



Having upgraded several times I wonder whether the config.php is outdated???

<?php  // Moodle configuration file


unset($CFG);

global $CFG;

$CFG = new stdClass();


$CFG->dbtype    = 'mysqli';

$CFG->dblibrary = 'native';

$CFG->dbhost    = 'localhost';

$CFG->dbname    = 'notmoodle';

$CFG->dbuser    = 'notmoodleuser';

$CFG->dbpass    = 'notgoingtorevealthis';

$CFG->prefix    = 'mdl_';

$CFG->dboptions = array(

    'dbpersist' => false,       // should persistent database connections be

                                //  used? set to 'false' for the most stable

                                //  setting, 'true' can improve performance

                                //  sometimes

    'dbsocket'  => false,       // should connection via UNIX socket be used?

                                //  if you set it to 'true' or custom path

                                //  here set dbhost to 'localhost',

                                //  (please note mysql is always using socket

                                //  if dbhost is 'localhost' - if you need

                                //  local port connection use '127.0.0.1')

    'dbport'    => '',          // the TCP port number to use when connecting

                                //  to the server. keep empty string for the

                                //  default port

);


$CFG->wwwroot   = 'http://www.neonataltraining.eu/moodle2';

$CFG->dataroot  = '/home/sites/neonataltraining.eu/mydatafolder';

$CFG->admin     = 'admin';


$CFG->directorypermissions = 0777;


$CFG->passwordsaltmain = 'notrevealingthiseither';


require_once(dirname(__FILE__) . '/lib/setup.php');


// There is no php closing tag in this file,

// it is intentional because it prevents trailing whitespace problems!


Here's hoping that a kind soul can interpret these results better than I can!!

If there's more information that I

Thanks for your help on the matter.


Colin



Average of ratings: -
In reply to Colin Peters

Re: more than Max Number of concurrent users

by James McLean -

The answer is in this error: "User myusername already has more than 'max_user_connections' active connections in"

The MySQL server is configured to only allow X amount of connections from the application, and the application is exceeding this number.

In the config you posted you have dbpersist set to false - I would set it to true and connections will be reused rather than broken down and re-established with every page view as they are now. This will help alleviate the issue. 

Should it occur again once you're on persistant connections, investigate increasing the number of connections MySQL is configured to allow with the max_connections variable, documentation available here: http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_max_connections and additionally the variable max_user_connections as mentioned in the error: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_user_connections

In reply to James McLean

Re: more than Max Number of concurrent users

by Colin Peters -

Thanks James,

I'll give it a go as we've got a chat session this evening in the live environment tonight.  All advice I'd seen previously had been to change to 'false' but appreciate the rationale for making it 'true'.


Colin

In reply to Colin Peters

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers

Colin, Issue is with allocated resources on your shared web host environment, despite you have mentioned the specs of the server as being very powerful, but question is, how much of that you are getting share of, there is where shared hosting do get different outcomes, usual industry practice is, using a good piece of hardware, and then stuffing it with user accounts allocating minimal resources to each individual that is why I have had different performance experience with different providers.


can you give a try to a different web hosting service?, with my experience of shared web hostings I'll recommend giving a test to another hosting company for a quick comparison of performance. 

(Edited by Howard Miller - gratuitous advertising removed - original submission Wednesday, 15 October 2014, 5:41 AM)

In reply to Usman Asar

Re: more than Max Number of concurrent users

by James McLean -

Wow, really? 

That's a pretty low attempt at spamming. Exactly how much do you earn if he clicks on the affiliate link you provided? Do you get more if he or anyone else signs up?

Admins, I suggest deleting that post (and this one) as, based on the detail provided, capacity is almost certainly not his issue.

In reply to James McLean

Re: more than Max Number of concurrent users

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
James

You have made the following allegation about Usman:
> That's a pretty low attempt at spamming. Exactly how much do you earn if he clicks on the affiliate link you provided? Do you get more if he or anyone else signs up?

Now you need to bring the evidence.
In reply to Visvanath Ratnaweera

Re: more than Max Number of concurrent users

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

the url Usman posted contains an affiliate id, but I don't really think we can completely class this as spamming. It was in the context of the discussion, the user reported they were having an issue related to shared hosting, Usman has responded with some good suggestions and details on what I presume is a hosting package he has used previously that he has found to work well. Many shared host providers are not able to cope with Moodle's requirements.

The only other grey area would be if he was promoting a company that violated the Moodle Trademark - my initial look suggests that hostwinds doesn't.

But I am not the moderator of the hardware and performance forum.

Average of ratings: Useful (2)
In reply to James McLean

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers
Indeed that an affiliate, but I could have provided affiliate link to ANY other host, but why HostWinds? There are reasons to that, I have spent time with different hosts testing their Installation and performance of Moodle so HostWinds is one of them, and if I am recommending them based on moodle satisfaction, I can always ask for their Affiliate Link.

That was for shared host, there are other hosting compaies I refer to as well, depending on size of Installation, Like WiredTree  - Link HERE (For Dedicated, Hybrid and VPS) and close alternative to HostWinds is CrocWeb (Link HERE) - Now both of WiredTree and CrocWeb dont provide affiliate opportunities, but I openly recommend them.

FYI, if  Affiliate would have been ultimate  goal for me, then there are hosts giving 10 times more than what HostWinds is, I would  have recommended them. If you dont want to use the Link provided, I have as well mentioned their name (HostWinds), you can type in Google and search for it. And that Discount Code, ultimately gives user benefit of 99% off their First Month's payment, now any sensible person would have seen who's getting benefited out of that, me? the hosting provider? or the buyer of hosting service?.

In reply to Usman Asar

Re: more than Max Number of concurrent users

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

With my moderator hat on... I removed your link. 

The problem for me was the advertising 'blurb' that went along with it. That was inappropriate IMO. I don't have a big problem with "what's the best host" discussions but there is a time and a place. 

However, to say it was "spamming" is going a bit far. And... *none* of this is helping the OP very much wink

In reply to Howard Miller

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers
Howard, but you could have left the coupon code intact, as it would have benefited the buyer in the end.
In reply to Usman Asar

Re: more than Max Number of concurrent users

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Just noting that the OP asked for help with his problem, not for hosting recommendations. See the difference? I don't think it was in the natural flow of the discussion. If the conclusion was that his hosting was no good and he had then asked for a recommendation I would have let it go. As it stands, I think it was inappropriate. 

Average of ratings: Useful (1)
In reply to Usman Asar

Re: more than Max Number of concurrent users

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Usman

There is an issue. If there was additional information coded in to the hyperlink you've provided, that is not good. moodle.org is reasonably tolerant on self-advertising but such a "coupen" is intransparant. If there is commercial interest the best thing is to state it clearly. You can mention your affiliations, etc. in the profile and place a short hint in the post. "Transparency" is the catch word!
In reply to Visvanath Ratnaweera

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers

Visvanath, I have just fired up my domain after this, writing the self experience of all the web hosting companies (as in shared hosts) that I have tested with Moodle and why I recommend them, so from next time, I'll rather give out that link in forums than affiliate links. wink

In reply to Howard Miller

Re: more than Max Number of concurrent users

by James McLean -

Spam is defined an unsolicited message, usually advertising, not requested by the user it was directed at.

OP asked why he was having an issue - I point out I actually posted the first reply with what is likely the answer to the issue - note the OP didn't say "can you please suggest a better hosting provider".

Next reply included a marketing driven blurb full of buzzwords containing a link with an affiliate ID. The user who posted the link will directly benefit from any sign up with this link. This is low and underhanded in my opinion, and only designed to take advantage of people who may not understand what the intention of the link is.

My threshold for unsolicited marketing is very very low. 

This is text book SPAM.

In reply to James McLean

Re: more than Max Number of concurrent users

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

OK, noted. Let's draw a line shall we?

I have asked Usman, off line, to cool it a little and he has happily agreed. No fights please smile

In reply to Usman Asar

Re: more than Max Number of concurrent users

by Alan Kmiecik -

Usman,

How about a little detail on why you recommend?

eg.  Hostmonster:  has performed well with one Moodle instance on their intro offering.  They have a limit on number of tables so you can do no more than two Moodle databases (don't know what performance would be like with two)

Hostgator: is doing well with one instance of Moodle.  Ran into a resource limitation but don't remember what it is.

Webhostinghub:  did not run well with Moodle 2.7 and PHP 5.5.  Major spikes in CPU utilization.  Problem on this hosting company because they will terminate you if you spike too much (this was with Theme Designer mode. I have to have Theme Designer mode)  Important note:  there are settings (I think) that will help this spike but does not look like Webhostinghub will allow me to tweak them.

THIS IS THE KEY we need to clarify which hosting company (and which level of service) enable us to capitalize on the Web Server Performance recommendations.

So, which hosting companies and which level of service enable things like APCPHPAXcacheWinCache or  eAccelerator and OPCache?  What other resources do the hosting companies (and level of service) provide and what should we be shooting for (is 1 CPU with 1G of memory enough, what about budget VPS on Windows vs. doing it on Linux))?

Hostwinds, based on chat I just finished, does not seem to enable the performance accelerators or opcache unless one pays for the VPS level.

Don't know what Hostmonster does but, by experience, it works (but I am looking for something new)


(not an affiliate with anybody yet but about ready to start my own hosting biz to provide this level of service)

In reply to Alan Kmiecik

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers

Alan,

There are few hosts that does opcache. Just to test out moodle I had spend money getting accounts with different providers to see which one can hold the Moodle installation stable.  I have used  opcache on CrocWeb, HosterPK, and stablehost as well confirmed they are doing that, but limitation with Croc and StableHost are size of discs they allocate per user account, whilst HostWinds dont impose limits but I have experienced their performance  matching or exceeding CrocWeb despite they don't have opcache enabled. if i have to say if I managed to get a real performance boost using opcache, that wasnt the case, but CRON jobs did showed usage of memory came down from 50MB (Without opcache) to 12MB (with opcache). Out of all Hosting I have used, HostWinds despite not using any opcache did out-performed every other I used.

If someone has a limited site with few GB of resources and limited visitors then using CrocWeb is good way to go, but for price-performance match HostWinds wins the option of choice.

Regarding Databases, every hosting limit the number of tables to 1000 on standard hosting packages, so you can expect about 2 moodle sites running on one shared account with every host, Business/Enterprise class hosting does though provide 2000-3000 tables limit.

I had used HostMonster before it was bought by EIG, the reason their servers hardware is brutal is because of each node made up of 8 x 16-Core AMD Opetron CPU's & 256Gig RAM with RAID-10 64 Terabyte drives, therefore their allocation of resources to each account may be more than what others are providing, consider if they have to use LiteSpeed servers rather than Apache, imagine the performance boost.

Havent tried HostGator, but still have Moodle hosted on TurnKeyInternet (Absolute failure), and Arvixe (Does works fine, but wont recommend) 

If you are starting hosting company, then first piece of advice, get commercial webserver LiteSpeed, as I have experienced loads of performance improvement on LiteSpeed hosts rather than Apache, and  All i recommended (Croc, HosterPK, StableHost, HostWinds & Wired Tree) have LiteSpeed or have ability to provide.

In reply to Usman Asar

Re: more than Max Number of concurrent users

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I know a lot of people favour LightSpeed but there are plenty of huge sites running on Apache as there are on nginx, lighttpd and such. 

Again, I'm concerned that the wrong impression is given. The problem is almost certainly down to lack of or poorly performing resources on your particular host. The exact choice of products is just varnish. You can even make Moodle run on Windows if you throw enough hardware at it wink

Average of ratings: Useful (1)
In reply to Howard Miller

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers

Lighttpd ("Lighty") is finished no support  or new versions coming out, Large corporates use Engine-X ("nginx") and I have seen Moodle performing on it very well as well on Apache (Host monster still uses Apache with Brutal Hardware), The only reason LiteSpeed is getting more of attention is because even the non-commercial version of LiteSpeed has surpassed performance in Static (Both Keep Alive & No-Keep Alive) and PHP tests when compared to Apache and nginx.

Its just because LiteSpeed Enterprise version requires licensing per CPU Core, so people may rather be adding more to RAM/Faster Discs than getting Piece of Software.

In reply to Usman Asar

Re: more than Max Number of concurrent users

by Colin Peters -

Thanks Usman,

We moved to this host about a year ago and hadn't had any bother until now.  It may be that we are now shared with another user with high intensity.  If the suggestion that James puts forward is unsuccessful then I might try somewhere else however I think it will be challenging to make a useful comparison when my interpretation of perspective.php seems to suggest that our current host should meet our needs?

While I won't enter the debate re the pros and cons of specific hosts and the whys and wherefores of moderation and affiliation I would like to thank you for commenting.

Regards

Colin

In reply to Colin Peters

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers
Colin, in this case look out for a host on Cloud Linux, as that tends to keep resources allocated to every user up to their limit, should one user abuses the resource, its only their account gets throttled whilst others remain unaffected.
In reply to Usman Asar

Re: more than Max Number of concurrent users

by Colin Peters -

The dbpersist change to 'true' this evening still managed to disconnect  a chat with only 6 users and no-one else on the site.  Looks like I'll need to try a different host.


Colin

In reply to Colin Peters

Re: more than Max Number of concurrent users

by Usman Asar -
Picture of Plugin developers Picture of Testers
Colin, chat session takes out loads of resources, and I doubt any shared host will do that for more than 10 users. You're looking at Hybrid solution to start with, else see if there are plug-ins available that could include external chat client in moodle taking off load off of your moodle.
In reply to Colin Peters

Re: more than Max Number of concurrent users

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I would be even more radical - don't use chat on Moodle. It's not well supported. Unless anybody knows differently, it hasn't had any significant development in years. There are many better solutions around these days.

In reply to Howard Miller

Re: more than Max Number of concurrent users

by Colin Peters -

Thanks Howard. There's a general desire from the faculty to have the synchronous discussion integrated with the course. Skype is an obvious alternative but I wonder if there are any other offerings which work well with moodle, eg can review the chat if you weren't online at the time?  

(Appreciate we are getting away from hardware and performance here)

Colin 

In reply to Colin Peters

Re: more than Max Number of concurrent users

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I've not found anything that isn't without its problems. BigBlueButton is ok and you can do recordings. There's no option for deleting them again (at the moment) which is a bit rubbish.