IIS PHP MySQL服务器堆栈在重负载下不可用

时间:2018-03-02 18:51:27

标签: mysql iis-10

我正在尝试构建一个能够应对非常繁忙流量的IIS 10 / PHP 7.2 / MySQL 5.7 Web服务器。它是48核Xeon Platinum服务器,具有188GB RAM。我正在使用loader.io来执行负载测试。

负载测试导航到服务器上的PHP页面,该页面又执行几个MySQL查询(以使其更加真实)。

当我运行loader.io负载测试时,在网站上大约有1500个用户处于活动状态后,我可以在IIS日志中看到很多500和503错误,并且由于高级别的错误导致测试停止。

我今天已经切换到MySQL持久连接以尝试提高性能。

我检查了PHP错误日志,没有错误。

我检查了Windows Server 2016系统日志,它说:

  

中止与db的连接:'xxxx'用户:'xxxx'主机:'localhost'(得到   读取通信包时出错)有关详细信息,请参阅“帮助”   和http://www.mysql.com的支持中心。

这是我的MySQL配置:

max_connections=501
table_open_cache=2000
tmp_table_size=1G
thread_cache_size=100
key_buffer_size=2G
read_buffer_size=2G
read_rnd_buffer_size=2G
join_buffer_size=2G
sort_buffer_size=2G

这是我的PHP配置:

mysqli.max_persistent = 500
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
memory_limit = 128M

资源永远不会超出,但测试仍然失败。我可以在配置或任何其他变量中进行任何调整以进行测试吗?谢谢

enter image description here

enter image description here

enter image description here

2 个答案:

答案 0 :(得分:1)

对my.cnf / ini [mysqld]部分的建议

#read_buffer_size=2G
#read_rnd_buffer_size=2G
#join_buffer_size=2G
#sort_buffer_size=2G

使用#引导这4行中的每一行,以使用DEFAULTS。您使用这些限制是极端的。使用MySQLCalculator.com 2分钟将说明您请求的RAM占用空间极端。

您的配置仅限于大约500个连接,为什么您在测试中尝试用1500过度驱动平台?

答案 1 :(得分:1)

为my.cnf / ini [mysqld]分析808秒正常运行时间后的建议

thread_cache_size=100  # from 2000, v 5.7 5.1.5 CAP at 100 suggestion
innodb_io_capacity=1000  # from 200  unless you test for Random Write IOPS and get your own capacity
eq_range_index_dive_limit=32  # from 200, if U can not find in 32, 200 will not either
expire_logs_days=5  # from 0, so you have limited historical logs vs nothing
innodb_lru_scan_depth=100  # from 1024 to avoid overrun of page_cleaners volume
innodb_page_cleaners=64  # from 4 for auto limit = innodb_buffer_pool_instances
innodb_read_ahead_threshold=8  # from 56 will RD next extent/avoid wait
innodb_read_io_threads=64  # from 4  see dba.stackexchange Q 5666 9/12/11 Rolando
innodb_thread_concurrency=0  # from 32  Rolando explains why - to use cores
innodb_write_io_threads=64  # from 4  turn it LOOSE SE 5666 explains
innodb_stats_sample_pages=32  # from 8 for more accurate cardinality
#max_allowed_packet=1G  # lead to use DEFAULT

当你需要超过DEFAULT时,在SESSION中 SET @ max_allowed_pa​​cket = nnnnn高达1G,这是infile允许的限制

max_join_size=1M  # from a huge # for a reasonable limit of rows
max_seeks_for_key=32  # from a huge # to limit OPTIMIZER endless search
max_write_lock_count=16  # from a huge # to allow RD after nn locks
sql_select_limit=1M  # from a huge # to limit ROWS selected
open_files_limit=50000  # from 502048 for more useful max
query_alloc_block_size=32K  # from 8192 to avoid RAM alloc frequency
query_cache_size=0  # from 1M keep your RAM for useful purpose, not using QC
query_cache_limit=1K  # from 1M to conserve RAM while QC not in use
query_cache_min_res_unit=512 # from 4096 will allow more results in QC
query_prealloc_size=32K  # from 8192 to avoid RAM alloc frequency
updatable_views_with_limit=NO  # from YES to reduce handler_external_lock
wait_timeout=3600  # from 28800 seconds, idle connections need to release rscrs, login will be required.
今天早上我的想法。在新的pastebin's发布时,很高兴重新使用新的GS和GV进行分析。