----- Original Message -----
From: "Bryce C" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 10, 2002 7:14 AM
Subject: resetting mysql server "gently"

Bryce wrote:

BC> I have a script that runs every minute to deterimine
BC> if the load is above a certain value (or if swap is
BC> high) and if so, it kills all the httpd processes,

That is the Wrong Way (tm). You should not be killing off processes.
Instead, you should not let them come to life. Several appropriate Apache
directives leap to mind: MinSpareServers, MaxSpareServers, MaxClients. And
to fine-tune it even further: KeepAlive, MaxKeepAliveRequests,
KeepAliveTimeout. Just to name a few.

BC> does /etc/rc.d/init.d/mysql stop

Killing off processes, even threads you got by iterating over the
processlist, is simply a very bad idea. Far worse even than with Apache.
Because killing the HTTP daemon, while sloppy, is relatively harmless. But
killing off MySQL threads is a sure ticket to corrupting your database.

> Bottom line - killing off httpd is not too bad since
> users see a temporary glitch, but killing mysql seems
> to give a lot problems - scripts don't like to have
> the mysql server suddenly go away.

You said it. :) So, don't do that.

> Is there a gentler way that I can "reset" mysql?

No. There is nothing gentle about resetting MySQL. Programs like sendmail
come with excellent built-in directives to deal with high load
(ConnectionRateThrottle, QueueLA, RefuseLA, and such). Maybe one day MySQL
will support these too?

You could "nice" the mysqld process, if it really takes that much CPU load.
But that is, in itself, something you need to investigate. I run an entire
news server on MySql, and the CPU load still does not exceed a few
percent -- and that only at peaks.

You could also take a more inventive approach. :) Off the top of my hat, if
you run mysql on TCP, run mysqld on a different port, say, 9000, and call it
"custom_mysql" in /etc/services. Then configure xinetd to redirect to port
3306. That gives you the advantage that you can use xinetd's
"throttle-control". On my server that would look like something like this:

service custom_mysql
{
 log_type    = FILE /var/log/mysql_xinetd.log
 log_on_success = HOST
 flags       = REUSE
 cps         = 3 5
 per_source  = 5
 max_load    = 2.5
 socket_type = stream
 protocol    = tcp
 wait        = no
 user        = root
 redirect    = 127.0.0.1 3306
}

"max_load" is platform dependent, though. I have not tested the xinetd
option yet, but I see no reason this should not work.

- Mark

        System Administrator Asarian-host.org

---
"If you were supposed to understand it,
we wouldn't call it code." - FedEx


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to