这篇文章主要讲解了“为什么PostgreSQL checkpointer后台进程使用这么多内存”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“为什么PostgreSQL checkpointer后台进程使用这么多内存”吧!
本节内容来源于PGer的一个问题:
Q:
为什么checkpointer后台进程使用这么多内存?
[pg12@localhost ~]$ ps -aux|grep postgres
pg12 1506 0.0 1.8 753156 34704 ? Ss 10:30 0:00 /appdb/xdb/pg12beta1/bin/postgres
pg12 1507 0.0 0.0 187304 1472 ? Ss 10:30 0:00 postgres: logger
pg12 1509 0.0 24.1 754120 452672 ? Ss 10:30 0:04 postgres: checkpointer
pg12 1510 0.0 28.4 753292 533184 ? Ss 10:30 0:08 postgres: background writer
pg12 1511 0.0 0.9 753260 18012 ? Ss 10:30 0:11 postgres: walwriter
pg12 1513 0.0 0.0 189420 1448 ? Ss 10:30 0:00 postgres: archiver last was 00000001000000020000005C
pg12 1514 0.0 0.0 189556 1324 ? Ss 10:30 0:00 postgres: stats collector
pg12 1515 0.0 0.1 753688 1984 ? Ss 10:30 0:00 postgres: logical replication launcher
pg12 2281 0.0 0.0 112660 972 pts/3 S+ 16:38 0:00 grep --color=auto postgres
[pg12@localhost ~]$ grep 'shared' $PGDATA/postgresql.conf
shared_buffers = 512MB # min 128kB
#shared_memory_type = mmap # the default is the first option
dynamic_shared_memory_type = posix # the default is the first option
#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers
#shared_preload_libraries = '' # (change requires restart)
比如上例,共享内存设置为512MB,在2G内存的机器上,checkpointer和background writer进程占用了差不多25%的内存大小.
A:
resident” RAM of a postgres subprocess is often just be the fraction of shared_buffers it’s read/written. checkpointer must necessarily read all dirty pages from s-b and write out to disk (by way of page cache), so that’s why its RSS is nearly 32GB. And the recovery process is continuously writing into s-b.
原因是checkpointer和bg writer需要从shared memory中读取数据(从s-b到page cache)并刷到磁盘上,因此给人占用大量内存的假象.
感谢各位的阅读,以上就是“为什么PostgreSQL checkpointer后台进程使用这么多内存”的内容了,经过本文的学习后,相信大家对为什么PostgreSQL checkpointer后台进程使用这么多内存这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:http://blog.itpub.net/6906/viewspace-2650715/