云数据库 GaussDB-连接设置:max_connections

时间:2023-11-01 16:22:49

max_connections

参数说明:允许和数据库连接的最大并发连接数。此参数会影响集群的并发能力。

该参数属于POSTMASTER类型参数,请参考表1中对应设置方法进行设置。

取值范围:整型。最小值为10(要大于max_wal_senders),理论最大值为262143,实际最大值为动态值,计算公式为“262143 - job_queue_processes - autovacuum_max_workers - max_inner_tool_connections - AUXILIARY_BACKENDS - AV_LAUNCHER_PROCS - min(max(newValue/4,64),1024)”,job_queue_processesautovacuum_max_workersmax_inner_tool_connections的值取决于对应GUC参数的设置,AUXILIARY_BACKENDS为预留辅助线程数固定为20,AV_LAUNCHER_PROCS为预留autovacuum的launcher线程数固定为2,min(max(newValue/4,64),1024)公式中newValue为新设置的值。

默认值:

  • 独立部署:

    CN:8000(60核CPU/480G内存);4000(32核CPU/256G内存);2000(16核CPU/128G内存);1000(8核CPU/64G内存);100(4核CPU/32G内存,4核CPU/16G内存)

    DN:24000(60核CPU/480G内存);12000(32核CPU/256G内存);6000(16核CPU/128G内存);2500(8核CPU/64G内存);100(4核CPU/32G内存,4核CPU/16G内存)

  • 金融版(标准型):

    CN:6000(128核CPU/1024G内存,104核CPU/1024G内存,96核CPU/1024G内存);4000(96核CPU/768G内存);3500(80核CPU/640G内存);3000(72核CPU/576G内存);2500(64核CPU/512G内存);2250(60核CPU/480G内存);1000(32核CPU/256G内存);500(16核CPU/128G内存);200(8核CPU/64G内存)

    DN:21000(128核CPU/1024G内存,104核CPU/1024G内存,96核CPU/1024G内存);16000(96核CPU/768G内存);14000(80核CPU/640G内存);12000(72核CPU/576G内存);11000(64核CPU/512G内存);9000(60核CPU/480G内存);4000(32核CPU/256G内存);2000(16核CPU/128G内存);1000(8核CPU/64G内存)

  • 企业版:

    CN:4000(128核CPU/1024G内存,104核CPU/1024G内存,96核CPU/1024G内存);3000(96核CPU/768G内存);2500(80核CPU/640G内存);2000(80核CPU/512G内存,72核CPU/576G内存,64核CPU/512G内存);1800(60核CPU/480G内存);900(32核CPU/256G内存);350(16核CPU/128G内存);200(8核CPU/64G内存)

    DN:15000(128核CPU/1024G内存,104核CPU/1024G内存,96核CPU/1024G内存);11000(96核CPU/768G内存);10000(80核CPU/640G内存);8500(72核CPU/576G内存);7500(80核CPU/512G内存,64核CPU/512G内存);7000(60核CPU/480G内存);3500(32核CPU/256G内存);1500(16核CPU/128G内存);900(8核CPU/64G内存)

  • 金融版(数据计算型):

    CN:2500(96核CPU/768G内存);1000(72核CPU/576G内存);500(64核CPU/512G内存);200(32核CPU/256G内存)

    DN:8000(96核CPU/768G内存);5000(72核CPU/576G内存);4000(64核CPU/512G内存);1000(32核CPU/256G内存)

配置不当时影响:

若配置max_connections过大,超过计算公式所描述的最大动态值,会出现节点拉起失败问题,报错提示“invalid value for parameter "max_connections"”;或在拉起时申请内存失败,报错提示“Cannot allocate memory”;

若未按照对外出口规格配置仅调大max_connections参数值,未同比例调整内存参数。业务压力大时,容易出现内存不足,报错提示“memory is temporarily unavailable”;

混合部署场景下,若CN的max_connections参数值大于(DN的max_connections/CN个数)时,客户端总压力超过DN端max_connections值时,可能会出现CN节点连接DN失败情况,报错提示“pooler... Too many clients already”。

  • 对于管理员用户的连接数限制会略超过max_connections设置,目的是为了让管理员在连接被普通用户占满后仍可以连接上数据库,再超过一定范围(sysadmin_reserved_connections参数)后才会报错。即管理员用户的最大连接数等于max_connections + sysadmin_reserved_connections。
  • 对于普通用户来说,由于内部作业也会使用一些链接,因此会略小于max_connections,具体值取决于内部链接个数。
  • 开启线程池后,stream线程数的上限为max_connections设置值。若stream线程数量达到上限时,将产生“Exceed stream thread pool limitation...”报错,此时可以通过调整max_connections参数值将stream线程数上限调高。由于该参数属于POSTMASTER类型,故设置时可以综合业务情况进行合理预估:stream线程数总数 = 业务并发数 * 每一个并发执行的语句所消耗的stream线程数量(可通过执行计划查看)。
support.huaweicloud.com/distributed-devg-v2-opengauss/gaussdb-v5r2c10-1436.html