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

标签 spring tomcat mariadb connection-pooling jdbc-pool

在阅读了多个基于 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/

相关文章:

java - Spring AOP。从 JoinPoint 获取 bean 名称

java - 上下文初始化失败/创建名为 'org.springframework.security.filterChains' 的 bean 时出错

java - JUnit 测试 SpringJUnit4ClassRunner

java - 来自 Servlet(tomcat 服务器)的 mysql jdbc 查询

eclipse - 无法使用 Tomcat 7 在 Eclipse 中运行 Maven 项目

php - PDO 内存耗尽

c - 适用于 OSX 的 MariaDB c 连接器

php - MariaDB - 发票编号 - 每年返回0

java - 采取什么方法使我的代码更通用 Java/Spring?

spring - 如何扩展 Spring Boot 应用程序?