1

我最近安装了一个新服务器:

  • Debian 挤压
  • 阿帕奇2
  • php5.3.3-7
  • sqlite

从旧服务器迁移我的应用程序时,我观察到它的运行速度要慢得多。我隔离了这个问题,sqlite 更新运行速度慢了 10 倍以上。

两个 sqlite 都是 2.8.17 版本,旧服务器运行 PHP 版本 5.2.6-1+lenny3 这是我使用的基准脚本:

function write($value) {
    $dbh = sqlite_open('mt.sq');
    $sql = "REPLACE INTO hash (key,value,lm) VALUES ('test','$value','dummy')";
    sqlite_query($dbh, $sql);
    $dbh = sqlite_close($dbh);
}

$n = 100;
$start = microtime(true);
for($i=0;$i<$n;$i++) write($i);
$avg = (microtime(true) - $start) / $n;
echo "Average write time: ".$avg."[s]";

新服务器结果:平均写入时间:0.0795[s]
旧服务器结果:平均写入时间:0.0032[s]

这是用于测试的数据库:

BEGIN TRANSACTION;
CREATE TABLE hash(
    key PRIMARY KEY,
    value,
    lm
);
INSERT INTO hash VALUES('test',99,'dummy');
COMMIT;

我不知道在哪里搜索。有没有人观察到同样的性能问题?
任何帮助都感激不尽。

4

1 回答 1

3

This is a known "issue" - ext4 comes with barriers enabled by default (in contrast to ext3) - see Serious performance issues with ext4fs barriers:

The important difference in this aspect from ext4fs to ext3fs is that ext4fs comes with barriers enabled, which is a filesystem feature (optional in ext3fs) that tries to improves filesystem integrity. But this comes at a cost: depending on your application use case this might decrease filesystem throughput a lot

于 2012-12-15T17:20:56.487 回答