Skocz do zawartości
Zaloguj się, aby obserwować  
Wielki Ktoś

apache 2.2.9 + php5 + mysql [optymalizacja]

Polecane posty

witam,

może ktoś pomóc mi zoptymalizować to cudo ;)?

 

2x1.9 athlon

2gb ram

 

siedzi na tym aplikacja online, 3000 uq, po 30-50 osób cały czas na www.

korzystam głównie z php,mysql,rewrite i to wszystko.

 

jak to jakoś zoptymalziować?

po jednym dniu ram jest zajmowany w ~95 %, przez pierwsze kilka godzin jest okej :).

 

Co muszę wam podać?

proszę o pomoc - dzięki z góry!

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

1. raczej odpada, bo ile to roboty znowu? :)

2. skrypt jest optymalny :)

3. zrobione ;]

4. zrobione ;] i zrobione ;]

 

i

/etc/init.d/mysql restart

:D)

 

---

 

Dodam, że Load Average jest na poziomie ~6.50 w górę

to jest php + xcache

Udostępnij ten post


Link to postu
Udostępnij na innych stronach
Gość N3T5kY

1. Jak zmieni na nginxa czy lighttpd czeka go rekonfiguracja rewrite-u.

2. Jaki przeznaczyłeś cache na xcache?

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Może Litespeed standard, w limiecie 100 połączeń równoczesnych powinieneś jeszcze się wyrabiać, a i migracja będzie dosyć bezproblemowa.

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Nie wiem czy chciałbym korzystać z migracji ;(.

 

Oto wyniki TUNING-PRIMER.SH:

               -- MYSQL PERFORMANCE TUNING PRIMER --
            - By: Matthew Montgomery -

MySQL Version 5.0.51a-24+lenny1 i486

Uptime = 0 days 10 hrs 54 min 45 sec
Avg. qps = 27
Total Questions = 1089185
Threads Connected = 3

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:
[url="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html"]http://dev.mysql.com/doc/refman/5.0/en/ser...-variables.html[/url]
Visit [url="http://www.mysql.com/products/enterprise/advisors.html"]http://www.mysql.com/products/enterprise/advisors.html[/url]
for info about MySQL's Enterprise Monitoring and Advisory Service

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

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See [url="http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html"]http://dev.mysql.com/doc/refman/5.0/en/poi...e-recovery.html[/url]

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

MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 3
Historic max_used_connections = 15
The number of used connections is 15% of the configured maximum.
Your max_connections variable seems to be fine.

MEMORY USAGE
Max Memory Ever Allocated : 182 M
Configured Max Per-thread Buffers : 299 M
Configured Max Global Buffers : 138 M
Configured Max Memory Limit : 437 M
Physical Memory : 1.84 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 3 M
Current key_buffer_size = 64 M
Key cache miss rate is 1 : 277
Key buffer free ratio = 85 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 5 M
Current query_cache_limit = 5 M
Current Query cache Memory fill ratio = 7.83 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 132.00 K
You have had 1 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
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 132 tables
You have 64 open tables.
Current table_cache hit rate is 2%, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 1302 temp tables, 50% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 670 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 149
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.

root@r20021:~# root@r20021:~# vim /etc/mysql/my.cnf
-bash: root@r20021:~#: command not found
root@r20021:~# root@r20021:~# vim /etc/mysql/my.cnf
-bash: root@r20021:~#: command not found
root@r20021:~# vim /etc/mysql/my.cnf
root@r20021:~# ./tuning-primer.sh

       -- MYSQL PERFORMANCE TUNING PRIMER --
            - By: Matthew Montgomery -

MySQL Version 5.0.51a-24+lenny1 i486

Uptime = 0 days 10 hrs 58 min 9 sec
Avg. qps = 28
Total Questions = 1107551
Threads Connected = 2

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:
[url="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html"]http://dev.mysql.com/doc/refman/5.0/en/ser...-variables.html[/url]
Visit [url="http://www.mysql.com/products/enterprise/advisors.html"]http://www.mysql.com/products/enterprise/advisors.html[/url]
for info about MySQL's Enterprise Monitoring and Advisory Service

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

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See [url="http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html"]http://dev.mysql.com/doc/refman/5.0/en/poi...e-recovery.html[/url]

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

MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 3
Historic max_used_connections = 15
The number of used connections is 15% of the configured maximum.
Your max_connections variable seems to be fine.

MEMORY USAGE
Max Memory Ever Allocated : 182 M
Configured Max Per-thread Buffers : 299 M
Configured Max Global Buffers : 138 M
Configured Max Memory Limit : 437 M
Physical Memory : 1.84 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 3 M
Current key_buffer_size = 64 M
Key cache miss rate is 1 : 272
Key buffer free ratio = 87 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 5 M
Current query_cache_limit = 5 M
Current Query cache Memory fill ratio = 8.21 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 132.00 K
You have had 1 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
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 132 tables
You have 64 open tables.
Current table_cache hit rate is 2%, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 1451 temp tables, 50% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 671 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 147
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.

 

 

Co mógłbym teraz pozmieniać?

Udostępnij ten post


Link to postu
Udostępnij na innych stronach
Gość N3T5kY
a i migracja będzie dosyć bezproblemowa.

 

Jeśli mało vHostów to tak.

Udostępnij ten post


Link to postu
Udostępnij na innych stronach
Jeśli mało vHostów to tak.

Mowa była o jednej aplikacji :D więc była by bezproblemowa.

A jeśli więcej vhostów, to trzeba trochę poklikać, albo też i pokopiować co nieco :)

 

 

PS: Wielki Ktosiu, jesteś pewien, że takie obciążenie generuje właśnie MySQL?

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Mógłby ktoś pomóc co do tego tuning-primer.sh? co jak i w ogóle? Dziękuję.

 

I jeszcze jedno:

 

top - 12:06:15 up 12:31, 1 user, load average: 2.19, 2.08, 1.85

Tasks: 129 total, 3 running, 126 sleeping, 0 stopped, 0 zombie

Cpu(s): 13.6%us, 2.6%sy, 0.0%ni, 69.9%id, 11.9%wa, 1.8%hi, 0.2%si, 0.0%st

Mem: 1938148k total, 1856728k used, 81420k free, 65044k buffers

Swap: 1955800k total, 56k used, 1955744k free, 1599436k cached

 

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

17766 mysql 20 0 159m 29m 4752 S 10 1.6 11:26.57 mysqld

18939 www-data 20 0 51088 11m 6948 S 3 0.6 0:00.58 apache2

18987 www-data 20 0 51176 9.8m 5592 S 3 0.5 0:00.12 apache2

18936 www-data 20 0 51612 10m 6292 S 3 0.6 0:00.54 apache2

18937 www-data 20 0 51136 10m 6544 S 1 0.6 0:00.54 apache2

18941 www-data 20 0 51612 10m 5852 S 1 0.6 0:00.38 apache2

18944 www-data 20 0 51352 10m 6368 S 1 0.6 0:00.24 apache2

18862 www-data 20 0 51376 10m 6152 S 1 0.6 0:00.70 apache2

18864 www-data 20 0 51936 12m 8028 R 1 0.7 0:00.92 apache2

18865 www-data 20 0 51320 10m 6336 S 1 0.6 0:00.62 apache2

18866 www-data 20 0 51256 10m 6472 S 1 0.6 0:00.72 apache2

18933 www-data 20 0 51368 10m 6516 S 1 0.6 0:00.50 apache2

18945 www-data 20 0 51176 10m 6336 S 1 0.6 0:00.38 apache2

18946 www-data 20 0 51496 10m 5612 S 1 0.5 0:00.22 apache2

18948 www-data 20 0 51168 8316 3984 S 1 0.4 0:00.12 apache2

18983 www-data 20 0 51432 8376 3768 S 1 0.4 0:00.06 apache2

18986 www-data 20 0 51148 7896 3564 S 1 0.4 0:00.06 apache2

18988 www-data 20 0 51040 7372 3220 S 1 0.4 0:00.04 apache2

18989 www-data 20 0 51040 7240 3140 S 1 0.4 0:00.02 apache2

18990 www-data 20 0 51192 7828 3548 S 1 0.4 0:00.04 apache2

1 root 20 0 2092 680 584 S 0 0.0 0:01.26 init

2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd

3 root RT -5 0 0 0 S 0 0.0 0:00.00 migration/0

4 root 15 -5 0 0 0 S 0 0.0 0:09.74 ksoftirqd/0

5 root RT -5 0 0 0 S 0 0.0 0:00.00 migration/1

6 root 15 -5 0 0 0 S 0 0.0 0:03.30 ksoftirqd/1

7 root 15 -5 0 0 0 S 0 0.0 0:01.42 events/0

8 root 15 -5 0 0 0 S 0 0.0 0:01.38 events/1

9 root 15 -5 0 0 0 S 0 0.0 0:00.00 khelper

114 root 15 -5 0 0 0 S 0 0.0 0:00.00 kintegrityd/0

115 root 15 -5 0 0 0 S 0 0.0 0:00.00 kintegrityd/1

116 root 15 -5 0 0 0 S 0 0.0 0:00.08 kblockd/0

117 root 15 -5 0 0 0 S 0 0.0 0:00.06 kblockd/1

118 root 15 -5 0 0 0 S 0 0.0 0:00.00 kacpid

119 root 15 -5 0 0 0 S 0 0.0 0:00.00 kacpi_notify

219 root 15 -5 0 0 0 S 0 0.0 0:00.00 ata/0

220 root 15 -5 0 0 0 S 0 0.0 0:00.00 ata/1

221 root 15 -5 0 0 0 S 0 0.0 0:00.00 ata_aux

222 root 15 -5 0 0 0 S 0 0.0 0:00.00 ksuspend_usbd

227 root 15 -5 0 0 0 S 0 0.0 0:00.00 khubd

230 root 15 -5 0 0 0 S 0 0.0 0:00.00 kseriod

282 root 20 0 0 0 0 S 0 0.0 0:00.00 pdflush

283 root 20 0 0 0 0 S 0 0.0 0:01.14 pdflush

284 root 15 -5 0 0 0 S 0 0.0 0:00.18 kswapd0

285 root 15 -5 0 0 0 S 0 0.0 0:00.00 aio/0

286 root 15 -5 0 0 0 S 0 0.0 0:00.00 aio/1

289 root 15 -5 0 0 0 S 0 0.0 0:00.04 nfsiod

290 root 15 -5 0 0 0 S 0 0.0 0:00.00 cifsoplockd

291 root 15 -5 0 0 0 S 0 0.0 0:00.00 cifsdnotifyd

293 root 15 -5 0 0 0 S 0 0.0 0:00.00 xfs_mru_cache

294 root 15 -5 0 0 0 S 0 0.0 0:00.00 xfslogd/0

 

 

stan z przed chwili. Co tutaj zrobić? Ram się zawala przez noc cały, 2GB.

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Generalnie to odczekaj 48h od odpalenia bazy danych i zmień w konfiguracji to, co radzi tuning-primer i mysqltuner. :D

Udostępnij ten post


Link to postu
Udostępnij na innych stronach

Bądź aktywny! Zaloguj się lub utwórz konto

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Utwórz konto

Zarejestruj nowe konto, to proste!

Zarejestruj nowe konto

Zaloguj się

Posiadasz własne konto? Użyj go!

Zaloguj się

Zaloguj się, aby obserwować  

×