phpMyAdmin Hosted in Azure problems - php

I created my phpMyadmin in Windows Azure which only allows 1 MySQL database for free users.
After creating a phpMyAdmin I linked MySQL Database Resources to another Website.
In this website I try to login my accounts registered to the database.
At first it goes smooth and seems there is no problem, but as i try to continue accessing the website which retrieves details from the linked MySQL Database Resources, The website returns and error of..
User 'b48a56f527c793' has exceeded the 'max_user_connections' resource (current value: 4)
But after a while 3-5mins the connection is good again.
At first I think the Windows Azure just tries to limit traffic but is it really that real cause of the problem or did i made mistake in setting up my phpMyAdmin in Windows Azure?
How to fix that error?
Big thanks in advance!

When you use MySQL on Azure you have to know is it provided by ClearDB, and the free tier is very limited. You can check the limitations here. For example you only have 4 concurrent connections limit, which is quite restrictive.
As a suggestion - never use mysql_pconnect in your scripts, but always use mysql_connect and always kill your connection when you don't need it anymore (i.e. when you retrieve the data).
I'm not 100% sure, but I think default installation of phpMyAdmin uses mysql_pconnect, which might keep idle connections as a resource from these 4 you have.

If you are using ClearDb on Azure which is the default option, ClearDb has really tight limit for simultaneous connections. Check it here:
https://www.cleardb.com/store/azure

Related

Azure website + mysql

I am starting my Azure Project. I did a website to Run Wordpress. Migrating from a previous host entity.
I use mysql, the ClearDb azure has is very limited and expensive $75 p month just because i need views and triggers ( only available on the dedicated server plan) its SAD. I Then created my MySql in Amazon RDS.
I did some latency tests, and the fact that Mysql being Closer to the Website region helps alot to reduce latency.
But still, my wordpress navigation seems slow! The first time is terrible, around 4 seconds. The next ones a bit better but nothing compared to my previous host of around 200ms!
Is this because of mysql being accessed by remote and not being in the same "data center" ? or is this because another thing like the "hot and cold" websites concept of Azure!? ( because even secondary calls are slow)...
I am starting to realize Azure is not Good for Websites with PHP + MYSQL.
I like the look and feel of Azure UI and Website concept but this is Very disappointing from azure not having a self MYSQL Structure.
Latency is a problem. Before assume that Azure is good or not, try a new thing. Create an azure virtual machine and install mysql in there. Then, edit your connection string to point to your VM. Also, install a plugin cache because wordpress execute a lot of queries in your database.
Another option: did you try the Scalable WordPress available through Azure Marketplace?
http://azure.microsoft.com/en-us/marketplace/partners/wordpress/scalablewordpress/
#Miguel, I agree with Thiago.
I think you can install MYSQL database on VM and connect it with your Wordpress website.
In this scenarios, I suggest you can use some tool to find the items which takes more times, such as webpagetest . It is useful for further steps.
At the same time, you can try to optimize your database,compress Images and so on. I recommend you can refer to this blog about how to improve the WP site performances.
By the way, Azure will unload your site if it is idle for the standard 20 minute timeout, which can cause slow responses for the initial site users after it is unloaded. You could enable the "always on" feature if you think it is necessary.
Did you try using persistent connections from your WordPress site to MySQL database. That can decrease latency times by decreasing time to create a connection and instead reuse existing connections.
The MySQL latency is an issue and there is probably not much we can do about it since the DB call has to be made further than to the localhost - simple as that.
1) If you need Azure for your MySQL driven eapp, use Microsoft's VM which is running quite reliably and where you can install PHP/MySQL on the same machine - speedy but relatively pricey. So far the only production acceptable solution for MySQL I found.
2) Don't use Azure if you need fast MySQL connections. We have tons of MS apps running in azure with various versions of MSSQL - and they all running relatively fine. So far I did not find fast solution for MySQL. Therefore, I am still using Linode for the PHP/MySQL apps. Their speed and service is superb (I am not getting anything from Linode for this recommendation :) and it is quite inexpensive in comparison to Azure in this case.

'Mirror' database connection using PHP

Now before I start I just want to say that I have absolutely no idea if this is possible.
The Question
I am used to managing databases on my computer using Sequel Pro, and that is what I have done for the past few years with my Linode VPS. I recently purchased iPage hosting to store some static content and I wanted to set up a database to keep an easy archive of it. Having created the database and set up the access details I wrote a basic PHP script for it.
I wanted to connect via Sequel Pro, but with a lot of shared hosting they don't seem to let you do this for security reasons. My question is, would it be possible to write a script that you connected to the same way as a database, but which processed all your requests to the database before returning it? If it is possible, how would you go about it, and if it's not, why?
SQLyog has php proxy, and it is generally one of the methods for connecting to mysql databases which are bound to localhost. Also, some cPanel hostings have an option where you can specify external IP which can connect to the database, have you asked the support if there is such an options?
In SQLyog, feature where they use php proxy is called HTTP Tunnel. Maybe there exists something like that for Sequel ?
https://static.webyog.com/docs/SQLyog/HTTP_Tunneling_SQLyog_MySQL_Client.html

Usage of Mysql in offline internet state

I'm using a self-made customer system in PHP running with a local mySQL Database.
Now i have a second computer on a different location which has to use this Database too. So i gave this mysql Database on a Server reachable through internet.
My problem is now, that the first one has often problems with the internet connection and then the program will not work. But it has to work every time!
Now i do not know how i should handle this problem?
A local Database and one in the internet, but how should i merge them?
Should i make a local DB per computer and match them together in one?
I also want to change the framework behind this system to symfony2 so is there a way to solve this problem with this framework (e.g. doctrine?)
Thanks for your help!
Update:
My limitation is the Internet connection on the first computer which could not be eliminated.
If you really have limitations of (1) not being able to move the database off of the machine with a bad connection and (2) not being able to fix the bad connection; you are going to have to keep some sort of local instance on the second machine.
I would try to setup master-master replication from the first machine with the bad connection to the second machine. I'm not sure how reliable this will be considering the replication will be failing often due to the first machine's bad connection. This problem may be extrapolated if one or both machines are using old versions of MySQL. MySQL 5.5, for example, can be configured to actively monitor replication connectivity.
If the majority of your application does READS instead of WRITES, perhaps you could install Memcached (or something similar) on the second machine so that the application can pull data from local memory without requiring a connection to the MySQL server.
There are a few ways to achieve what you want (although maybe not exactly how you described), but the best way is definitely do host the database on a server that doesn't have Internet connectivity problems. Look for hosting that allows remote MySQL connections.

Advantage and PHP - Error 6303: Maximum Advantage Database Server connections exceeded

My company php web site is connected to an Advantage Database Server where are stored all necessary data such as users, passwords and customer registry.
Lately we started to get an error requesting web pages:
Warning: SQL error: [Extended Systems][Advantage SQL][ASA] Error 6303: Maximum Advantage Database Server connections exceeded. axServerConnect, SQL state HY000 in SQLDriverConnect in C:\...\www\... on line...
It's becoming critical day by day and it can happen once a week or twice a day without an apparent reason.
When website crashes, database service still working great with other applications connected and the only way to restore web service is to restart apache web server.
On database server we've got ads.ini configuration file in C:\Windows folder where we raised max connections setting with "MAX_CONNECTIONS=1000" which is really big compared to our needs.
Can it be useful if we set also "RETRY_ADS_CONNECTS = 1" ??
I found this post where R&D confirms a bug in may 2009:
Is this a bug with Advantage Database?
Has this been fixed? In wich release?
Where can i see the real number of connections open by apache on db?
Each php page closes ads connection on footer, what can cause connections to exceed??
Thanks in advance for help.
-
ENVIRONMENT INFO
Database:
Advantage Database Server 10.10.0.6 on Windows 2003 server
Web server:
Apache/2.0.59 (Win32) mod_ssl/2.0.59 OpenSSL/0.9.8d PHP/4.4.7 on Windows XP pro
On phpinfo() page we get "Advantage Version" "8.00.0.0".
Why this? Do we need to upgrade php-advantage extension?
Lots of questions, but I will try and address each.
1) 6303 Error. Using MAX_CONNECTIONS is the correct way to resolve this.
Make sure MAX_CONNECTIONS is in the [SETTINGS] section
Check if Apache / PHP / ADS driver is using the correct ads.ini file. You can use Process Monitor from Sysinternals to see what ads.ini file was opened successfully. If you upgrade your PHP driver you can set an environment variable adsini_path to point to the directory where the ads.ini lives.
2) Setting RETRY_ADS_CONNECTS=1 will be helpful. This also goes under the [SETTINGS] section of the ads.ini. When an ADS client receives a networking error (generally a 6000 class error) then the error is cached by the client driver and subsequent attempts to connect will use the cached error vs. retrying. Setting RETRY_ADS_CONNECTS will tell the ADS client to ignore the cached error and retry the connection
3) Bug: Looks like this was fixed in 9.10.0.9 version of the driver based on the release notes on http://devzone.advantagedatabase.com.
Fixed an issue where the garbage collection reference count on a
connection would be incorrect if multiple SQL statements were opened
on it.
Since you are running a 10.1 server you may look at updating to a 10.1 client which will also contain the fix. 10.1 Advantage PHP Driver
4)See the real number of connection
I would recommend using the stored procedure sp_mgGetConnectedUsers, you can use ARC (Advantage Data Architect) but it can be difficult to group, order, etc.
Since you are using 10.1 you can include the results of the stored procedure in a query such as
SELECT COUNT(*) FROM (EXECUTE PROCEDURE sp_mgGetConnectedUsers()) u WHERE ADDRESS='xxx.xxx.xxx.xxx'
You could also use other fields to identify the PHP application such as UserName (the server name), DictionaryUser (assuming the php application uses a unique user), ApplicationID
5) PHPINFO shows Advantage Version of the Advantage PHP client driver. You may want to upgrade the client driver for reasons mentioned above. Should be as simple as swapping DLL files (ace32.dll, axces32.dll, adsodbc.dll and php_advantage.dll), but I would recommend testing first to ensure you get everything.

Apart from MySQL concurrent connection limit, does PHP/Apache play any role on dropping connections?

If MySQL is dropping connections in a PHP application, and MySQL connection limit is set above the number of concurrent users in the application, which other factors can contribute to this behavior? Also, analyzing moodle logs (the only app running at these servers), yesterday I had 4 times more activity and it didn't drop anything, but today there were times where it was frustrating the number of dropped connections.
My main question here is why the database is rejecting connections when it didn't before with 4 times more activity (and everything it's the same, I didn't change anything in between).
Some background: I've got 2 servers contracted at my hosting:
shared server running Debian Linux/PHP 5.3 (FastCGI)
VPS running Debian Linux/MySQL 5.1.39
On this environment I'm running only moodle 1.9.12 (for the database connection using adoDB and persistent connections), php part on the shared server, database on the VPS. I suspect that, by PHP running on a shared server, other hosting accounts are affecting me (the database rejecting connections I mean, I really don't care about RAM/CPU).
Reading about the issue I've seen in places that persistent connections don't work well with PHP as CGI/FastCGI and that if both servers are in the local lan it really doesn't matter using persistent or not persistent connections because of the connection is going to be quick anyway. So now I'm using not persistent connections. I guess that may be part of the problem, but I fail to understand why it worked with more load. Which PHP/Apache settings are involved here?
Since your database and web server are on two different machines, there are two other possible causes: the network in between, and the network layer of the operating system.
If you did not change anything in your configuration and it worked with higher loads before, it is more likely to be an issue with the network connectivity between the two machines. Since the database machine is a VPS you also don't know how much real network load it is handling. If your ISP has competent support personnel (which unfortunately isn't always the case) it can't hurt to ask them if they have an explanation.
The same goes for your "shared" web-server. While it is unlikely, it is not impossible that it is a an issue of too many connections on that machine.
It would also help to know how exactly you are measuring dropped connections. If you are looking at the aborted-connections counter of mySQL, it is not necessarily a measure of an actual problem: http://dev.mysql.com/doc/refman/5.1/en/communication-errors.html. A user aborting a page load already may increase this counter.
If PHP throws an error, because it could not connect to the server or lost connection to the server during a query, then it is an issue.

Categories