Hi all, i have a strange issue when connecting to mysql from cloud functions. We have a function wrote on node js that connect through vpc serverless access to a sqlproxy that route the connection to our mysql db on compute instances. When i execute the function (it start a loop doing a select 1+1 for testing purpose) i see that the query is progressively slowing down. It start doing almost 20 query for second and after 2 o 3 seconds slow down to 2 / 4 query per second until the connection die after 10 - 15 minutes.
I suppose that some connection slow down is to be expected but executing the same function from a limited pod on a GKE that connect to the same sqlproxy it does circa 340 query per seconds.
It look like the VPC serverless access is the bottleneck but i find it very strange that it make the connection this slow.
Any suggestion?
When you deploy a VPC serveless, you will use a VPC connector. This VPC connector has a characteristic that will autoscale upward if more capacity is needed, but this behavior could increase your cost. So, if the connector was configured to be fixed in a static value to save costs, this could be the issue that is affecting the bandwidth that you require to process more queries.
Moreover, also the instance capacity could be the issue, because in order to process more queries, the instance needs more CPU, Memory and Disk capacity. So if the VM instance is overloaded, this issue could be the reason why the instance could not attend network requests. You can start troubleshooting by checking the log errors in Cloud Logging. This guide could help you to start your troubleshooting digging in the instance logs .