Apache lahmt

nolimitek

Registered User
Hi alle zusammen
Mein Apache und Mysql lahmen ein wenig
Hab mal tuning primer script lauffen lassen
Das kommt dann rauß
HTML:
-- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -

MySQL Version 4.0.24_Debian-10sarge2-log  is EOL please upgrade to MySQL 4.1 or later

/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Uptime =  days  hrs  min  sec
Avg. qps = 48
Total Questions = 71057
Threads Connected = 1

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html

SLOW QUERIES
Current long_query_time = 10 sec.
You have 0 out of 71069 that take longer than 10 sec. to complete
The slow query log is NOT enabled.
Your long_query_time may be too high, I typically set this under 5 sec.

WORKER THREADS
Current thread_cache_size = 0
Current threads_cached = 0
Current threads_per_sec = 1
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 1
Historic max_used_connections = 8
The number of used connections is 8% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating

MEMORY USAGE
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1150: [: -gt: unary operator expected
/usr/bin/tuning-primer.sh: line 344: [: max_memoryHR: integer expression expected
/usr/bin/tuning-primer.sh: line 350: [: max_memoryHR: integer expression expected
/usr/bin/tuning-primer.sh: line 356: [: max_memoryHR: integer expression expected
/usr/bin/tuning-primer.sh: line 363: export: `0=max_memoryHR': not a valid identifier
Max Memory Ever Allocated :  bytes
/usr/bin/tuning-primer.sh: line 344: [: per_thread_buffersHR: integer expression expected
/usr/bin/tuning-primer.sh: line 350: [: per_thread_buffersHR: integer expression expected
/usr/bin/tuning-primer.sh: line 356: [: per_thread_buffersHR: integer expression expected
/usr/bin/tuning-primer.sh: line 363: export: `0=per_thread_buffersHR': not a valid identifier
Configured Max Per-thread Buffers :  bytes
/usr/bin/tuning-primer.sh: line 344: [: global_buffersHR: integer expression expected
/usr/bin/tuning-primer.sh: line 350: [: global_buffersHR: integer expression expected
/usr/bin/tuning-primer.sh: line 356: [: global_buffersHR: integer expression expected
/usr/bin/tuning-primer.sh: line 363: export: `0=global_buffersHR': not a valid identifier
Configured Max Global Buffers :  bytes
/usr/bin/tuning-primer.sh: line 344: [: total_memoryHR: integer expression expected
/usr/bin/tuning-primer.sh: line 350: [: total_memoryHR: integer expression expected
/usr/bin/tuning-primer.sh: line 356: [: total_memoryHR: integer expression expected
/usr/bin/tuning-primer.sh: line 363: export: `0=total_memoryHR': not a valid identifier
Configured Max Memory Limit :  bytes
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Total System Memory :  G
Max memory limit seem to be within acceptable norms

KEY BUFFER
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current MyISAM index space =  M
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current key_buffer_size =  M
Key cache miss rate is 1 : 1895
Key buffer fill ratio = Unknown %
Your key_buffer_size seems to be fine

QUERY CACHE
/usr/bin/tuning-primer.sh: line 1: bc: command not found
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Query cache is enabled
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current query_cache_size =  M
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current query_cache_used =  M
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current query_cach_limit =  M
Current Query cache fill ratio =  %
/usr/bin/tuning-primer.sh: line 661: [: -le: unary operator expected
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current sort_buffer_size =  M
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current record/read_rnd_buffer_size =  K
Sort buffer seems to be fine

JOINS
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current join_buffer_size =  K
You have had 128 queries where a join could not use an index properly
You should enable "log-long-format"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.

Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.

OPEN FILES LIMIT
Current open_files_limit = 1024 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_cache value = 64 tables
You have a total of 470 tables
You have 64 open tables.
Current table_cache hit rate is 9%, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current max_heap_table_size =  M
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current tmp_table_size =  M
Of 596 temp tables, 21% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine

TABLE SCANS
/usr/bin/tuning-primer.sh: line 1: bc: command not found
Current read_buffer_size =  K
Current table scan ratio = 887 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 5966
Your table locking seems to be fine

Könnt ihr mir bitte mal ein wenig helfen was ich alles ändern soll

Die Kiste ist ein RootDS mit 1,5 GHZ und 1GB Ram

gruß Chris
 
Wie man sieht, sieht man nichts!
Zuviele Fehler die das tuning-primer-script ausspuckt.
Bring das erstmal zum laufen.

(Unter uns gesagt: Das Script taugt grundsätzlich nicht viel.)

Schau Dir lieber mal Deine Apache-Tunings an und vor allem Deine Speicher-Auslastung über die Zeit.

Und für uns alle: Definier "Apache und Mysql lahmen ein wenig" um ca 400% genauer.

huschi.
 
Ich hänge mal meine my.cnf und die apache2.conf hier an

Mit lahmt meine ich das die Anfrage zu lange dauert kommt mir vor
Heute morgen hatte ich dann in der apache error log den Fehler
HTML:
server reached MaxClients setting, consider raising the MaxClients setting


HTML:
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "/var/lib/mysql/my.cnf" to set server-specific options or
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port		= 3306
socket		= /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket		= /var/run/mysqld/mysqld.sock
nice		= 0

[mysqld]
#
# * Basic Settings
#
user		= mysql
pid-file	= /var/run/mysqld/mysqld.pid
socket		= /var/run/mysqld/mysqld.sock
port		= 3306
basedir		= /usr
datadir		= /var/lib/mysql
tmpdir		= /tmp
language	= /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer		= 16M
max_allowed_packet	= 16M
thread_stack		= 128K
#
# * Query Cache Configuration
#
query_cache_limit	= 1048576
query_cache_size        = 16777216
query_cache_type        = 1
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#log		= /var/log/mysql.log
#log		= /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement :)
#
# Here you can see queries with especially long duration
#log-slow-queries	= /var/log/mysql/mysql-slow.log
#
# The following can be used as easy to replay backup logs or for replication.
#server-id		= 1
log-bin			= /var/log/mysql/mysql-bin.log
# See /etc/mysql/debian-log-rotate.conf for the number of files kept.
max_binlog_size		= 104857600
#binlog-do-db		= include_database_name
#binlog-ignore-db	= include_database_name
#
# * BerkeleyDB
#
# The use of BerkeleyDB is now discouraged and support for it will probably
# cease in the next versions.
skip-bdb
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Feature
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# If you want to enable SSL support (recommended) read the manual or my
# HOWTO in /usr/share/doc/mysql-server/SSL-MINI-HOWTO.txt.gz
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet	= 16M

[mysql]
#no-auto-rehash	# faster start of mysql but no tab completition

[isamchk]
key_buffer		= 16M

HTML:
PidFile /var/run/apache2.pid

# Timeout: The number of seconds before receives and sends time out.

Timeout 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.

KeepAlive Off

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.

KeepAliveTimeout 15

##
## Server-Pool Size Regulation (MPM specific)
## 

# prefork MPM
# StartServers ......... number of server processes to start
# MinSpareServers ...... minimum number of server processes which are kept spare
# MaxSpareServers ...... maximum number of server processes which are kept spare
# MaxClients ........... maximum number of server processes allowed to start
# MaxRequestsPerChild .. maximum number of requests a server process serves
<IfModule prefork.c>
StartServers         5
MinSpareServers      5
MaxSpareServers     10
MaxClients          50
MaxRequestsPerChild  0
</IfModule>

# pthread MPM
# StartServers ......... initial  number of server processes to start
# MaxClients ........... maximum  number of server processes allowed to start
# MinSpareThreads ...... minimum  number of worker threads which are kept spare
# MaxSpareThreads ...... maximum  number of worker threads which are kept spare
# ThreadsPerChild ...... constant number of worker threads in each server process
# MaxRequestsPerChild .. maximum  number of requests a server process serves
<IfModule worker.c>
StartServers         2
MaxClients         300 
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

# perchild MPM
# NumServers ........... constant number of server processes
# StartThreads ......... initial  number of worker threads in each server process
# MinSpareThreads ...... minimum  number of worker threads which are kept spare
# MaxSpareThreads ...... maximum  number of worker threads which are kept spare
# MaxThreadsPerChild ... maximum  number of worker threads in each server process
# MaxRequestsPerChild .. maximum  number of connections per server process (then it dies)
<IfModule perchild.c>
NumServers           5
StartThreads         5
MinSpareThreads      5
MaxSpareThreads     10
MaxThreadsPerChild  20
MaxRequestsPerChild  0
AcceptMutex fcntl
</IfModule>

User www-data
Group www-data
Aber wäre super wenn ich euch das mal kurz angucken könntet

vielen vielen dank im voraus

grüße Chris
 
Last edited by a moderator:
Er sagt Dir ja, was Du machen mußt.
Die Frage ist immer: Gibt das Dein Speicher auch her?

Ansonsten probier mal mit den Parametern rum:
"KeepAlive On" mit Timeout von 1 oder 2 Sekunden.
Erhöhe MaxClients in kleinen Schritten und setze MaxRequestsPerChild auf einen Wert um die 1-3 Tausend.

Zusätzlich aktivier mal mod_status und beobachte es gerade in Zeiten hoher Auslastung.
Beobachte auch Deine Speicherauslastung über die Zeit. (z.B. mit MRTG, rrdtools, etc.)
Achte darauf, daß er nicht anfängt unnötig zu swappen.

Jede Änderung muß mind. 24 Stunden beobachtet werden!!!

huschi.
 
>50 MaxClients wirst du nicht haben so wie ich das sehe. Teste mal
Code:
Timeout 30
KeepAlive On
MaxKeepAliveRequests 150
KeepAliveTimeout 2

<IfModule prefork.c>
StartServers       5
MinSpareServers    5
MaxSpareServers    10
ServerLimit       150
MaxClients        50
MaxRequestsPerChild  3000
</IfModule>

HostnameLookups off
und /etc/my.cnf
Code:
[mysqld]

[COLOR="Red"]# * Fine Tuning[/COLOR]
key_buffer = 32M
net_buffer_length = 8K

sort_buffer_size = 32K
myisam_sort_buffer_size = 32K
read_buffer_size = 16K
read_rnd_buffer_size = 512K
join_buffer_size = 512K

thread_cache = 32
table_cache = 1024
max_allowed_packet = 256K

max_connections = 50
low_priority_updates = 1
long_query_time = 2


[COLOR="Red"]# * Query Cache Configuration[/COLOR]
query_cache_size = 1M
... und deine MySQL Version ist etwas veraltet, daher auch die Errors mit tuning-primer.sh Script. Und poste mal ein
Code:
top

rechnen wir mal,

Apache 50 * 15 = 750 MB
MySQL (50 * (32 + 32 + 16 + 512)) + 32000 = 29,6 MB + 32 MB = 61,6 MB

So sollte das in etwa passen :D
 
Last edited by a moderator:
Änderungen wurden übernommen
Mal gucken wies läuft
Daknke auf alle Fälle

hier noch der Auszug von top

HTML:
top - 09:28:21 up 23:08,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  47 total,   1 running,  46 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.9% us,  0.3% sy,  0.0% ni, 98.6% id,  0.2% wa,  0.0% hi,  0.0% si
Mem:   1310720k total,   222044k used,  1088676k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      18   0  1592  520  452 S  0.0  0.0   0:00.10 init
 1950 root      15   0  1636  540  440 S  0.0  0.0   0:00.36 syslogd
 1957 bind      25   0 37868 2448 1628 S  0.0  0.2   0:00.00 named
 1966 postgrey  15   0 10104 7840 2592 S  0.0  0.6   0:00.72 postgrey
 1971 root      21   0  1756  384  316 S  0.0  0.0   0:00.00 courierlogger
 1972 root      15   0  1876  512  420 S  0.0  0.0   0:00.00 authdaemond.pla
 1973 root      18   0  2288  896  264 S  0.0  0.1   0:00.03 authdaemond.pla
 1974 root      16   0  2288  896  264 S  0.0  0.1   0:00.01 authdaemond.pla
 1975 root      17   0  2288  896  264 S  0.0  0.1   0:00.04 authdaemond.pla
 1976 root      17   0  2288  896  264 S  0.0  0.1   0:00.10 authdaemond.pla
 1979 root      15   0  2288  896  264 S  0.0  0.1   0:00.08 authdaemond.pla
 1984 root      18   0  1856  484  416 S  0.0  0.0   0:00.02 couriertcpd
 1986 root      18   0  1760  472  400 S  0.0  0.0   0:00.01 courierlogger
 1992 root      18   0  1860  488  416 S  0.0  0.0   0:00.00 couriertcpd
 1994 root      18   0  1756  468  400 S  0.0  0.0   0:00.00 courierlogger
 3219 root      15   0  3048 1176  988 S  0.0  0.1   0:00.40 master
 3221 postfix   18   0  3092 1276 1052 S  0.0  0.1   0:00.04 qmgr
 3231 root      18   0  3548  892  660 S  0.0  0.1   0:00.00 sshd
 3240 root      18   0  1580  384  316 S  0.0  0.0   0:00.00 vhcs2_daemon
 3247 nobody    18   0  4640 1288  604 S  0.0  0.1   0:00.00 proftpd
 3250 root      18   0  1824  740  604 S  0.0  0.1   0:00.00 cron
18091 postfix   15   0  5556 2380 1912 S  0.0  0.2   0:00.00 smtpd
18128 postfix   18   0  3580 1560 1268 S  0.0  0.1   0:00.00 trivial-rewrite
20313 postfix   17   0  5556 2372 1912 S  0.0  0.2   0:00.00 smtpd
21587 postfix   25   0  3056 1136  968 S  0.0  0.1   0:00.00 pickup
21849 postfix   15   0  5556 2380 1912 S  0.0  0.2   0:00.00 smtpd
23643 vmail     18   0  4044 1344 1140 S  0.0  0.1   0:00.00 imapd
23644 vmail     16   0  6040 3412 1156 S  0.0  0.3   0:00.13 imapd
23645 vmail     15   0  4572 1880 1156 S  0.0  0.1   0:00.03 imapd
23646 vmail     18   0  4688 2000 1156 S  0.0  0.2   0:00.04 imapd
23737 root      18   0 14684 1808 1436 S  0.0  0.1   0:00.00 sshd
23776 root      15   0  2668 1468 1152 S  0.0  0.1   0:00.00 bash
23831 root      18   0 14536 4700 3068 S  0.0  0.4   0:00.01 apache2
23832 www-data  18   0 17444 7772 3184 S  0.0  0.6   0:00.15 apache2
23833 www-data  20   0 18052 8464 3280 S  0.0  0.6   0:00.16 apache2
23834 www-data  21   0 14668 3048 1332 S  0.0  0.2   0:00.00 apache2
23835 www-data  21   0 14668 3048 1332 S  0.0  0.2   0:00.00 apache2
23836 www-data  19   0 14668 3048 1332 S  0.0  0.2   0:00.00 apache2
23917 root      25   0  2396 1116  912 S  0.0  0.1   0:00.00 mysqld_safe
23954 root      25   0  2396  548  344 S  0.0  0.0   0:00.00 mysqld_safe
23955 mysql     15   0  118m  18m 3316 S  0.0  1.5   0:00.42 mysqld
23956 root      18   0  1576  508  440 S  0.0  0.0   0:00.00 logger
24020 www-data  18   0 14668 3044 1332 S  0.0  0.2   0:00.00 apache2
24033 www-data  16   0 14536 2504  860 S  0.0  0.2   0:00.00 apache2
24036 www-data  15   0 14536 2504  860 S  0.0  0.2   0:00.00 apache2
24037 www-data  15   0 14536 2504  860 S  0.0  0.2   0:00.00 apache2
24099 root      15   0  2136  956  744 R  0.0  0.1   0:00.00 top

Huii das flutscht jetzt im Moment
Seitenaufbau bei 0,2 Sekunden

Hoffentlich bleibst so
Mals sehen wie er tut wenn mehr los ist
 
Last edited by a moderator:
saug dir vpsmem.sh Script und kopiere es in z.B. /usr/bin/vpsmem.sh

Hier kannst du auch noch lesen.

und
Hier, Tuning-Primer.sh Script

thread_cache = 32
table_cache = 1024

hab ich bei dir recht hoch gewählt weil du mit 1024 MB RAM ausreichend Speicher hast. Falls du den key_buffer erhöhen mußt und RAM knapp wird, würde ich thread_cache auf 16 oder 8 verkleinern und table_cache auf 512

Mein rootDS hat nur 256 MB RAM und ich mußte mich informieren um die Kiste zu optimieren. Nun benötige ich ~ 45% vom RAM und der Kleine läuft und läuft...

Änderung!
Code:
[mysqld]

[COLOR="Red"]# * Fine Tuning[/COLOR]
key_buffer = 32M
net_buffer_length = 8K

sort_buffer_size = 32K
myisam_sort_buffer_size = 32K
read_buffer_size = 16K
read_rnd_buffer_size = 512K
join_buffer_size = 512K

thread_cache = 32
table_cache = 1024
max_allowed_packet = 256K

max_connections = 50
[COLOR="Blue"]wait_timeout = 30[/COLOR]
low_priority_updates = 1
long_query_time = 2
wait_timeout hizugefügt!
 
Last edited by a moderator:
wait_timeout hizugefügt!
Achtung, diese Einstellung wirkt dem Vorteil der persistenten Verbindung von mod_php entgegen.
Bringt lediglich einen Speicher-Vorteil wenn man mehrere verschiedene und gut besuchte PHP-Projekte auf einem Server laufen hat. Aber dann sollte man eh mal über mehr Speicher für die Maschine nachdenken... :)

huschi.
 
Back
Top