Show HN: PostgreSQL 在 23 种 EC2 实例类型上的性能与成本

Hacker News Top 工具

摘要

一个比较 AWS 上 23 种 EC2 实例类型的 PostgreSQL 性能与成本的网站,基准测试达到 33,000 RPS。

嘿!我是 Andrei。<p>我对人们倾向于构建过于复杂的后端系统感到沮丧,这些系统往往受到大型科技公司案例研究和热门书籍的“激励”。<p>因此,我开始探索精益架构,并构建我的数字花园,收集与此方向一致的想法、方法和数据。<p>这里我想介绍其中一个工具——PostgreSQL 容量规划工具。我在不同的 EC2 实例和磁盘上对 PostgreSQL 进行了基准测试,使用了不同的初始数据集,以了解这些实例所能提供的性能。我还构建了一个可视化这些数据的工具,欢迎你来探索。<p>因此,你可以输入常用的参数,比如所需的 RPS 和磁盘大小,然后找出最符合你需求且最具成本效益的实例。<p>你可以在此处了解方法论:<a href="https://postgres.saneengineer.com/about" rel="nofollow">https://postgres.saneengineer.com/about</a><p>我测试了一种工作负载——混合 90/10 读写比例,并且只测试了部分配置。但它是可扩展的,我和(你也可以——基准测试是开源的:<a href="https://github.com/anivaniuk/sanebench" rel="nofollow">https://github.com/anivaniuk/sanebench</a>)可以运行更多配置以获得更多数据。<p>看起来有趣吗?接下来我应该测试哪种工作负载?
查看原文
查看缓存全文

缓存时间: 2026/07/07 17:13

# AWS 上的 PostgreSQL:EC2 实例容量评估与基准测试 来源:https://postgres.saneengineer.com/ **目标吞吐量** 33,000 RPS **达到目标的最便宜配置** m8g.large (https://postgres.saneengineer.com/instances/m8g.large) gp3-baseline · Graviton **安全选择 · ≥20% 余量** m8g.large (https://postgres.saneengineer.com/instances/m8g.large) gp3-baseline · Graviton **最佳 RPS 每美元/小时** c8i.large (https://postgres.saneengineer.com/instances/c8i.large) gp3-baseline · x86-64 在 52 种配置中有 **30** 种在 1GB 下能达标 **33,000 RPS**。最便宜的是 **m8g.large** 搭配 **gp3-baseline**,每月仅 **$82**。每个点代表实例 × 磁盘;虚线为性价比前沿;arm64(Graviton)为绿色,x86-64 为石板色。 共 52 行 1GB 下的 PostgreSQL 基准测试结果——包含所有实例 × 磁盘组合,可排序与筛选。达标 33,000 RPS 的最便宜配置已高亮显示。 c8i.large (https://postgres.saneengineer.com/instances/c8i.large) | c8i (https://postgres.saneengineer.com/families/c8i) | x86-64 | gp3-baseline | 2 | 452,203±0.4% | 451,476 | $0.1156/hr ~$84/mo | 0.61±0.4% | 2.16±0.1% | 2.79±0.2% | 26,102 | 13,051 | 1.6× m8g.large (https://postgres.saneengineer.com/instances/m8g.large) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-baseline | 2 | 845,515±0.1% | 407,555 | $0.1117/hr ~$82/mo | 0.70±0.1% | 2.02±0.3% | 2.76±0.2% | 22,757 | 5,689 | 1.4× m8g.xlarge (https://postgres.saneengineer.com/instances/m8g.xlarge) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-baseline | 4 | 1670,871±0.1% | 351,826 | $0.2014/hr ~$147/mo | 0.45±0.1% | 1.83±0.1% | 2.32±0.1% | 17,718 | 4,429 | 2.1× m7i.large (https://postgres.saneengineer.com/instances/m7i.large) | m7i (https://postgres.saneengineer.com/families/m7i) | x86-64 | gp3-baseline | 2 | 841,305±0.4% | 336,586 | $0.1227/hr ~$90/mo | 0.77±0.4% | 2.33±0.2% | 3.11±0.2% | 20,653 | 5,163 | 1.3× m7g.xlarge (https://postgres.saneengineer.com/instances/m7g.xlarge) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-baseline | 4 | 1658,726±0.4% | 317,234 | $0.1851/hr ~$135/mo | 0.54±0.4% | 1.98±0.1% | 2.44±0.3% | 14,681 | 3,670 | 1.8× c8i.xlarge (https://postgres.saneengineer.com/instances/c8i.xlarge) | c8i (https://postgres.saneengineer.com/families/c8i) | x86-64 | gp3-baseline | 4 | 864,585±0.1% | 308,522 | $0.2093/hr ~$153/mo | 0.50±0.1% | 1.85±0.2% | 2.27±0.1% | 16,146 | 8,073 | 2.0× r8g.large (https://postgres.saneengineer.com/instances/r8g.large) | r8g (https://postgres.saneengineer.com/families/r8g) | arm64 | gp3-baseline | 2 | 1638,531±1.6% | 304,746 | $0.1264/hr ~$92/mo | 0.83±1.6% | 2.35±0.6% | 3.06±0.4% | 19,266 | 2,408 | 1.2× m7i.xlarge (https://postgres.saneengineer.com/instances/m7i.xlarge) | m7i (https://postgres.saneengineer.com/families/m7i) | x86-64 | gp3-baseline | 4 | 1665,582±0.2% | 293,410 | $0.2235/hr ~$163/mo | 0.49±0.1% | 1.86±0.2% | 2.30±0.2% | 16,396 | 4,099 | 2.0× r8g.xlarge (https://postgres.saneengineer.com/instances/r8g.xlarge) | r8g (https://postgres.saneengineer.com/families/r8g) | arm64 | gp3-baseline | 4 | 3264,627±0.6% | 279,821 | $0.2310/hr ~$169/mo | 0.49±0.6% | 1.89±0.5% | 2.32±0.6% | 16,157 | 2,020 | 2.0× m8g.medium (https://postgres.saneengineer.com/instances/m8g.medium) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-baseline | 1 | 416,670±0.4% | 249,555 | $0.0668/hr ~$49/mo | 1.92±0.4% | 3.44±0.5% | 4.28±0.6% | 16,670 | 4,167 | 0.5× m7g.large (https://postgres.saneengineer.com/instances/m7g.large) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-baseline | 2 | 824,669±0.4% | 238,304 | $0.1035/hr ~$76/mo | 1.30±0.4% | 2.83±0.4% | 3.58±0.4% | 12,334 | 3,084 | 0.7× r8g.medium (https://postgres.saneengineer.com/instances/r8g.medium) | r8g (https://postgres.saneengineer.com/families/r8g) | arm64 | gp3-baseline | 1 | 816,482±0.2% | 222,197 | $0.0742/hr ~$54/mo | 1.94±0.2% | 3.51±0.1% | 4.29±0.2% | 16,482 | 2,060 | 0.5× m7g.2xlarge (https://postgres.saneengineer.com/instances/m7g.2xlarge) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-baseline | 8 | 3277,197±1.6% | 221,629 | $0.3483/hr ~$254/mo | 0.41±1.6% | 1.81±0.2% | 2.22±0.2% | 9,650 | 2,412 | 2.3× m8g.2xlarge (https://postgres.saneengineer.com/instances/m8g.2xlarge) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-baseline | 8 | 3281,451±0.7% | 213,807 | $0.3810/hr ~$278/mo | 0.39±0.7% | 1.75±0.3% | 2.13±0.1% | 10,181 | 2,545 | 2.5× c8i.large (https://postgres.saneengineer.com/instances/c8i.large) | c8i (https://postgres.saneengineer.com/families/c8i) | x86-64 | gp3-max | 2 | 453,444±0.4% | 211,563 | $0.2526/hr ~$184/mo | 0.60±0.4% | 2.17±0.1% | 2.83±0.7% | 26,722 | 13,361 | 1.6× c8i.xlarge (https://postgres.saneengineer.com/instances/c8i.xlarge) | c8i (https://postgres.saneengineer.com/families/c8i) | x86-64 | gp3-max | 4 | 869,067±0.2% | 199,429 | $0.3463/hr ~$253/mo | 0.46±0.2% | 1.85±0.1% | 2.30±0.1% | 17,267 | 8,633 | 2.1× m8g.xlarge (https://postgres.saneengineer.com/instances/m8g.xlarge) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-max | 4 | 1667,428±0.2% | 199,242 | $0.3384/hr ~$247/mo | 0.47±0.2% | 1.86±0.2% | 2.30±0.4% | 16,857 | 4,214 | 2.0× r8g.xlarge (https://postgres.saneengineer.com/instances/r8g.xlarge) | r8g (https://postgres.saneengineer.com/families/r8g) | arm64 | gp3-max | 4 | 3269,292±0.2% | 188,322 | $0.3679/hr ~$269/mo | 0.46±0.2% | 1.87±0.2% | 2.36±1.1% | 17,323 | 2,165 | 2.1× m5.xlarge (https://postgres.saneengineer.com/instances/m5.xlarge) | m5 (https://postgres.saneengineer.com/families/m5) | x86-64 | gp3-baseline | 4 | 1639,959±0.7% | 186,794 | $0.2139/hr ~$156/mo | 0.80±0.7% | 2.22±0.3% | 2.68±0.3% | 9,990 | 2,497 | 1.2× m7g.xlarge (https://postgres.saneengineer.com/instances/m7g.xlarge) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-max | 4 | 1657,738±0.1% | 179,252 | $0.3221/hr ~$235/mo | 0.55±0.1% | 2.00±0.2% | 2.48±0.3% | 14,434 | 3,609 | 1.7× m7g.medium (https://postgres.saneengineer.com/instances/m7g.medium) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-baseline | 1 | 410,986±0.1% | 175,171 | $0.0627/hr ~$46/mo | 2.91±0.1% | 4.76±0.1% | 5.83±0.2% | 10,986 | 2,747 | 0.3× m7i.2xlarge (https://postgres.saneengineer.com/instances/m7i.2xlarge) | m7i (https://postgres.saneengineer.com/families/m7i) | x86-64 | gp3-baseline | 8 | 3273,190±0.5% | 172,163 | $0.4251/hr ~$310/mo | 0.44±0.5% | 1.80±0.2% | 2.18±0.1% | 9,149 | 2,287 | 2.2× m5.large (https://postgres.saneengineer.com/instances/m5.large) | m5 (https://postgres.saneengineer.com/families/m5) | x86-64 | gp3-baseline | 2 | 820,293±0.2% | 172,092 | $0.1179/hr ~$86/mo | 1.58±0.2% | 3.12±0.2% | 3.88±0.4% | 10,146 | 2,537 | 0.6× m7i.xlarge (https://postgres.saneengineer.com/instances/m7i.xlarge) | m7i (https://postgres.saneengineer.com/families/m7i) | x86-64 | gp3-max | 4 | 1660,805±0.2% | 168,667 | $0.3605/hr ~$263/mo | 0.53±0.2% | 1.90±0.1% | 2.35±0.1% | 15,201 | 3,800 | 1.8× m7i.large (https://postgres.saneengineer.com/instances/m7i.large) | m7i (https://postgres.saneengineer.com/families/m7i) | x86-64 | gp3-max | 2 | 841,465±3.3% | 159,663 | $0.2597/hr ~$190/mo | 0.77±3.2% | 2.31±0.2% | 2.98±1.4% | 20,733 | 5,183 | 1.3× m8g.2xlarge (https://postgres.saneengineer.com/instances/m8g.2xlarge) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-max | 8 | 3281,697±0.4% | 157,734 | $0.5179/hr ~$378/mo | 0.39±0.4% | 1.76±0.1% | 2.14±0.2% | 10,212 | 2,553 | 2.5× c8i.2xlarge (https://postgres.saneengineer.com/instances/c8i.2xlarge) | c8i (https://postgres.saneengineer.com/families/c8i) | x86-64 | gp3-baseline | 8 | 1661,861±0.1% | 155,916 | $0.3968/hr ~$290/mo | 0.52±0.1% | 1.86±0.2% | 2.24±0.1% | 7,733 | 3,866 | 1.9× m8g.large (https://postgres.saneengineer.com/instances/m8g.large) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-max | 2 | 838,463±0.3% | 154,678 | $0.2487/hr ~$182/mo | 0.83±0.3% | 2.36±0.2% | 3.06±0.3% | 19,231 | 4,808 | 1.2× r8g.large (https://postgres.saneengineer.com/instances/r8g.large) | r8g (https://postgres.saneengineer.com/families/r8g) | arm64 | gp3-max | 2 | 1639,039±0.6% | 148,198 | $0.2634/hr ~$192/mo | 0.82±0.6% | 2.35±0.1% | 3.06±0.1% | 19,519 | 2,440 | 1.2× m7g.2xlarge (https://postgres.saneengineer.com/instances/m7g.2xlarge) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-max | 8 | 3267,275±0.2% | 138,625 | $0.4853/hr ~$354/mo | 0.48±0.2% | 1.89±0.2% | 2.29±0.3% | 8,409 | 2,102 | 2.0× m7i.2xlarge (https://postgres.saneengineer.com/instances/m7i.2xlarge) | m7i (https://postgres.saneengineer.com/families/m7i) | x86-64 | gp3-max | 8 | 3277,126±0.4% | 137,210 | $0.5621/hr ~$410/mo | 0.41±0.4% | 1.80±0.2% | 2.18±0.3% | 9,641 | 2,410 | 2.3× c8i.2xlarge (https://postgres.saneengineer.com/instances/c8i.2xlarge) | c8i (https://postgres.saneengineer.com/families/c8i) | x86-64 | gp3-max | 8 | 1668,311±0.7% | 127,984 | $0.5337/hr ~$390/mo | 0.47±0.7% | 1.83±0.3% | 2.21±0.4% | 8,539 | 4,269 | 2.1× m5.2xlarge (https://postgres.saneengineer.com/instances/m5.2xlarge) | m5 (https://postgres.saneengineer.com/families/m5) | x86-64 | gp3-baseline | 8 | 3251,445±0.1% | 126,737 | $0.4059/hr ~$296/mo | 0.62±0.1% | 2.01±0.1% | 2.41±0.1% | 6,431 | 1,608 | 1.6× m5.xlarge (https://postgres.saneengineer.com/instances/m5.xlarge) | m5 (https://postgres.saneengineer.com/families/m5) | x86-64 | gp3-max | 4 | 1639,479±0.4% | 112,506 | $0.3509/hr ~$256/mo | 0.81±0.4% | 2.24±0.2% | 2.69±0.2% | 9,870 | 2,467 | 1.2× m7g.large (https://postgres.saneengineer.com/instances/m7g.large) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-max | 2 | 824,684±1.0% | 102,635 | $0.2405/hr ~$176/mo | 1.30±1.0% | 2.87±0.8% | 3.66±0.9% | 12,342 | 3,086 | 0.7× m5.2xlarge (https://postgres.saneengineer.com/instances/m5.2xlarge) | m5 (https://postgres.saneengineer.com/families/m5) | x86-64 | gp3-max | 8 | 3251,430±0.3% | 94,731 | $0.5429/hr ~$396/mo | 0.62±0.3% | 2.02±0.3% | 2.42±0.3% | 6,429 | 1,607 | 1.6× m8g.medium (https://postgres.saneengineer.com/instances/m8g.medium) | m8g (https://postgres.saneengineer.com/families/m8g) | arm64 | gp3-max | 1 | 416,487±0.2% | 80,903 | $0.2038/hr ~$149/mo | 1.94±0.2% | 3.53±0.2% | 4.31±0.2% | 16,487 | 4,122 | 0.5× t3.small (https://postgres.saneengineer.com/instances/t3.small) | t3 (https://postgres.saneengineer.com/families/t3) | x86-64 | gp3-baseline | 2 | 23,353±1.1% | 78,486 | $0.0427/hr ~$31/mo | 9.55±1.1% | 66.53±0.1% | 71.05±0.2% | 1,676 | 1,676 | 0.1× m5.large (https://postgres.saneengineer.com/instances/m5.large) | m5 (https://postgres.saneengineer.com/families/m5) | x86-64 | gp3-max | 2 | 819,627±0.3% | 76,997 | $0.2549/hr ~$186/mo | 1.63±0.3% | 3.16±0.2% | 3.83±0.2% | 9,813 | 2,453 | 0.6× r8g.medium (https://postgres.saneengineer.com/instances/r8g.medium) | r8g (https://postgres.saneengineer.com/families/r8g) | arm64 | gp3-max | 1 | 816,050±7.7% | 76,008 | $0.2112/hr ~$154/mo | 2.01±7.7% | 3.68±7.5% | 4.74±10.2% | 16,050 | 2,006 | 0.5× t4g.small (https://postgres.saneengineer.com/instances/t4g.small) | t4g (https://postgres.saneengineer.com/families/t4g) | arm64 | gp3-baseline | 2 | 22,842±1.5% | 73,413 | $0.0387/hr ~$28/mo | 11.26±1.5% | 67.66±0.1% | 72.49±0.1% | 1,421 | 1,421 | 0.1× t4g.medium (https://postgres.saneengineer.com/instances/t4g.medium) | t4g (https://postgres.saneengineer.com/families/t4g) | arm64 | gp3-baseline | 2 | 43,394±0.9% | 61,132 | $0.0555/hr ~$41/mo | 9.43±0.9% | 66.40±0.2% | 69.87±0.1% | 1,697 | 848 | 0.1× t4g.large (https://postgres.saneengineer.com/instances/t4g.large) | t4g (https://postgres.saneengineer.com/families/t4g) | arm64 | gp3-baseline | 2 | 85,157±0.3% | 57,870 | $0.0891/hr ~$65/mo | 6.20±0.3% | 56.39±0.1% | 62.81±0.1% | 2,579 | 645 | 0.2× m7g.medium (https://postgres.saneengineer.com/instances/m7g.medium) | m7g (https://postgres.saneengineer.com/families/m7g) | arm64 | gp3-max | 1 | 411,200±0.3% | 56,085 | $0.1997/hr ~$146/mo | 2.86±0.3% | 4.64±0.1% | 5.67±0.2% | 11,200 | 2,800 | 0.3× t3.medium (https://postgres.saneengineer.com/instances/t3.medium) | t3 (https://postgres.saneengineer.com/families/t3) | x86-64 | gp3-baseline | 2 | 43,401±2.8% | 53,551 | $0.0635/hr ~$46/mo | 9.41±2.8% | 66.21±0.1% | 71.13±0.3% | 1,701 | 850 | 0.1× t3.large (https://postgres.saneengineer.com/instances/t3.large) | t3 (https://postgres.saneengineer.com/families/t3) | x86-64 | gp3-baseline | 2 | 85,315±0.4% | 50,562 | $0.1051/hr ~$77/mo | 6.02±0.4% | 56.08±0.1% | 61.05±0.0% | 2,657 | 664 | 0.2× t4g.large (https://postgres.saneengineer.com/instances/t4g.large) | t4g (https://postgres.saneengineer.com/families/t4g) | arm64 | gp3-max | 2 | 85,028±0.3% | 22,238 | $0.2261/hr ~$165/mo | 6.36±0.3% | 57.73±0.0% | 60.23±0.1% | 2,514 | 629 | 0.2× t3.large (https://postgres.saneengineer.com/instances/t3.large) | t3 (https://postgres.saneengineer.com/families/t3) | x86-64 | gp3-max | 2 | 84,985±2.7% | 20,589 | $0.2421/hr ~$177/mo | 6.42±2.7% | 52.98±1.6% | 61.70±0.1% | 2,492 | 623 | 0.2× t3.small (https://postgres.saneengineer.com/instances/t3.small) | t3 (https://postgres.saneengineer.com/families/t3) | x86-64 | gp3-max | 2 | 23,205±0.5% | 17,833 | $0.1797/hr ~$131/mo | 9.99±0.5% | 66.65±0.0% | 71.23±0.2% | 1,602 | 1,602 | 0.1× t4g.small (https://postgres.saneengineer.com/instances/t4g.small) | t4g (https://postgres.saneengineer.com/families/t4g) | arm64 | gp3-max | 2 | 23,126±2.8% | 17,791 | $0.1757/hr ~$128/mo | 10.24±2.8% | 66.61±0.2% | 70.09±0.1% | 1,563 | 1,563 | 0.1× t4g.medium (https://postgres.saneengineer.com/instances/t4g.medium) | t4g (https://postgres.saneengineer.com/families/t4g) | arm64 | gp3-max | 2 | 43,287±0.5% | 17,075 | $0.1925/hr ~$141/mo | 9.74±0.5% | 66.62±0.1% | 70.04±0.0% | 1,644 | 822 | 0.1× t3.medium (https://postgres.saneengineer.com/instances/t3.medium) | t3 (https://postgres.saneengineer.com/families/t3) | x86-64 | gp3-max | 2 | 43,243±0.5% | 16,172 | $0.2005/hr ~$146/mo | 9.87±0.5% | 66.46±0.1% | 71.26±0.2% | 1,621 | 811 | 0.1×

相似文章

大规模并行 Postgres 备份

Hacker News Top

PlanetScale 描述了它如何通过为每个分片启动 EC2 实例、从对象存储恢复之前的备份并重放 WAL,来对分片 Postgres 数据库执行大规模并行备份,从而实现超过 50 GB/s 的 PB 级备份速度。