I found that some hosting providers are using external MySQL database (located on a separate domain/server). The database access time for these providers is around 0.02 - 0.06 sec per one MySQL query (the queries are very simple “select * from some_table” and the tables contain only 3-10 rows).
Another hosting provider that I tested has internal MySQL database (located on “localhost”). For this provider the access time is 0.0005 sec per one MySQL query.
For comparison, on my local PC the access time is 0.005 per one MySQL query.
I wonder what is the point in using external MySQL databases if they are around 50 times slower. It is like trying to sell a car with max speed 3km/h when there are cars with max speed 150km/h in the market.
Also, what are the suitable MySQL access times for shared hosting plans? (let’s assume simple mysql queries)
I wonder what is the point in using external MySQL databases if they are around 50 times slower. It is like trying to sell a car with max speed 3km/h when there are cars with max speed 150km/h in the market.
I believe it is easier for the host to achieve higher density per server when each server can be optimized (hardware, OS and software) towards a narrow purpose. Overall stability might also increase. Unfortunately, the latency introduced will mean a certain overhead. Now, this overhead is likely more or less constant, so for queries that resemble real life applications more (that is, they take longer to run), I suspect that the difference (percentage wise) won’t be as large.
I suspect that the difference (percentage wise) won’t be as large
I agree that the productivity and stability of the external MySQL database may be higher. However, based on my tests that I mentioned above, the latency of the external database is 50 times higher (or percentage wise - 5000%). 10 queries x 0.05 sec latency = 0.5 second delay. This is already noticable. And if the delay increases to 2-3 seconds, you will start losing visitors. So, external database may be convenient for the hosting provider, but not so convenient for the webmaster.
Also, I am interested what database latency is good for shared hosting and what latency would indicate that MySQL server is overloaded and it’s better to look for more reliable hosting provider?
From my experience, when webpage is loaded within 1 sec I don’t notice it, when it is loaded more than 2 sec this is already irritating. So, extra 0.5 sec delay from database would spoil user experience.
The ability to optimise a server for mysql alone and apache (or other server) alone is easier than trying to make one machine do both (in terms of resources) - equally, single task servers are easier to setup and back up - often, in big websites a large database server will be running behind multiple smaller front end ones - so it balances costs too.
There are reasons to do it, and I bet most of the difference in time is setup / destruction of the TCP connection - in which case, try using Persistant connections if they are enabled.
The latency difference is small relative to typical query duration.
If e.g I had a database server heavily optimised in both soft/hardware (perhaps using small but very fast SSD drives that wouldn’t be an optimal choice for a web server where space has a higher importance) that then performed a typical 1 second wordpress/forum/shopping cart query twice as fast, there would still be a substantial net gain despite the marginally increased latency.