【TDengine 使用环境】
预生产环境
【TDengine 版本】
3.4.1.13
【操作系统以及版本】
【部署方式】非容器部署
【集群节点数】
1
【集群副本数】
1
【描述业务影响】
同问,我这边在压测也发现同样的同样的问题。
taosadapter差不多内存能到40-50G
求教、请教: 有没有什么参数配置能进行adapter参数调优,(我这边的业务场景是 频繁写入/少量读)
代码中写入方式:STMT2 + async_insert
相关参数配置:
queryUseMemoryPool = 1
内存分配器 = jemalloc
./set_taos_malloc.sh -m 3
[root@localhost taos]# free -h
total used free shared buff/cache available
Mem: 61Gi 16Gi 37Gi 45Mi 6.2Gi 43Gi
Swap: 31Gi 7.5Gi 23Gi
[root@localhost taos]# cat taos.cfg
firstEp localhost.localdomain:6030
fqdn localhost.localdomain
serverPort 6030
dataDir /home/tdengine/lib/taos
logDir /home/tdengine/log/taos
tempDir /home/tdengine/tmp/taos
timezone Asia/Shanghai
locale en_US.UTF-8
charset UTF-8
========== 核心性能参数 ==========
numOfThreadsPerCore 2.0
numOfCores 40
ratioOfQueryCores 2.0
numOfCommitThreads 8
========== VNODE 核心配置 ==========
vnodes 48
maxVgroupsPerDb 48
minTablesPerVnode 1000
tableIncStepPerVnode 1000
========== 内存配置 ==========
cache 32
buffer 256
pages 256
pagesize 4
========== 其他优化 ==========
keepColumnName 1
telemetryReporting 0
maxShellConns 1000
logKeepDays 3
debugFlag 131
walLevel 1
walFsyncPeriod 3000
========== 监控上报(taosd → taoskeeper)==========
monitor 1
monitorFqdn localhost.localdomain
monitorPort 6043
monitorInterval 30
1、建议升级一下 tsdb 到最新版本;
2、taosadapter有两个控制内存使用的参数,可以试试:
感谢回复~
目前最新近况,已经使用这两个参数在taosadapter.toml中 控制,但是未生效;
但是我通过taosadapter.service
systemctl set-property taosadapter.service MemoryHigh=25G MemoryMax=30G
倒是可以最为兜底,但是内存仍然没法释放。
我看了 大于 3.4.1.13 OSS 的历届版本的changeLog没有看到具体提及 websocket 与taosadapter相关的fix
有哪些建议的稳定版本么
补充当前为 arm架构下的 3.4.1.13 社区版
我在代码层做了一个读写分流,定位到是读场景下 taosadapter导致的内存积增
具体是 聚合查询语句导致,因为是压测环境数据仿真,发现这个sql聚合查询超时抛出异常过后
“msg”: "\n### Error querying database. Cause: java.sql.SQLException: Error\n### The error may exist in …
随后taosadapter内存开始飙升的
现在最新的是3.4.2.8版本了,可以升级看一下情况。
同时 jdbc 驱动也要升级到最新版本。
qevolg
(郭振伟)
2026 年9 月 16 日 01:26
6
请帮忙区分 C 内存还是 Go 内存
方式一:
Go 运行时带内存统计功能,可以使用 pprof 即时获取,如果 taosadapter 配置中的 debug 配置项是 true 则可以通过 http://localhost:6041/debug/pprof/heap?debug=1 获取内存信息的可读文本,在文件最后部分关注三个参数
HeapSys(系统分配的堆内存)
含义:这表示 Go 语言运行时从操作系统中申请的总堆内存量。它可以被理解为运行时所管理的“内存池”的总大小。
解读:运行时会提前申请一大块内存(即“预留”)以供后续分配使用,从而减少向操作系统频繁申请的开销。
Stack(协程栈内存)
含义:这是所有 Goroutine(Go 轻量级线程)栈所占用的内存总和。
解读:在绝大多数业务逻辑下,每个 Goroutine 的栈初始大小很小(通常为几KB),因此此项的数值通常不高,可以作为一个次要观察项。如果发现此项异常高,可能需要检查是否创建了海量的 Goroutine 且未及时退出。
MaxRSS(最大常驻集大小)
含义:这是最为关键的指标,全称为“Maximum Resident Set Size”。它直接来自操作系统,表示 taosadapter进程当前实际占用的物理内存大小。
解读:此指标是判断程序真实内存消耗的黄金标准。HeapSys是从 Go 运行时视角看到的“虚拟”分配量,而 MaxRSS是从操作系统视角看到的“物理”使用量。由于 Go 的垃圾回收器(GC)在回收内存后,并不一定会立即将内存归还给操作系统(而是保留以便复用),因此只要 MaxRSS保持稳定在一个合理范围,就表明程序没有实质性的内存泄漏。在监控时,应首要关注 MaxRSS的趋势是否平稳。
# HeapSys = 99090432
# Stack = 1572864 / 1572864
# MaxRSS = 721453056
Go 内存 = HeapSys + Stack = (99090432 + 1572864)/1024/1024 = 96 M
C 内存 = MaxRSS - Go 内存 = 721453056/1024/1024 - 96 = 592 M
方式二:
taosAdapter 将内存信息会定时上报给 taosKeeper 并由 taosKeeper 记录到 log 库中,如果 debug 参数为 false 可使用此语句获取内存占用
taos> SELECT _wstart, endpoint, max(go_heap_sys + go_stack_sys)/1024/1024 as go_mb, max(rss)/1024/1024 as rss_mb, (max(rss)/1024/1024) - (max(go_heap_sys + go_stack_sys)/1024/1024) as c_mb FROM log.adapter_status WHERE _c0 > now() - 1h PARTITION BY endpoint INTERVAL(1m);
_wstart | endpoint | go_mb | rss_mb | c_mb |
===============================================================================================================================================
2025-12-04 17:02:00.000 | test-mem:6041 | 40 | 71 | 31 |
2025-12-04 17:03:00.000 | test-mem:6041 | 40 | 85.88671875 | 45.88671875 |
2025-12-04 17:04:00.000 | test-mem:6041 | 96 | 193.390625 | 97.390625 |
2025-12-04 17:05:00.000 | test-mem:6041 | 96 | 190.8359375 | 94.8359375 |
2025-12-04 17:06:00.000 | test-mem:6041 | 96 | 644.046875 | 548.046875 |
2025-12-04 17:07:00.000 | test-mem:6041 | 96 | 671.76171875 | 575.76171875 |
2025-12-04 17:08:00.000 | test-mem:6041 | 96 | 672.26171875 | 576.26171875 |
2025-12-04 17:09:00.000 | test-mem:6041 | 96 | 660.03125 | 564.03125 |
2025-12-04 17:10:00.000 | test-mem:6041 | 96 | 677.78125 | 581.78125 |
2025-12-04 17:11:00.000 | test-mem:6041 | 96 | 680.15625 | 584.15625 |
2025-12-04 17:12:00.000 | test-mem:6041 | 96 | 687.78125 | 591.78125 |
2025-12-04 17:13:00.000 | test-mem:6041 | 96 | 688.03125 | 592.03125 |
2025-12-04 17:14:00.000 | test-mem:6041 | 96 | 688.03125 | 592.03125 |
2025-12-04 17:15:00.000 | test-mem:6041 | 96 | 678.75 | 582.75 |
2025-12-04 17:16:00.000 | test-mem:6041 | 96 | 678.75 | 582.75 |
2025-12-04 17:17:00.000 | test-mem:6041 | 96 | 666.05859375 | 570.05859375 |
2025-12-04 17:18:00.000 | test-mem:6041 | 96 | 666.05859375 | 570.05859375 |
2025-12-04 17:19:00.000 | test-mem:6041 | 96 | 666.05859375 | 570.05859375 |
2025-12-04 17:20:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:21:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:22:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:23:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:24:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:25:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:26:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:27:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:28:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:29:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:30:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |
2025-12-04 17:31:00.000 | test-mem:6041 | 96 | 666.30859375 | 570.30859375 |