4images Forum & Community
4images Issues / Ausgaben => Installation, Update & Configuration => Topic started by: Ruben on June 24, 2002, 10:57:20 PM
-
(http://www.wobpictures.com/inaction.jpg)
http://www.wobpictures.com
I go to PHPMyAdmin and check out the processes and there are like maybe 15 that are locked....seems like 4Images does sleeping processes that lasts for minutes !
Anyway I can fix this problem without having to restart mySQL twice an hour? My server's gonna die soon if I can't fix a solution for this...
Is there a way you can write like, or create a script that will shut the site off to certain people when it overloads the server and like, it redirects them to a special notice page instead ?
Thanks..
-Ruben
-
Hi,
try to put this at the top of your global.php:
$max_load = 5.00;
$path = "/proc/loadavg";
$buffer = "0 0 0";
$fp = @fopen($path, "r");
if (!@feof($fp)) {
$buffer = @fgets($fp, 1024);
}
@fclose($fp);
$load = explode(" ", $buffer);
$load_avg = max((float)$load[0], (float)$load[1], (float)$load[2]);
if ($load_avg > $max_load) {
header("Location: ./path/to/too_busy.html");
exit;
}
Hope this will help...
Greets Jan
-
Thank you, would that code go above the <?php or above
if (!defined('ROOT_PATH')) {
die("Security violation");
}
??
Thanks..
-Ruben
-
Below <?php
Greets Jan
-
Jan,
Thanks for the response.
Well, it's working, but it's constantly going over 5.00.
Is there a way that you could do something about this problem? It seems like if the software does not support high traffic sites?
I was talking to someone yesterday and he looked over the config.php and main.php and said how yoou didn't use something called "pconnect" or something like that?
I have to set the load to 10.00 so that the archive can be acceptable without it redirecting the users to the too_busy page all the time.
Like I said, the database locks a bunch of processes as well as works silently on them for a long long time...
Anyway you could offer support for high traffic websites in future releases of the software (although I would sorta need help now) so that it can run smoothly now matter how many pictures it has?
Thanks.
-Ruben
-
Hi,
if you want to use persistent database connections, change in global.php:
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
to:
$site_db = new Db($db_host, $db_user, $db_password, $db_name, 1);
Greets Jan
-
Another things you can do is to disable the random image which needs high performance:
in constans.php you can change this line:
Set:
define('SHOW_RANDOM_CAT_IMAGE', 1);
to:
define('SHOW_RANDOM_CAT_IMAGE', 0);
This wil disable the category related random images. Instead, a random image of the whole archive will be displayed.
You can also disable all random images, just set
define('SHOW_RANDOM_IMAGE', 1);
to:
define('SHOW_RANDOM_IMAGE', 0);
Greets Jan
-
Hi,
if you want to use persistent database connections, change in global.php:
Code:
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
to:
Code:
$site_db = new Db($db_host, $db_user, $db_password, $db_name, 1);
Greets Jan
Is it interesting for performance to use persisent connections in 4images ?