<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>连接池 on Leanku</title>
    <link>https://blog.leanku.com/tags/%E8%BF%9E%E6%8E%A5%E6%B1%A0/</link>
    <description>Recent content in 连接池 on Leanku</description>
    <image>
      <url>https://blog.leanku.com/papermod-cover.png</url>
      <link>https://blog.leanku.com/papermod-cover.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Fri, 15 Aug 2025 20:46:01 +0800</lastBuildDate><atom:link href="https://blog.leanku.com/tags/%E8%BF%9E%E6%8E%A5%E6%B1%A0/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>连接池</title>
      <link>https://blog.leanku.com/post/microservice/%E8%BF%9E%E6%8E%A5%E6%B1%A0/</link>
      <pubDate>Fri, 15 Aug 2025 20:46:01 +0800</pubDate>
      
      <guid>https://blog.leanku.com/post/microservice/%E8%BF%9E%E6%8E%A5%E6%B1%A0/</guid>
      <description>连接池 一、概述 1.1 什么是连接池 连接池（Connection Pool）是：
预先创建一定数量的连接，并统一管理和复用这些连接，而不是每次请求都重新建立连接。
这里的&amp;quot;连接&amp;quot;不仅指数据库连接，还包括：
MySQL 连接 Redis 连接 HTTP 连接 gRPC 连接 Kafka 连接 RabbitMQ 连接 本质上，只要是建立成本较高、可以复用的连接，都适合使用连接池。
1.2 为什么需要连接池 假设没有连接池：
每个请求执行流程如下：
HTTP Request │ ▼ 创建 MySQL 连接 │ ▼ 执行 SQL │ ▼ 关闭连接 如果系统每秒有 5000 个请求, 服务器的大量资源都会浪费在建立连接上，而不是执行业务。
1.3 建立一个连接到底需要做什么？ 以 MySQL 为例：
Application │ ▼ TCP 三次握手 │ ▼ SSL/TLS（可选） │ ▼ MySQL 用户认证 │ ▼ 权限校验 │ ▼ 初始化 Session │ ▼ 返回连接对象 这整个过程远比执行一条简单 SQL 更耗时。</description>
    </item>
    
  </channel>
</rss>
