我正在开发一个连接到CloudSQL(GCP管理的mysql实例)的spring-boot应用程序。
最近,我开始遇到一些我不太了解的情况。 当用户突然涌入应用程序时,数据库CPU使用率达到峰值,并且停止响应。几分钟后,一切恢复正常。
GCP的人告诉我们,传入连接的突然激增是造成这种情况的原因,并且当中断发生时,数据库面临的传入连接的最大数量为668。
spring-boot应用程序在kubernetes中运行,并且会自动缩放。到目前为止,已扩展的最大容器数为70,hikari(弹簧引导连接池工具)配置的最大池大小设置为30。
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=30
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.max-lifetime=1800000
这是下面mysql配置的一部分。
max_allowed_packet 33554432
max_binlog_cache_size 18446744073709547520
max_binlog_size 104857600
max_binlog_stmt_cache_size 18446744073709547520
max_connect_errors 100
max_connections 4030
max_delayed_threads 20
max_digest_length 1024
max_error_count 64
max_execution_time 0
max_heap_table_size 16777216
max_insert_delayed_threads 20
max_join_size 18446744073709551615
max_length_for_sort_data 1024
max_points_in_geometry 65536
max_prepared_stmt_count 16382
max_relay_log_size 0
max_seeks_for_key 18446744073709551615
max_sort_length 1024
max_sp_recursion_depth 0
max_tmp_tables 32
max_user_connections 0
max_write_lock_count 18446744073709551615
我将非常感谢您的帮助。