gpt4 book ai didi

postgresql - 两个具有相同配置但性能不同的postgresql服务器

转载 作者:行者123 更新时间:2023-11-29 13:06:55 25 4
gpt4 key购买 nike

我有两台相同的服务器,都安装了具有相同配置的 postgresql 服务器版本 9.0.4。如果我启动一个执行大约 5k 插入的 .sql 文件,第一个需要几秒钟,第二个需要 1 分 30 秒。

如果我设置 synchronous_commit,速度会显着降低(正如预期的那样),并且两个服务器的性能相当。但是如果我将 synchronous_commit 设置为 on,在一个服务器上插入脚本执行时间增加不到一秒,在另一个服务器上它增加太多,正如我在第一节中所说的。

对这种性能差异有什么想法吗?我是否缺少某些配置?

更新:尝试了一个简单的磁盘测试:time sh -c "dd if=/dev/zero of=ddfile bs=8k count=200000 && sync"

快速服务器输出:

1638400000 bytes (1.6 GB) copied, 1.73537 seconds, 944 MB/s

real 0m32.009s
user 0m0.018s
sys 0m2.298s

缓慢的服务器输出:

1638400000 bytes (1.6 GB) copied, 4.85727 s, 337 MB/s

real 0m35.045s
user 0m0.019s
sys 0m2.221s

共同特征(两个服务器):

SATA, RAID1, controller: Intel Corporation 82801JI (ICH10 Family) SATA AHCI Controller, distribution: linux centOS. mount -v output:
/dev/md2 on / type ext3 (rw)
proc on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/md1 on /boot type ext3 (rw)

快速服务器:内核 2.6.18-238.9.1.el5 #1 SMP

Disk /dev/sda: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System
/dev/sda1 3906 4209029 2102562 fd Linux raid autodetect
/dev/sda2 4209030 4739174 265072+ fd Linux raid autodetect
/dev/sda3 4739175 1465144064 730202445 fd Linux raid autodetect

慢速服务器:内核 2.6.32-71.29.1.el6.x86_64 #1 SMP

Disk /dev/sda: 750.2 GB, 750156374016 bytes
64 heads, 32 sectors/track, 715404 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006ffc4

Device Boot Start End Blocks Id System
/dev/sda1 2048 4194303 2096128 fd Linux raid autodetect
/dev/sda2 4194304 5242879 524288 fd Linux raid autodetect
/dev/sda3 5242880 1465147391 729952256 fd Linux raid autodetect

它对解决性能问题有用吗?

最佳答案

我想你的较慢的内核较新的服务器有工作障碍。这很好,否则您可能会在断电时丢失数据。但它当然比在启用写入缓存且没有障碍的情况下运行要慢,也就是用剪刀运行

您可以使用 mount -v 检查障碍是否已启用——在输出中搜索 barrier=1。您可以为您的文件系统禁用障碍 (mount -o remount,barrier=0/) 以加快速度,但这样您就有数据损坏的风险。

尝试在一次事务中执行 5k 插入操作——Postgres 不必在插入的每一行都写入磁盘。每秒交易数量的理论限制与磁盘转速相当(7200rpm 磁盘 ≈ 7200/60 tps = 120 tps),因为磁盘每次旋转只能写入一个扇区一次。

关于postgresql - 两个具有相同配置但性能不同的postgresql服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7572075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com