【问题标题】:How to set TCP NODELAY for db connections on a spring boot application如何在 Spring Boot 应用程序上为数据库连接设置 TCP NODELAY
【发布时间】:2022-02-01 09:02:16
【问题描述】:

我有一个使用 Hikari 池基于 Spring Boot 和 Spring Data 构建的 Java Web 应用程序,部署在 azure Kubernetes 集群中,连接到 azure postgres 数据库。为了解决性能问题,Azure 团队建议为此应用程序设置 TCP NODELAY。你能告诉我如何为spring应用程序配置这个

【问题讨论】:

  • 在 PostgreSQL JDBC 驱动程序上设置tcpNoDelay 连接参数。

标签: java spring spring-boot spring-data


【解决方案1】:

在 PostgreSQL JDBC Driver 42.3.2 版本之后,您可以通过在 JDBC URL 末尾添加“tcpNoDelay=true”来使用 TCP_NODELAY 选项,例如 jdbc:postgresql://localhost:5432/postgres?tcpNoDelay=true 但在此版本之前不支持 TCP_NODELAY。

为 Spring Boot 更新 PostgreSQL JDBC 驱动程序 对于 Maven 项目,您可以设置 PostgreSQL 驱动程序版本,如

<properties>
   <postgresql.version>42.3.2</postgresql.version>
</properties>

在 pom.xml 中。

PostgreSQL JDBC 驱动程序更新;

问题链接:https://github.com/pgjdbc/pgjdbc/issues/2324

提交链接:https://github.com/pgjdbc/pgjdbc/commit/2a8ecbe2321ed92bc7051d3415a0484a5464346b#diff-af76c66c8a01becfcbfe739ba0cc2e4333e7d27865cb67cbb63db2e6f534801a

【讨论】:

    猜你喜欢
    • 2018-02-22
    • 2018-09-11
    • 1970-01-01
    • 2019-06-16
    • 1970-01-01
    • 2022-11-19
    • 2023-01-15
    • 2019-08-25
    • 2015-05-31
    相关资源
    最近更新 更多