1

MySQL と比較して、CouchDB が処理できる挿入数を確認したかったのです。私のテストは簡単でした: 10 秒間挿入を続け{firstName: "Testing 001", lastName: "Testing 002"}、ドキュメント/行の数を比較します。得られた結果は、私の期待とはかけ離れていました。

  • MySQL MyIsam: 110,000 行
  • MySQL InnoDB: 52,000 行
  • CouchDB: 3,300ドキュメント!

私が間違っている場合は訂正してください。しかし、NoSQL は常に単純な操作でリレーショナル データベースよりも優れているのでしょうか? 私はそのような劇的な違いを期待していません. おそらく私のテストは素朴で、そのような方法でそれらのデータベースを比較するべきではありませんか? MySQL ドライバーには接続プールへのアクセス権があり、リクエストごとに TCP 接続を再作成する必要がないことはわかっていますが、それほど大きな違いはありますか?

CouchDB の挿入はそれほど遅いはずですか? そうでない場合は、正しく行う方法はありますか?

クリーンな CouchDB データベース (設計ドキュメントなし) / Macbook Pro 2.6Ghz i7、16GB RAM、SSD / CouchDB 1.4.0 でテストを実行します

テスト スクリプト:

var nano = require('nano')('http://localhost:5984');
var async = require('async');
var db = nano.db.use('test');
var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '',
  database: 'test'
});

/*
connection.connect(function(err){
    var t = new Date().getTime() + 10000;
    var i = 0;

    var page = 2,
        lastPage = 100;

    async.whilst(function () {
      return new Date().getTime()  < t;
    },
    function (next) {
        connection.query('INSERT INTO test (firstName, lastName) VALUES ("Testing 001","Testing 002")', function(err, rows, fields) {
          i += 1;
          next();
        });
    },
    function (err) {
        console.log( i );
        connection.end();
    });
});
*/

var t = new Date().getTime() + 10000;
var i = 0;

var page = 2,
    lastPage = 100;

async.whilst(function () {
  return new Date().getTime()  < t;
},
function (next) {
  db.insert({firstName: "Testing 001", lastName: "Testing 002"}, 'id-' + i, function(){
    i += 1;
    next();
  });
},
function (err) {
    console.log( i );
    connection.end();
});

// 編集:

結局のところ、問題は言うまでもなくCouchDB側にはありません。クライアントのライブラリ/ドライバーには、それらをひどく遅くする何かがあります。Apache ベンチマークを使用した単純な POST テストは、CouchDB 側で非常に良い結果を示しています。

$ ab -n 10000 -c 100 -p post-data -T "application/json" "http://192.168.50.102:5984/test/"
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.50.102 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        CouchDB/1.5.0
Server Hostname:        192.168.50.102
Server Port:            5984

Document Path:          /test/
Document Length:        95 bytes

Concurrency Level:      100
Time taken for tests:   1.149 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      4120412 bytes
Total POSTed:           1920960
HTML transferred:       950095 bytes
Requests per second:    8704.85 [#/sec] (mean)
Time per request:       11.488 [ms] (mean)
Time per request:       0.115 [ms] (mean, across all concurrent requests)
Transfer rate:          3502.69 [Kbytes/sec] received
                        1632.98 kb/s sent
                        5135.67 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       2
Processing:     6   11   2.6     11      23
Waiting:        6   11   2.6     11      22
Total:          6   11   2.6     11      25
4

1 に答える 1

4

一度に 1 つのドキュメントを挿入していますか? 現実的な比較を行うには、ドキュメントの一括読み込み機能を使用する必要があります。

http://docs.couchdb.org/en/latest/api/database/bulk-api.html#db-bulk-docs

CouchDB のパフォーマンスの詳細については、こちらをご覧ください。

http://guide.couchdb.org/draft/performance.html (少し古いですが、ほとんどの場合まだ関連があります)

于 2013-12-23T10:58:47.213 に答える