首页 > 解决方案 > Apache Intermittant Hang 是网络延迟吗?

问题描述

我在 Debian 机器上从 Apache 提供的 Web 应用程序出现间歇性延迟。Apache 和 MySQL 签出。我远未充分利用盒子 CPU/内存。仍然存在间歇性滞后。我的理论是需要调整网络速率限制。统计如下。

Apache 服务器状态

Current Time: Tuesday, 02-Jun-2020 14:36:53 EDT
Restart Time: Monday, 01-Jun-2020 01:00:03 EDT
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 1 day 13 hours 36 minutes 50 seconds
Server load: 2.95 3.23 3.09
Total accesses: 1213060 - Total Traffic: 22.0 GB - Total Duration: 32311929295
CPU Usage: u396.94 s164.31 cu2065.15 cs789.27 - 2.52% CPU load
8.96 requests/sec - 170.5 kB/second - 19.0 kB/request - 26636.7 ms/request
296 requests currently being processed, 66 idle workers

WR.WWWW.KWW_W._W_KWWWWWWKWWWWW_WWWWK_WK_WWW_WW_RWWWWWKCWWWWWW._W
_WW_R_W_.__K_WWWW__WWWWWWKKWWWWWWKWWWW_W____WWWWWWWW_WWW_KWWWWWW
WWWWWWWW_.WWWWWK_WWW_WWKWWWWWWKWWKWK_WWWWWRKWWW.WW_KKWKWWWKW_WWW
WW.W_.K._WWWK_WW_K_K._WW..WWWWWWW_.W_WWWW_W_W.W_WWWW_.WWKWK_WKWW
_W_WWWW_W.WWWWWW.WWWW_K__..W.WW_WWWWWWWWKRW_WWW_C.W_KW_WWW_KW.._
..WWWWWWWCWWW.WWW_WKKWWWW_._WWW.....WWW.W_W.W._.KW...W...WWW.WWW
W..W..K..WW_.W._................W..._W.W.....K.W.K_...R..K...W.W
...W..W.............................................

最佳

top - 14:31:14 up 79 days, 21:39,  3 users,  load average: 2.26, 2.57, 2.86
Tasks: 717 total,   1 running, 716 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.3 us,  0.7 sy,  0.2 ni, 95.7 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :  64365.1 total,    539.8 free,   8847.0 used,  54978.4 buff/cache
MiB Swap:  65477.0 total,  63810.0 free,   1667.0 used.  54580.5 avail Mem 

ss-s

Total: 1934
TCP:   2362 (estab 1233, closed 1105, orphaned 2, timewait 1104)

Transport Total     IP        IPv6
RAW       0         0         0        
UDP       0         0         0        
TCP       1257      430       827      
INET      1257      430       827      
FRAG      0         0         0    

ulimit -n

1024

ss-ntu | awk '{打印 $5}' | 切-d:-f1 | 排序 | 唯一的-c | 排序 -n

    1 Local
    6 192.XXX.XXX.XXX
  100 127.0.0.1
  340 10.0.0.XX
  866 [

ss-ntu | awk '{打印 $6}' | 切-d:-f1 | 排序 | 唯一的-c | 排序 -n

 ..........
lists # of ip connections. Besides 127.0.0.1 and [ there are 2 ips over 50.
   74 104.xxx.xxx.xxx
   91 12.xxx.xxx.xxx

MySQL

No processes running more than a second. Number of processes well within limits.

在诊断网络速率限制问题时,我不知道除了这些统计信息之外还有哪些相关的统计信息。任何指针将不胜感激。

已编辑

中央处理器

阿帕奇配置

mysql

可选的非常有用的信息

标签: apachenetworkingdebianlag

解决方案


多萝西,您的系统正忙于活动。不知道间歇性挂起的频率和持续时间会使我们处于不利地位。一个可能的原因是 com_drop_table 在您 83 天的正常运行时间中有 3,318 次使用。另一个可能的原因是读取和写入的数据量。看起来 innodb_data_written 在 83 天内是 484TB,但 MySQLTuner 在 10 个表中只报告了 800K 的数据。我们的常规日志分析可能会确定这种高活动的原因。这些建议将是一个开始的努力,应该完成更多的分析和更改。

在您的操作系统命令提示符下, ulimit -n 96000 将启用更多的打开文件(句柄),超过今天的 1024 限制。这是 Linux 中的动态操作,不需要执行操作系统重启。为了使此更改在操作系统停止/启动中持续存在,可以使用以下 URL 作为指南。请使用 96000,而不是 500000 - 如他们的示例文档中所示。 https://glassonionblog.wordpress.com/2013/01/27/increase-ulimit-and-file-descriptors-limit/

每秒速率 = RPS

为您的 my.cnf [mysqld] 部分考虑的建议

innodb_io_capacity=1900  # from 200 if you have SSD, 900 if you have magnetic storage to improve IOPS
net_buffer_length=32K  # from 16K to reduce malloc operations
innodb_lru_scan_depth=100  # from 1024 to conserve 90% of CPU cycles used for function
key_cache_segments=16  # from 0 to reduce mutex contention with MyISAM opens
key_cache_division_limit=50  # from 100 for Hot/Warm storage to reduce key_page_reads RPS of 18
aria_pagecache_division_limit=50  # from 100 for Hot/Warm storage to reduce aria_pagecache_reads RPS of 5K
read_rnd_buffer_size=64K  # from 256K to reduce handler_read_rnd_next RPS of 27,707

这些更改应该会减少完成大多数查询所用的时间。需要考虑的其他方面包括使用慢查询日志分析来查找索引可以避免表扫描的位置。MySQLTuner 报告了超过 400 万次没有索引的连接。我们的常见问题页面包含有关如何找到需要索引以避免扫描的表的信息。让我们知道这些建议如何为您服务。如果您可以灵活地使用这种通信方式,Skype Talk 会非常有效。


推荐阅读