Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何优化Google Cloud SQL(MySQL)数据库以与API一起使用_Mysql_Google App Engine_Google Cloud Sql - Fatal编程技术网

如何优化Google Cloud SQL(MySQL)数据库以与API一起使用

如何优化Google Cloud SQL(MySQL)数据库以与API一起使用,mysql,google-app-engine,google-cloud-sql,Mysql,Google App Engine,Google Cloud Sql,我在谷歌云平台上创建了一个MySQL数据库 Machine type is db-n1-standard-2 with 2 vCPUs and 7.5 GB Memory. Network throughput (MB/s) is 500 of 2000 Storage type: SSD Disk throughput (MB/s) Read: 4.8 Write 4.8 IOPS Read: 300 Write: 300 Availability: High availability

我在谷歌云平台上创建了一个MySQL数据库

Machine type is db-n1-standard-2 with 2 vCPUs and 7.5 GB Memory. 
Network throughput (MB/s) is 500 of 2000
Storage type: SSD

Disk throughput (MB/s)
Read: 4.8
Write 4.8
IOPS
Read: 300
Write: 300

Availability: High availability

Database Flags:
max_connections: 500
我用Laravel Lumen创建了一个API,并让它在谷歌云平台上运行,成为一个应用程序引擎

runtime: php72
instance_class: F2
automatic_scaling:
    min_instances: 1
    max_instances: 20
    target_cpu_utilization: 0.7
    max_concurrent_requests: 80
    target_throughput_utilization: 0.8
如果我向带有postman的API发送请求,第一个响应需要1123ms。响应的大小为8.59 KB

如果我在1分钟内使用loader.io和250个客户端发送相同的请求, 测试已中止,因为它已达到错误阈值。 79.5%的错误率 平均响应=9141毫秒

最小/最大响应时间为:2081/10376 成功率:104 响应计数超时:403

当我查看MySQL错误日志时,我确实有很多这样的错误:

    2020-01-07 16:29:18.670 CET
2020-01-07T15:29:18.670275Z 1507 [Note] Aborted connection 1507 to db: 'mydatabasename' user: 'mydatabaseuser' host: 'cloudsqlproxy~172.217.35.158' (Got an error reading communication packets)

有人知道我如何解决这个问题吗?

我对这个错误进行了一些调查,并找到了一些关于如何诊断这类错误的有用指南。我相信,作为第一步,我们需要找到这个消息的真正原因(根据共享的链接,可能是由于各种原因),下面是我在其他帖子和之前分享的同一链接上重复的一些建议:

  • 检查以确保max_allowed_数据包的值足够高(可以在Cloud SQL中使用标志进行修改)
  • 客户端已成功连接,但未正确终止
  • 客户端睡眠时间超过定义的等待超时或交互超时秒
我要做的是继续尝试调整数据库标志,如google页面上的描述,并检查行为如何变化

如果您在调整实例时发现有用的东西,请告诉我们