PostgreSQL 10.0 preview 功能增强 - 缓存自动预热, 直达性能巅峰

本文涉及的产品
RDS PostgreSQL Serverless,0.5-4RCU 50GB 3个月
推荐场景:
对影评进行热评分析
云数据库 RDS SQL Server,基础系列 2核4GB
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
简介: 标签 PostgreSQL , 10.0 , 自动预热缓存 背景 数据库的shared buffer可以用来存储经常使用的数据块,以提升效率。通过LRU算法老化不常用的数据块。 因此在生成数据库中,SHARED BUFFER中通常是热数据。

标签

PostgreSQL , 10.0 , 自动预热缓存


背景

数据库的shared buffer可以用来存储经常使用的数据块,以提升效率。通过LRU算法老化不常用的数据块。

因此在生产数据库中,SHARED BUFFER中通常是热数据。 

数据库如果重启,或者发生主备切换,缓存中的热数据需要从磁盘(或者OS PAGE CACHE)重新载入数据库的shared buffer。

当这个事情发生在业务高峰期时,由于热数据未在数据库缓存中,访问将会变慢,用户的感觉可能是请求变慢了。

为了提升用户体验,减少请求的响应时间的抖动,PostgreSQL 10.0推出了自动预热缓存的技术。

也就是说shared buffer的block list chain会记录下来,下次启动时,自动载入shared buffer.

# pg_autoprewarm.  

This a PostgreSQL contrib module which automatically dump all of the  
blocknums  
present in buffer pool at the time of server shutdown(smart and fast mode  
only,  
to be enhanced to dump at regular interval.) and load these blocks when  
server restarts.  

Design:  
------  
We have created a BG Worker Auto Pre-warmer which during shutdown dumps all  
the  
blocknum in buffer pool in sorted order.  
Format of each entry is  
<DatabaseId,TableSpaceId,RelationId,Forknum,BlockNum>.  
Auto Pre-warmer is started as soon as the postmaster is started we do not  
wait  
for recovery to finish and database to reach a consistent state. If there  
is a  
"dump_file" to load we start loading each block entry to buffer pool until  
there is a free buffer. This way we do not replace any new blocks which was  
loaded either by recovery process or querying clients. Then it waits until  
it receives  
SIGTERM to dump the block information in buffer pool.  

HOW TO USE:  
-----------  
Build and add the pg_autoprewarm to shared_preload_libraries. Auto  
Pre-warmer  
process automatically do dumping of buffer pool's block info and load them  
when  
restarted.  

TO DO:  
------  
Add functionality to dump based on timer at regular interval.  
And some cleanups.  
--   
Thanks and Regards  
Mithun C Y  
EnterpriseDB: http://www.enterprisedb.com  

这个patch的讨论,详见邮件组,本文末尾URL。

PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。

参考

https://commitfest.postgresql.org/13/848/

https://www.postgresql.org/message-id/flat/CAD__Ougw7Kc+1-cGA8GM0t+FuUHqPYR9Aow6OZX48sbH=V8BWw@mail.gmail.com#CAD__Ougw7Kc+1-cGA8GM0t+FuUHqPYR9Aow6OZX48sbH=V8BWw@mail.gmail.com

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
5月前
|
缓存 NoSQL Java
SpringBoot实现缓存预热的几种常用方案
SpringBoot实现缓存预热的几种常用方案
|
5月前
|
关系型数据库 Serverless 分布式数据库
【公测】PolarDB PostgreSQL版Serverless功能免费使用​!
【公测】PolarDB PostgreSQL版Serverless功能免费使用​,公测于2024年3月28日开始,持续三个月,公测期间可以免费使用!
|
18天前
|
缓存 NoSQL 关系型数据库
redis和缓存及相关问题和解决办法 什么是缓存预热、缓存穿透、缓存雪崩、缓存击穿
本文深入探讨了Redis缓存的相关知识,包括缓存的概念、使用场景、可能出现的问题(缓存预热、缓存穿透、缓存雪崩、缓存击穿)及其解决方案。
90 0
redis和缓存及相关问题和解决办法 什么是缓存预热、缓存穿透、缓存雪崩、缓存击穿
|
2月前
|
缓存 关系型数据库 数据库
PostgreSQL性能
【8月更文挑战第26天】PostgreSQL性能
58 1
|
1月前
|
缓存 关系型数据库 数据库
如何优化 PostgreSQL 数据库性能?
如何优化 PostgreSQL 数据库性能?
33 2
|
18天前
|
存储 关系型数据库 MySQL
四种数据库对比MySQL、PostgreSQL、ClickHouse、MongoDB——特点、性能、扩展性、安全性、适用场景
四种数据库对比 MySQL、PostgreSQL、ClickHouse、MongoDB——特点、性能、扩展性、安全性、适用场景
|
1月前
|
缓存 关系型数据库 数据库
PostgreSQL的性能
PostgreSQL的性能
97 2
|
5月前
|
关系型数据库 Serverless 分布式数据库
PolarDB PostgreSQL版Serverless功能上线公测啦,公测期间免费使用!
Serverless数据库能够使得数据库集群资源随客户业务负载动态弹性扩缩,将客户从复杂的业务资源评估和运维工作中解放出来。PolarDB PostgreSQL版 Serverless提供了CPU、内存、存储、网络资源的实时弹性能力,构建计算与存储分离架构下的 PolarDB PostgreSQL版产品新形态。
|
2月前
|
缓存 关系型数据库 数据库
PostgreSQL 查询性能
【8月更文挑战第5天】PostgreSQL 查询性能
64 8
|
2月前
|
关系型数据库 Java 数据库
PostgreSQL性能
【8月更文挑战第5天】PostgreSQL性能
70 7

相关产品

  • 云原生数据库 PolarDB
  • 云数据库 RDS PostgreSQL 版