Author Topic: i wanna limit online user ! Couse my site getting slowly  (Read 10213 times)

0 Members and 1 Guest are viewing this topic.

Offline }{iJacK

  • Newbie
  • *
  • Posts: 46
    • View Profile
i wanna limit online user ! Couse my site getting slowly
« on: December 28, 2005, 04:41:34 AM »
is there any ways to limit online users?
i want to show " Just waiting a few minutes. Server is overloaded. "
message when my cpu is %90 up...


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #1 on: December 28, 2005, 08:20:31 AM »
and how would u detect how much CPU usage at a moment? :?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #2 on: December 28, 2005, 01:34:29 PM »
@V@no

With this:

Code: [Select]
$serverinfo = 0;
if($uptime = @exec("uptime")) {
     if(preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $match)) {
         $match[1] *= 100;
         $match[2] *= 100;
         $match[3] *= 100;

         $serverinfo = 1;
     }
}


echo "Server-Auslastung der letzten Minute: $match[1]% <br>"; //Zeigt die aktuelle Server-Auslastung
echo "Server-Auslastung der letzten 5 Minuten: $match[2]% <br>"; //Zeigt die Auslastung vor 15 Minuten
echo "Server-Auslastung der letzten 15 Minuten: $match[3]% <br>"; //Zeigt die Auslastung vor 30 Minuten

(o:

Offline }{iJacK

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #3 on: December 30, 2005, 02:35:58 AM »
where am i going to add this !

in index.php ?
if yes which place ?

could you explain ?

Sincerely

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #4 on: December 30, 2005, 10:51:20 PM »
that was only for V@no... (o:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #5 on: December 31, 2005, 12:53:03 AM »
Acidgod, do you know in what "mesurement" the CPU usage returned by "uptime" binary? I don't... and if use the method you showed, it would show sometimes 300% on my server - which is obviosly impossible. Wonder if you know..

@}{iJacK:
Lets try this first, see if you'd like it.
If server reached NN% CPU usage, let the current page request wait 1 second (sleep), then check again CPU usage, if its still too high, sleep for 1 more second, continue put the process to sleep unitll CPU usage droped, once its droped - continue executing the script.
This will endup slowing down opening pages, and will not return any error messages (unless ofcourse client (browser) get timeout, which hopefuly will not happend too often or at all.)
If you like this idea, I'll try do that using Acidgod's method.
In mean time, create a test.php file with the following content, upload it to your server and start it with the browser. See if it return any error messages, or some numbers.
Code: [Select]
<?php
echo exec("uptime");
?>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #6 on: December 31, 2005, 10:44:41 AM »
The Script shows the load averages of the Server...

Read this for more Informations:
http://en.wikipedia.org/wiki/Load_(computing)

And this:
http://www.teamquest.com/resources/gunther/ldavg1.shtml

And the load averages is a good thing for that...
But the Limit must over 200% and not 90%, on Linux Server the max Limit is not 100% and itīs varied on different Systems... (o:

Offline comicart

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #7 on: July 19, 2006, 08:41:35 PM »
I know this is an old thread but this is almost what I'm looking for.

I would LOVE a mod that will limit the number of *non-registered* users when loads are heavy.
For example, 200 total users allowed with (already logged in) *Registered* users given first priority, and a "we're too busy right now" message for non-registered users exceeding the 200 users mark.

Possible?

Terry

Offline comicart

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #8 on: August 14, 2006, 04:56:41 PM »
V@no, would it be possible to hire you for a mod like this?
I would share it with the community.

There are some alternatives...
Limit number of Users on the site at one time? (Instead of server load).

This thread has something similar but it looks like all users would have to be registered users:
http://www.4homepages.de/forum/index.php?topic=9170.0

Terry

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: i wanna limit online user ! Couse my site getting slowly
« Reply #9 on: August 17, 2006, 01:29:47 AM »
I belive I've posted somewhere the code for that...I'll try to find it, but no promises ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)