gpt4 book ai didi

spring - 部署在连接到 mariadb 的 tomcat 上的 spring 应用程序的连接池的最佳选择

转载 作者:行者123 更新时间:2023-11-29 00:01:34 24 4
gpt4 key购买 nike

在阅读了多个基于 jdbc 连接池的文档后,我无法得出一些结论。对于部署在 tomcat 上并连接到 mariadb 的 spring 应用程序,哪种连接池方法最适合。

mariadb 提供自己的连接池,另一方面存在多个外部池库 HikariCp、DBCP、tomcat-jdbc 等。

最佳答案

关于 MariaDB 的连接池似乎没有任何基准,因此给出答案可能会很自以为是,而且它还取决于您的用例,因为基准只有在查看正确的数据时才有意义。

你会在这里找到https://mariadb.com/fr/node/1829 MariaDB 关于提供另一种连接池实现的论点。

Here are some of the reasons:

  • Reliability: When reusing a connection from pool, the connection must be like a "new freshly created" connection. Depending on connection state, frameworks may result executing multiple commands to reset state (Some frameworks even choose to skip some of those reset to avoid some performance impact). MariaDB has a dedicated command to refresh connection state permitting real reset (rollback remaining transaction, reset transaction isolation level, reset session variables, delete user variables, remove all PREPARE statement, ...) in one command.
  • Performance: The pool can save some information at the first connection, allowing faster creations when making the next connection.
  • Easy configuration: Solve some frequent issues, like server will close socket if not used after some time (wait_timeout default to 8h). Pool implementation avoids keeping a connection in a bad state

对于其他 CP 实现,有很多基准测试,HikariCP 从中脱颖而出,作为一个整体更好的选择,现在是 Spring Boot 2 中的默认设置。

最后,它归结为您尝试 MariaDB 的连接池或依赖已经建立的实现。

关于spring - 部署在连接到 mariadb 的 tomcat 上的 spring 应用程序的连接池的最佳选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50718948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com