Advertisement
lyfsy

Apache connections stuck on "sending reply" and high mysql l

Jan 23rd, 2020
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. Apache connections stuck on "sending reply" and high mysql load
  2. Apache on my dedicated server constantly hangs due to connections being stuck in a state of "sending reply":
  3. ++++++++++++++
  4. list of top cheapest host http://Listfreetop.pw
  5.  
  6. Top 200 best traffic exchange sites http://Listfreetop.pw
  7.  
  8. free link exchange sites list http://Listfreetop.pw
  9. list of top ptc sites
  10. list of top ptp sites
  11. Listfreetop.pw
  12. Listfreetop.pw
  13. +++++++++++++++
  14.  
  15. https://i.imgur.com/9AV3U9o.png
  16.  
  17. This happens at least several times a day - sometimes it won't happen for 2 or 3 hours, sometimes it'll happen constantly to the point where all connections will be occupied and stuck in sending reply within 5 minutes of restarting apache. This results in sites having constant downtime. The IP's in these requests are usually Amazon AWS or Cloudflare (I use Cloudflare for many sites, and Amazon AWS IP's may be from having the site using Ezoic nameservers) that access a variety of URL's on the site. The 'SS' column in the screenshot above shows how long the connections been stuck - in this example it's hundreds of seconds on each request, so something is very wrong.
  18.  
  19. These are simple Wordpress sites, usually no images, no unusual plugins, very simple and definitely nothing unusual that would cause a page to take a long time to load. However, they each have 5,000 to 100,000+ posts on each site and may be posting up to several thousand posts a day (using the plugin "WP all import pro") that are scheduled to publish at random times within 24 hours from being imported. There are 10+ sites like this on the server but only 3 or 4 constantly appear in apache status with stuck connections.
  20.  
  21. Across all sites on the server, monthly pageviews are under 1,000,000 and should be easily handled by my server (from namecheap: XEON E3 1240 V3 8GB DDR3 1TB HDD SATA).
  22.  
  23. Mysql is often under high load on the server, and sometimes when looking at the processlist in phpmyadmin there will be stuck queries or sometimes NULL queries. Running the 'top' command also often shows very high CPU usage (my server has 4 CPU cores). Example screenshots:
  24.  
  25. https://i.imgur.com/uT1wmrY.png (queries being stuck)
  26. https://i.imgur.com/pg3qWgl.png (NULL queries)
  27. https://i.imgur.com/lKtRGDr.png (high mysql CPU use)
  28.  
  29. Of concern is that the mysql error log in /var/lib/mysql is over 3GB in size now, too big for me to even read - renaming it and checking a new one generated shows many 'Got an error reading communication packets' errors. I don't know if that is the issue for stuck connections in apache and if so, what to do about it.
  30.  
  31. make money c programming
  32. blog.de
  33. url-4ever.com
  34. babybearhits.com
  35. venezici.creadunet.com
  36. lcwsoft.com
  37. make money working from home
  38. bitcoinflood.com
  39.  
  40. I have tried changing all possible apache settings such as Max Request Workers from the default 150 so more connections can be made (doesn't help as any new connections also get occupied and stuck), disabling all plugins or trying different themes on the wordpress sites (no effect), as well as changing some different mysql settings in my.cnf (per https://serverfault.com/a/989269/548654) with no improvement. I also tried changing all of the database tables for 1 of the problem sites to InnoDB from MyISAM and it still gets stuck connections. What else can I try to resolve this?
  41. Apache on my dedicated server constantly hangs due to connections being stuck in a state of "sending reply":
  42.  
  43. https://i.imgur.com/9AV3U9o.png
  44.  
  45. This happens at least several times a day - sometimes it won't happen for 2 or 3 hours, sometimes it'll happen constantly to the point where all connections will be occupied and stuck in sending reply within 5 minutes of restarting apache. This results in sites having constant downtime. The IP's in these requests are usually Amazon AWS or Cloudflare (I use Cloudflare for many sites, and Amazon AWS IP's may be from having the site using Ezoic nameservers) that access a variety of URL's on the site. The 'SS' column in the screenshot above shows how long the connections been stuck - in this example it's hundreds of seconds on each request, so something is very wrong.
  46.  
  47. These are simple Wordpress sites, usually no images, no unusual plugins, very simple and definitely nothing unusual that would cause a page to take a long time to load. However, they each have 5,000 to 100,000+ posts on each site and may be posting up to several thousand posts a day (using the plugin "WP all import pro") that are scheduled to publish at random times within 24 hours from being imported. There are 10+ sites like this on the server but only 3 or 4 constantly appear in apache status with stuck connections.
  48.  
  49. Across all sites on the server, monthly pageviews are under 1,000,000 and should be easily handled by my server (from namecheap: XEON E3 1240 V3 8GB DDR3 1TB HDD SATA).
  50.  
  51. Mysql is often under high load on the server, and sometimes when looking at the processlist in phpmyadmin there will be stuck queries or sometimes NULL queries. Running the 'top' command also often shows very high CPU usage (my server has 4 CPU cores). Example screenshots:
  52.  
  53. https://i.imgur.com/uT1wmrY.png (queries being stuck)
  54. https://i.imgur.com/pg3qWgl.png (NULL queries)
  55. https://i.imgur.com/lKtRGDr.png (high mysql CPU use)
  56.  
  57. Of concern is that the mysql error log in /var/lib/mysql is over 3GB in size now, too big for me to even read - renaming it and checking a new one generated shows many 'Got an error reading communication packets' errors. I don't know if that is the issue for stuck connections in apache and if so, what to do about it.
  58.  
  59. I have tried changing all possible apache settings such as Max Request Workers from the default 150 so more connections can be made (doesn't help as any new connections also get occupied and stuck), disabling all plugins or trying different themes on the wordpress sites (no effect), as well as changing some different mysql settings in my.cnf (per https://serverfault.com/a/989269/548654) with no improvement. I also tried changing all of the database tables for 1 of the problem sites to InnoDB from MyISAM and it still gets stuck connections. What else can I try to resolve this?
  60. Try converting your database table engines to InnoDB as you have too many table level locks.
  61.  
  62. Your processor is doing ~75 work on user level stuff and rest of the %cpu looks normal
  63.  
  64. The bottleneck is somehow the database
  65. ∞A U T O M 8 N . C O M
  66. High Available webstack for cPanel * 10 minute deployment
  67. Fully rebrandable Solution for Service providers and SME
  68. I tried that with one of the problem sites and it still frequently gets connections stuck in sending reply.
  69. Since it does seem to be a bottleneck at the database, try running mysqltuner to see if it will give you some items to change in the mysql configuration.
  70.  
  71. It also looks like you have some IO wait and using some swap which wont help with IO to which mysql uses a good bit . Try increasing RAM for the server and see if that helps.
  72.  
  73. Also, since you mentioned AWS IPs, it could be some type of attack on one or multiple sites on that server. Seeing cloudflare IPs would be normal if you have sites using cloudflare. Use netstat -ntu to see if there are a lot of connections from a select few IPs or say a lot of SYN connections that could be eating all the open connections.
  74. -Steven | u2-web@Cooini, LLC - Business Shared Hosting | Isolate sites with Webspaces | Site Builder | PHP-FPM | MariaDB
  75. WHMCS Modules: Staff Knowledgebase | Custom Modules and Hooks
  76. "It is the mark of an educated mind to be able to entertain a thought without accepting it" -Aristotle
  77. Since it does seem to be a bottleneck at the database, try running mysqltuner to see if it will give you some items to change in the mysql configuration.
  78.  
  79. It also looks like you have some IO wait and using some swap which wont help with IO to which mysql uses a good bit . Try increasing RAM for the server and see if that helps.
  80.  
  81. Also, since you mentioned AWS IPs, it could be some type of attack on one or multiple sites on that server. Seeing cloudflare IPs would be normal if you have sites using cloudflare. Use netstat -ntu to see if there are a lot of connections from a select few IPs or say a lot of SYN connections that could be eating all the open connections.
  82. I tried changing different mysql settings as mentioned (per https://serverfault.com/a/989269/548654) from the default settings and there was no improvement.
  83. After trying everything I believe it is slow SQL queries running on the server causing this issue, rather than a bot attack or anything of that nature. Primarily now I keep seeing SELECT SQL_CALC_FOUND_ROWS queries that get stuck for several minutes at a time. When there are a lot of these for certain databases/websites I look in apache status and those are the sites that have a bunch of stuck connections; when there are none of these queries running apache status is clean. There are other types of queries that get stuck sometimes but it definitely looks like the SELECT SQL_CALC_FOUND_ROWS queries are the main culprits. So I am seeing what I can do to handle those (https://wordpress.stackexchange.com/...dpress-queries).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement