Is there a way to limit the number of online users for a moodle site?

Is there a way to limit the number of online users for a moodle site?

by Frankle Lee 李智高 -
Number of replies: 10

Hi, everyone, I am now using moodle 2.6.

Due to my server compacity, I really like to limit the online user number so that I can guarantee my user experience.

I hope there is a plugin or any other ways to check the online user number and the when it meets my limitation, moodle will automatically refuse the next user to login.

Any suggestion?

By the way, I know the online user block, it doesn't meet my need.

Average of ratings: -
In reply to Frankle Lee 李智高

回复: Is there a way to limit the number of online users for a moodle site?

by Frankle Lee 李智高 -

Is this not the right place to ask this question?

Any suggestion where I should give a shot?

In reply to Frankle Lee 李智高

Re: 回复: Is there a way to limit the number of online users for a moodle site?

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I think the location is fine. Probably no one has answered because no one knows how to do what you are asking.

In reply to AL Rachels

Re: 回复: Is there a way to limit the number of online users for a moodle site?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
There were two similar discussion:
- "limiting number of concurrent users Moodle 1.9.9+"
https://moodle.org/mod/forum/discuss.php?d=192787
No conclusion.

- "Limit number of users logged in moodle."
https://moodle.org/mod/forum/discuss.php?d=156510
Apparently all you need is a "(quite simple) core hack".
wink

P.S. I would say, this topic touches "Hardware and performance".
Average of ratings: Useful (1)
In reply to Frankle Lee 李智高

Re: Is there a way to limit the number of online users for a moodle site?

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers

You didn't provide any details about your server, so I'm guessing...

You could write a plugin that checks how many users are already logged in whenever a user tries to login. If the number of logged in users is greater than the number of users that you want to allow then redirect the user to a "site is too busy page". But that would create a really bad user experience. Users don't care how busy the server is and they shouldn't be denied access to Moodle just because the server is too busy.

But if you want to persist with this...

In IIS you can set the "Connections limited to" setting on the Performance tab to your preferred value - the max number of users you want to allow. I'm not sure if you can do that in Apache...

Using an F5 load balancer you could:

  • Count the number of post request that you get from the Moodle login page.
  • Delay user logins if the logins per second is above your first limit.
  • Send users to a maintenance page if logins per second is above your second limit, i.e. the site is really busy.

But the better solution is that if you think you are going to have more users than your existing server can handle then you need to look at upgrading your server/hosting solution, e.g. move your Moodle into some kind of server farm environment where there are enough web servers to handle the number of users that you are expecting. If any of the individual servers in the farm goes down at any time then the users will not be affected - their requests will simply get redirected to another server in the farm.

What you should really focus on first is fine tuning the server and the Moodle and PHP settings so that you get maximum performance out of that server, e.g. by setting the various Moodle, PHP and server caches optimally (MUC in Moodle, OPCache in PHP, Memcached for session management, etc.)

Hope that helps...

Average of ratings: Useful (1)
In reply to Luis de Vasconcelos

Re: Is there a way to limit the number of online users for a moodle site?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Or limit access to the most resource intensive activities (e.g. quiz)

Average of ratings: Useful (1)
In reply to Luis de Vasconcelos

回复: Re: Is there a way to limit the number of online users for a moodle site?

by Frankle Lee 李智高 -

Thanks for your reply. Of course upgrading the server should be a better way, but it exceeds my budget.

I guess there is not simple solution such as a plugin yet.

I wonder how the offical moodle cloud service could limit the 50 users for free account? A modified version of moodle?

 

https://moodle.com/cloud/

 

————————————————————————

Designed for smaller users

We’ve targeted the system towards small users of Moodle: very small schools or companies, or lone teachers with a few classes, or just anyone who wants a Moodle to experiment with.

Your database size is unlimited (which means unlimited text pages, posts, and activities). You can also customise the look of your own site via the web with our custom MoodleCloud theme, based on the standard More theme.

To keep things manageable our sites do have some limits:

  • 50 users maximum.
  • 200Mb disk space
  • Core themes and plugins only
  • One site per phone number

If you need more than this, however, just see one of our friendly Moodle Partners.

In reply to Frankle Lee 李智高

Re: 回复: Re: Is there a way to limit the number of online users for a moodle site?

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

Moodle Cloud (as far as I know) restricts the number of accounts. Which is a different thing from what you are asking (and a pretty simple modification). 


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

回复: Re: 回复: Re: Is there a way to limit the number of online users for a moodle site?

by Frankle Lee 李智高 -

OK, I got it.

Yes, it is different from what I need.

I prefer more users from different schools, but I hope they don't login all at the same time.

If the school think they need more online users, I will recommend them to build their own platform.

In reply to Frankle Lee 李智高

Re: 回复: Re: 回复: Re: Is there a way to limit the number of online users for a moodle site?

by Doug Moody -

Frankie,

This is a cumbersome suggestion, but it would work.

Why not devise a way for the users you expect to first have to ask for a code that would give them access to your moodle (maybe using a signup service). Then write a script that creates the code and emails them the access code, but stops at 50.

In other words, a limited time code.

Then, in moodle, have activities or access that times out after x amount of time or accesses. You might have to then run a cron script that removes all users every day.

This is just a weird workaround, I know, but if you only need a temporary solution for demo purposes, you could watch it  closely and see how things work and adjust on the fly!