1
votes

I switched from a join and view based strategy on my old dedicated server to a multiple small queries strategy for Google Cloud. For me this is also easier to maintain and on my dev machine there was no noticeable performance difference. But on my App Engine and Cloud SQL it is really slow.

For example if I want to query the last 50 articles it takes 4-5 seconds, on my dev machine 160ms. For each article there are min. 12 queries on average 15 queries. That are ~750 queries, if I monitor the Cloud SQL I noticed that it always caps at ~200 queries per second. The CPU just peeks at 20%, I have just a db-n1-standard-1 with SSD. 200 queries per second also mean if I want to get the last 100 articles it will take 8-9 seconds and so on.

I already tried to set the App Engine Instance class to F4 to see if this will change anything. It didn't change anything, the number where the same. I haven't tried to increase the DB Instance because I can't see that it is at it's limit.

What to do?

Software: I use GO with a unlimited mysql connection pool.

EDIT: I even changed to the db-n1-standard-2 instance and there was no difference :(

EDIT2: I tried some changes over the weekend, 1500 iops, 4 cores, etc but nothing showed the expected improvements. The usage graphs were already indicating that there is no "hardware" limit. I managed to isolate the slow query tho... it was a super simple one where I query the country name via country-ISO2 and language-ISO3 both keys are indexed and still it takes 50ms for EACH. So I just cached ALL countires in memcache and done.

1
Could you maybe post the query codes that are causing you this slow performance? - Y2H
@Y2H do you mean the "pure" SQL from all 12 queries? - Tiega

1 Answers

3
votes

Google Cloud SQL uses GCE VM instances so things that apply to GCE apply to Cloud SQL.

When you create a db-n1-standard-1 instance your network throughput is caped to 250 MB/s by your CPU but your Read/Write (a)disk throughtput and (b)IOPS speed are capped by the the storage capacity and type, which is:

  • Write: 4.8ᵅ|300ᵇ
  • Read: 4.8ᵅ|300ᵇ

You can view what if anything is missing in your instance details:

https://console.cloud.google.com/sql/instances/[INSTANCE_NAME]

If you want to increase performance of your instance raise the number of its vCPUs and its storage capacity/type as sugested in the links above.