PHP App (ExpressionEngine) slow to load on IIS 7, MySQL, FastCGI - mysql

I'm working on debugging a slowness issue I've got with running ExpressionEngine (a PHP application) on IIS 7.
I don't think this is actually an issue with ExpressionEngine, but rather an issue with my PHP/MySQL setup.
The problem shows itself thusly:
Go to webite address
IE "spins" for 10-15 seconds, waiting to load. During this time:
processor usage is minimal on the server, and PHP's process is inactive
I see a connection for the site user in MySQL, but the thread is in "sleeping" more.
There is plenty of free memory on the server
pretty much, the server is doing nothing
After 10-15 seconds, I see the connection MySQL run some really quick queries (very fast) and the site loads in under a second.
This is a fairly complex site, but it doesn't make any sense that the whole system is just sitting there waiting for 10 seconds - not processing anything. I'm using FastCGI on IIS7, which seems to be working fine, and to me this seems like some sort of a timeout issue where FastCGI, PHP, or maybe even MySQL is waiting for something, not getting it, and after the timeout occurs, continuing to process.
Anyone had similar experiences?
Thanks!
P.S. - I should also add that the database (MySQL) and PHP are running on the same server.

mysql might be trying to do a reverse DNS on the connection from the web server. if you don't need to filter mysql connections by DNS name, then add skip-name-resolve to your mysql configuration file

Twitter plugins cause lots of issues in CMS systems. usually there is a function that checks if twitter is there/alive. When twitter gets busy, this slows down the system (thats why it can appear as intermittent) Find the twitter plugin, and the routine that checks if twitter is there. Comment out this code and return true (ie. don't ask twitter if it is there, just assume it is)

I have no idea why, but the solution to this was to install PHP 5.3. I had PHP 5.2.10 running, and I guess 5.3 added some extensive optimizations for Windows. Or fixed some other weird problem - who knows.
Actually, after some further digging, it appears the problem was with the Twitter plugin. It waits 25 seconds to come back from Twitter sometime with an error. Maybe this is related to the DNS?

Related

ASP Classic On IIS Takes 31 Seconds To Execute Each mySQL Script

My development system has suddenly been afflicted with this weird problem where every single SQL script takes exactly 31 seconds to execute on my Classic ASP site's connection to a mySQL (MariaDB) database.
Connecting to either a local copy of the DB running off my system or even my live DB being hosted at a web host, it all the same.
Everything from a simple
adoconn.Execute("SELECT * FROM users;")
or even
adoconn.Execute("SET sql_mode''")
would take 31 seconds to execute. Each!
I can safely rule out any problems with the DB as connecting to it and running scripts from DBeaver shows no problems at all. The results come back instantly.
I can also rule out network problems as the local DB and the hosted DB have the same results and I have used WireShark to confirm that the MySQL packets are being responded to almost immediately from the hosted DB.
Debug stepping through my ASP code, everything runs fine right up until the .Execute() at which it will take 31 seconds, regardless of how complex the script is.
The strangest thing is, this problem just came out of the blue; when my system was powered down, disconnected and untouched over the weekend. No updates, installations or changes were done to the system. Friday I was doing my dev work perfectly fine. But Monday morning when I powered it back up, the DB connections there are stuffed.
I've already tried configuring mySQL to use the "skip-name-resolve" and "bind-address = ::" settings.
I have tried rebuilding my IIS websites and reinstalling IIS itself.
I've also reinstalled mySQL ODBC drivers on my system to no avail.
What is going on here?
As it turns out, the cause of this whole issue was the McAfee software that came pre-installed in my Dell laptop.
No, I did disable the firewall and antivirus, mind you.
Those were the first steps I did and triple-checked routinely during my testing. Both McAfee's firewall and auto-protection were all fully disabled.
But apparently, McAfee, ignores this setting and was screwing my DB connections over ODBC.
This problem finally only came to an end when I fully uninstalled this McAfee malware. There's no other way to describe it.
Let this post be a warning to anyone else naively believing this malware to be anything else.

MySQL 5.7 default install running much slower than 5.6

I have a java / spring / hibernate app running with connections to a MySQL db.
We recently upgraded from 5.6 to 5.7 (on a Windows server) and the app has gone from taking 3 hours to 3 days to complete. It essentially uses hibernate connections to retrieve read only data from the db before processing it and dumping the result elsewhere.
However as a first step, partly to check it was the upgraded version that is causing the problem, I installed 5.7.21 on my dev machine. I then noticed that even doing a db restore took several hours rather than what used to take about 10 minutes on 5.6. This has lead me to believe it may be more of a config issue than 'drivers' being out of date (I did think my first step was going to be upgrading app dependencies). I didn't install the server but I installed my dev machine with a default 'developer' install. Both the server and the dev machine are 64 bit Windows.
I've had a scoot around for obvious gotchas and not found anything yet. I just wondered if anyone could point me in the right direction before I start seriously thrashing about ? I have a good basic understanding of out of the box MySQL but I haven't done much config so even pointers to likely suspects in my.ini and best ways to investigate would be helpful.
When upgrading, pay attention to innodb_buffer_pool_size variable value.
It controls how much memory MySQL uses to make I/O operations faster. Usually, this is the one that makes it fly or that makes it crawl like a snail. There's a lot to be written about this particular variable, there's a plethora of excellent blog posts about it so I'll avoid explaining it into detail.
To see the current value, type in MySQL terminal:
SHOW VARIABLES LIKE '%innodb_buffer_pool%';
Change the value in config file and restart MySQL.
For the value, don't go overboard, don't exceed your entire RAM. You want it as high as possible, especially for servers with a lot of data.

Wordpress sends lots of sleep sql query to mysql

My server got stucked last night because of database connection error.
I investigated it is caused by too many database connections. After a research from google and stackoverflow, I didn't get any useful information. While I am trying to investigate all plugins one by one to see if any of them has a bug or something did this, I would like to ask your helps..
First of all, when I logged in to MySQL I can see a lot of SLEEP queries with NULL info there. I tried to use command line to kill all sleep queries but there still more requests fill all connections right away.
The weird thing is, the apache server is not actually getting high volumn of requests. I am actually using AWS RDS as my database server so the apache and mysql is not on same server. The RDS server doesn't have public access so I am sure all requests are only from my apache server. The cpu usage on apache server is not high. Also, I searched the apache's access_log there are not a lot requests at that time. And I cannot find anything wrong with these requests. Especially there is no requests is performing injection attack. I think it is possible some thing triggered in the code so I searched 'SLEEP' in all my code but can only find some in the w3 total cache plugin, which the code blocks in this plugin is not easily get reached..I turned off the XML-RPC in apache level so it shouldn't be the XML-RPC attack.
I know there are a lots of possibility since I am using about twenty plugins in my site, but it is really weird I cannot find any possible requests caused this on apache level. Is it possible any requests can hit the server without being recorded in access_log?
I am pretty new to configure apache and mysql on my own and still learning these features..Thanks in advance for helping me!

Updated to Windows 10 and XAMPP for Windows 5.6.12 - MySQL is now very slow

Following a recent upgrade to Windows 10 my XAMPP didn't seem to want to work (neither Apache or MySQL would start). So I upgraded that too to XAMPP for Windows 5.6.12. There were a few port issues initially (due to new? services in Windows 10) but once those were fixed I have both Apache and MySQL running.
However, now the php pages that I am working on, which do a great deal of reading and writing back to a MySQL database, run unbelievably slowly. A page that used to take a minute or two before any upgrade now takes about 30 minutes. I can see that writing to the database is very slow and the hard disc is always sitting at around 90 to 100%. I have tried many suggested changes: stopping various services, changing the page size etc but it still runs very slowly. I have checked the event log but there is nothing that stands out as an issue.
I am not sure if it the upgrade to Windows 10 or XAMPP that has done it, and I have run out of ideas. I realise this may sound a bit vague and I am happy to post logs etc but I am not sure whether there is a simple reason for this, or something simple for me to check.

MySQL database is loading very slow

I have a wordpress installation which has over 5000 posts in it. For the last few days, the database is loading very slowly. I have used the database optimization plugin as well as optimized db tables from back end. But still the issue exist. After I restart the MySQL server everything seems to work just fine. The same issue exists for my other website which is a Joomla installation on another server(Amazon) and has over 50,000 articles. Even here I regularly do database optimization but still the pages load very slowly. Sometimes to over 1 minute. There is page cache on both the sites, still I am getting this issue. There are other websites also running on the same server but they are relatively new and less content compared to these two sites, they load very fast. The problem is with these two websites only.
Check out:
Connection pool. Maybe you're running out of connections and get bottlenecked
Server's cache
slow queries audit
... this are just hints, to get real help you should indicate more system performance's info
I'm not sure about the Wordpress site configuration settings, but for Joomla, if you are not already running MySQLi, I would recommend enabling in in the Global Configuration. Try clearing the site cache and if you are running on Joomla 1.5, then if possible, upgrade to Joomla 2.5 as it is a little faster when running queries. In the end, it might just be due to the fact that you are on a shared host, so if you are willing to, a VPS server would speed things up.
There can be many reason for the same like : "Hosting Server Issue (use dedicated server for such sites)" , "Use good cache plugin availabe for joomla & wordpress" , "Use db optimize plugins"
You can also refer to following sites -
http://www.sparringmind.com/speed-up-wordpress/
http://wpmu.org/too-many-wordpress-plugins/
http://www.joomlaperformance.com/articles/performance/so_you_want_to_speed_up_joomla_3_14.html