java - 如何处理从 spring-boot 到 mysql 数据库的连接池错误?
问题描述
我正在开发一个连接到 CloudSQL(GCP 管理的 mysql 实例)的 spring-boot 应用程序。
最近我开始遇到一些我不能很好理解的情况。当用户突然涌入应用程序时,数据库 CPU 利用率达到峰值并停止响应。然后几分钟后一切恢复正常。
来自 GCP 的人员表示,传入连接的突然爆发导致了这种情况,并且数据库面临的最大传入连接数在中断发生时为 668。
spring-boot 应用程序在 kubernetes 中运行并自动扩展。Max pods(containers) 扩展到现在是 70,hikari(spring-boot 连接池工具) 配置 maximum-pool-size 设置为 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
我将非常感谢一些帮助。
解决方案
推荐阅读
- xpath - XPath - 已访问或未访问的链接?
- php - stripos 函数的奇怪结果
- python-3.x - Python 没有为多元线性回归注册列 - Jupyter notebook
- html - 无法向左移动卡片列表
- pic - I2C 在 DS3231 的 PIC18F46K22 中不起作用
- sql - 根据具有连接值的列从其他表中获取数据
- java - Java中泛型集合的迭代
- powershell - 管道对象到选择字符串出现空
- amazon-web-services - 从 Lambda 函数切换 Amazon 智能插头
- ruby - application_responder (LoadError) Rails 6