Большая нагрузка на сервер

12 3
T
На сайте с 02.10.2016
Offline
0
3759

День добрый.

Никак не могу победить нагрузку. Нагрузку тестирую siege'ом:

siege -c 350 -t30s http://сайт/

Загружает сильно apache2 и mysql. 100% загрузка проца. Статика отдается nginx'ом - все хорошо.

Оперативка максимум используется 5Гб из 64Гб

в логах apache2 и nginx ничего по ошибкам нет, а вот по mysql:

mysql error.log:


161002 14:46:24 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. $
161002 14:46:24 [Note] Plugin 'FEDERATED' is disabled.
161002 14:46:24 InnoDB: The InnoDB memory heap is disabled
161002 14:46:24 InnoDB: Mutexes and rw_locks use GCC atomic builtins
161002 14:46:24 InnoDB: Compressed tables use zlib 1.2.8
161002 14:46:24 InnoDB: Using Linux native AIO
161002 14:46:24 InnoDB: Initializing buffer pool, size = 128.0M
161002 14:46:24 InnoDB: Completed initialization of buffer pool
161002 14:46:24 InnoDB: highest supported file format is Barracuda.
161002 14:46:24 InnoDB: Waiting for the background threads to start
161002 14:46:25 InnoDB: 5.5.52 started; log sequence number 88439312
161002 14:46:25 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
161002 14:46:25 [Note] - '127.0.0.1' resolves to '127.0.0.1';
161002 14:46:25 [Note] Server socket created on IP: '127.0.0.1'.
161002 14:46:25 [Note] Event Scheduler: Loaded 0 events
161002 14:46:25 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.52-0ubuntu0.14.04.1-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)

mysqltuner.pl


[OK] NO SECURITY CVE FOUND FOR YOUR VERSION

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 21m 56s (454 q [0.345 qps], 154 conn, TX: 67K, RX: 31K)
[--] Reads / Writes: 100% / 0%
[--] Binary logging is disabled
[--] Physical Memory : 62.9G
[--] Max MySQL memory : 998.2M
[--] Other process memory: 229.9M
[--] Total buffers: 192.0M global + 2.7M per thread (300 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 194.7M (0.30% of installed RAM)
[OK] Maximum possible memory usage: 998.2M (1.55% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/454)
[OK] Highest usage of available connections: 0% (1/300)
[OK] Aborted connections: 0.00% (0/154)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[OK] No Sort requiring temporary tables
[OK] No joins without indexes
[OK] Temporary tables created on disk: 25% (54 on disk / 215 total)
[OK] Table cache hit rate: 95% (153 open / 160 opened)
[OK] Open file limit used: 18% (274/1K)
[OK] Table locks acquired immediately: 100% (174 immediate / 174 locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (3M used / 16M cache)
[!!] Key buffer size / total MyISAM indexes: 16.0M/31.0M

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is disabled.
[!!] InnoDB Storage engine is disabled. InnoDB is the default storage engine

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Add skip-innodb to MySQL configuration to disable InnoDB
1 user(s) used basic or weak password.
MySQL started within last 24 hours - recommendations may be inaccurate
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
Variables to adjust:
query_cache_type (=0)
key_buffer_size (> 31.0M)

Можете подсказать что?

S
На сайте с 23.05.2004
Offline
316
#1

Профилируйте саму страницу сайта для начала, что бы выяснить какие именно функции жрут больше всего ресурсов.

От этого уже и отталкиваться - давать больше памяти базе, увеличивать число процессов апача.

У вас может быть 10 записей в базе и пару сотен циклических запросов в нее. Или наоборот - 2 запроса с поиском по сотням тысяч не индексированных записей. Или вообще и поиск с перебором в скрипте.

В общем отталкиваться от сайта надо.

Это просто подпись.
T
На сайте с 02.10.2016
Offline
0
#2

В apache2 в error.log еще появилось вот что:


[Sun Oct 02 14:24:25.439957 2016] [mpm_prefork:notice] [pid 12659] AH00163: Apache/2.4.10 (Ubuntu) configured -- resuming normal operations
[Sun Oct 02 14:24:25.440071 2016] [core:notice] [pid 12659] AH00094: Command line: '/usr/sbin/apache2'
[Sun Oct 02 15:19:56.157850 2016] [mpm_prefork:error] [pid 12659] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Sun Oct 02 15:45:42.516825 2016] [mpm_prefork:notice] [pid 12659] AH00169: caught SIGTERM, shutting down
[Sun Oct 02 15:45:43.675760 2016] [mpm_prefork:notice] [pid 28108] AH00163: Apache/2.4.10 (Ubuntu) configured -- resuming normal operations
[Sun Oct 02 15:45:43.675840 2016] [core:notice] [pid 28108] AH00094: Command line: '/usr/sbin/apache2'

по mpm:


<IfModule mpm_prefork_module>
StartServers 10
MinSpareServers 10
MaxSpareServers 10
MaxRequestWorkers 250
MaxConnectionsPerChild 0
</IfModule>
Оптимизайка
На сайте с 11.03.2012
Offline
396
#3
tutochkin:
Нагрузку тестирую siege'ом:
siege -c 350 -t30s

350 concurrent users? 100% CPU load is OK in that case.

⭐ BotGuard (https://botguard.net) ⭐ — защита вашего сайта от вредоносных ботов, воровства контента, клонирования, спама и хакерских атак!
T
На сайте с 02.10.2016
Offline
0
#4
Оптимизайка:
350 concurrent users? 100% CPU load is OK in that case.

(i bad speak English) Hmm..i think not is OK, because another site can withstand the load. And load CPU 55-70%.

Оптимизайка
На сайте с 11.03.2012
Offline
396
#5
tutochkin:
i think not is OK, because another site can withstand the load

Does another site use some of caching features? Which CMS/engine/script is used on both sites?

T
На сайте с 02.10.2016
Offline
0
#6
Оптимизайка:
Does another site use some of caching features? Which CMS/engine/script is used on both sites?

1 site is used MODx evolution

2 site is used MODx revolution

This is sites are not mine, therefore i can not say now about caching.

Generally used caching nginx and memcached.

Оптимизайка
На сайте с 11.03.2012
Offline
396
#7

1. According to your Apache configuration, the real number of concurrent users are limited by 250 (MaxRequestWorkers). When you run Siege, additional concurrent users are queued, so increasing of this parameter will not help.

2. Even that amount of concurrent users can easily overload of single CPU (without proper caching).

3. So, if you need to serve that large amount of requests, you definitely should use caching for "read-only" users by configuring Nginx.

T
На сайте с 02.10.2016
Offline
0
#8
Оптимизайка:
1. According to your Apache configuration, the real number of concurrent users are limited by 250 (MaxRequestWorkers). When you run Siege, additional concurrent users are queued, so increasing of this parameter will not help.
2. Even that amount of concurrent users can easily overload of single CPU (without proper caching).
3. So, if you need to serve that large amount of requests, you definitely should use caching for "read-only" users by configuring Nginx.

How to make a "read-only" in configuring Nginx? Nginx now works as a reverse-proxy. Static files given to Nginx, php - Apache2.

LEOnidUKG
На сайте с 25.11.2006
Offline
1725
#9

Теперь для посещения сёрча нужно гугл переводчик использовать, весёлые вы ребятки.

✅ Мой Телеграм канал по SEO, оптимизации сайтов и серверов: https://t.me/leonidukgLIVE ✅ Качественное и рабочее размещение SEO статей СНГ и Бурж: https://getmanylinks.ru/
Оптимизайка
На сайте с 11.03.2012
Offline
396
#10
tutochkin:
How to make a "read-only" in configuring Nginx? Nginx now works as a reverse-proxy. Static files given to Nginx, php - Apache2.

By "read-only" users I've mean the sessionless users (i.e. unregistered ones). Most of CMS uses a cookie to distinguish registered users from unregistered ones, so you can use Nginx "out-of-box" caching like this:

https://habrahabr.ru/post/124684/

Unfortunately, MODx uses php session cookie for unregistered users too. So, you have to slightly modify MODx code to add another cookie that will set only for registered users.

12 3

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий