Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud SQL VERY SLOW

I am thinking to migrate my website to Google Cloud SQL and I signed up for a free account (D32).

Upon testing on a table with 23k records the performances were very poor so I read that if I move from the free account to a full paid account I would have access to faster CPU and HDD... so I did.

performances are still VERY POOR.

I am running my own MySQL server for years now, upgrading as needed to handle more and more connections and to gain raw speed (needed because of a legacy application). I highly optimize tables, configuration, and heavy use of query cache, etc...

A few pages of our legacy system have over 1.5k of queries per page, currently I was able to push the mysql query time (execution and pulling of the data) down to 3.6seconds for all those queries, meaning that MySQL takes about 0.0024 seconds to execute the queries and return the values.. not the greatest but acceptable for those pages.

I upload a table involved in those many queries to Google Cloud SQL. I notices that the INSERT already takes SECONDS to execute instead than milliseconds.. but I think that it might be the sync vs async setting. I change it to async and the execution time for the insert doesn't feel like it changes. for now not a big problem, I am only testing queries for now.

I run a simple select * FROM <table> and I notice that it takes over 6 seconds.. I think that maybe the query cache needs to build.. i try again and this times it takes 4 seconds (excluding network traffic). I run the same query on my backup server after a restart and with no connections at all, and it takes less than 1 second.. running it again, 0.06 seconds.

Maybe the problem is the cache, too big... let's try a smaller subset

select * from <table> limit 5;

  • to my server: 0.00 seconds
  • GCS: 0.04

so I decide to try a dumb select on an empty table, no records at all, just created with only 1 field

  • to my server: 0.00 seconds
  • GCS: 0.03

profiling doesn't give any insights except that the query cache is not running on Google Cloud SQL and that the queries execution seems faster but .. is not...

My Server:

mysql> show profile;
+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| starting                       | 0.000225 |
| Waiting for query cache lock   | 0.000116 |
| init                           | 0.000115 |
| checking query cache for query | 0.000131 |
| checking permissions           | 0.000117 |
| Opening tables                 | 0.000124 |
| init                           | 0.000129 |
| System lock                    | 0.000124 |
| Waiting for query cache lock   | 0.000114 |
| System lock                    | 0.000126 |
| optimizing                     | 0.000117 |
| statistics                     | 0.000127 |
| executing                      | 0.000129 |
| end                            | 0.000117 |
| query end                      | 0.000116 |
| closing tables                 | 0.000120 |
| freeing items                  | 0.000120 |
| Waiting for query cache lock   | 0.000140 |
| freeing items                  | 0.000228 |
| Waiting for query cache lock   | 0.000120 |
| freeing items                  | 0.000121 |
| storing result in query cache  | 0.000116 |
| cleaning up                    | 0.000124 |
+--------------------------------+----------+
23 rows in set, 1 warning (0.00 sec)

Google Cloud SQL:

mysql> show profile;
+----------------------+----------+
| Status               | Duration |
+----------------------+----------+
| starting             | 0.000061 |
| checking permissions | 0.000012 |
| Opening tables       | 0.000115 |
| System lock          | 0.000019 |
| init                 | 0.000023 |
| optimizing           | 0.000008 |
| statistics           | 0.000012 |
| preparing            | 0.000005 |
| executing            | 0.000021 |
| end                  | 0.000024 |
| query end            | 0.000007 |
| closing tables       | 0.000030 |
| freeing items        | 0.000018 |
| logging slow query   | 0.000006 |
| cleaning up          | 0.000005 |
+----------------------+----------+
15 rows in set (0.03 sec)

keep in mind that I connect to both server remotely from a server located in VA and my server is located in Texas (even if it should not matter that much).

What am I doing wrong ? why simple queries take this long ? am I missing or not understanding something here ?

As of right now I won't be able to use Google Cloud SQL because a page with 1500 queries will take way too long (circa 45 seconds)

like image 910
Fabrizio Avatar asked Feb 13 '15 16:02

Fabrizio


People also ask

Why is SQL query running so slow?

WAITING: Queries can be slow because they're waiting on a bottleneck for a long time. See a detailed list of bottlenecks in types of Waits. RUNNING: Queries can be slow because they're running (executing) for a long time. In other words, these queries are actively using CPU resources.

How fast is Google Cloud SQL?

With a connection to Cloud SQL over SSL the load speed is 0.4s.

Is Google Cloud SQL good?

It is one of the excellent database to use. Google cloud SQL delivers high performance and scalability . Cloud service is best way to manage varieties of databases like (MYSQL, PostgreSQL, SQL server). It is very to use and easy to setup.

Why BigQuery is faster than SQL?

Scalable Architecture: Google BigQuery has a scalable architecture and offers a petabyte scalable system that users can scale up and down as per load. Faster Processing: Being a scalable architecture, Google BigQuery executes petabytes of data within the stipulated time and is more rapid than many conventional systems.


1 Answers

I know this question is old but....

CloudSQL has poor support for MyISAM tables, it's recommend to use InnoDB.

We had poor performance when migrating a legacy app, after reading through the doc's and contacting the paid support, we had to migrate the tables into InnoDB; No query cache was also a killer.

You may also find later on you'll need to tweak the mysql conf via the 'flags' in the google console. An example being 'wait_timeout' is set too high by default (imo.)

Hope this helps someone :)

like image 198
SteveJ314 Avatar answered Dec 21 '22 10:12

SteveJ314