In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to configure hikari connection pool properties in spring boot, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Spring boot configure hikari connection Pool Properties
The cause of the event is that Young GC often occurs in a simple application, and GC (Allocation Failure) often occurs even when there is no number of requests. Later, using mat tool to analyze, it is found that the class related to mysql connection actually accounts for 40% + in-heap space.
Only to find that the connection pool size of spring boot is not configured, and the default is 10 connections, but in fact, the application does not need so many.
The class "com.mysql.cj.jdbc.AbandonedConnectionCleanupThread", loaded by "org.apache.catalina.loader.ParallelWebappClassLoader @ 0xf8dfdf30", occupies 19279792 (41.23%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Node []" loaded by ".spring-boot default connection pool
In spring-boot, load the connection pool according to the following three priorities
1) if there is HikariCP in classpath, it is preferred.
2) if the Tomcat pooling connection pool is available, it will be selected
3) if there is none of the above, Commons DBCP2 connection pool will be selected.
Hikari configuration
Here we do a very low configuration (this is just a very low-traffic system), if the default server, it is recommended that the default configuration is sufficient.
Spring.datasource.hikari.maximum-pool-size=2spring.datasource.hikari.minimum-idle=1spring.datasource.hikari.idle-timeout=600000spring.datasource.hikari.max-lifetime=1800000spring.datasource.hikari.connection-timeout=500spring.datasource.hikari.login-timeout=500spring.datasource.hikari.validation-timeout=1000spring.datasource.hikari.initialization-fail-timeout=1000
Reference link
Hikari connection Pool configuration instructions # # Database configuration spring.datasource.type=com.zaxxer.hikari.HikariDataSourcespring.datasource.driverClassName = com.mysql.jdbc.Driverspring.datasource.url = jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=utf-8&useSSL=falsespring.datasource.username = rootspring.datasource.password = root## Hikari connection Pool configuration-for more configuration, please visit: https://github.com/brettwooldridge/HikariCP## minimum idle connection Number of spring.datasource.hikari.minimum-idle=5## idle connections maximum survival time Default is 600000 (10 minutes) maximum number of connections in the spring.datasource.hikari.idle-timeout=180000## connection pool. Default is 10spring.datasource.hikari.maximum-pool-size=10##. This attribute controls the default autocommit behavior of connections returned from the pool. Default: truespring.datasource.hikari.auto-commit=true## connection pool name spring.datasource.hikari.pool-name=MyHikariCP## this attribute controls the maximum life cycle of connections in the pool, with a value of 0 indicating unlimited life cycle. Default 1800000 is 30 minutes spring.datasource.hikari.max-lifetime=1800000## database connection timeout, default 30 seconds, that is, above 30000spring.datasource.hikari.connection-timeout=30000spring.datasource.hikari.connection-test-query=SELECT 1 is "how to configure hikari connection pool properties in spring boot" all the content of this article, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.