Merhabalar,
Birkaç arkadaşım yazıları okuduktan sonra Kyoto Cabinet’in sorgu performansını merak etmiş. Bunun üzerine küçük bir çalışma ile sorgulama performanslarını sizlerle paylaşmak isterim.
Hemen sonuçları yazmakta fayda gÖrüyorum :)
MySQL üzerinden daha Önceki yazılarımda yer alan konfigurasyon ile (engine: Innodb, primary key üzerinden sorgulama yapılıyor.) 100 thread ile 1.000.000 kayit 48.56 sn’de sorgulanmıştır.
KyotoCabinet üzerinden daha Önceki yazılarımda yer alan konfigurasyon ile (engine: Hash, ek parametreler DB::OCREATE | DB::GCONCURRENT ve key üzerinden sorgulama yapılmıştır) 100 thread ile 1.000.000 kayit 4.54 sn’de sorgulanmıştır.
Şaka değil gerçek.
MySQL kod parçası;
require "mysql" start_number = 905420000000 start_time = Time.now all_threads = [] 100.times { |index| period_start_number = start_number + (index * 10000) #puts "isleniyor.. #{period_start_number}" current_thread = Thread.new(period_start_number) { |local_start_number| begin dbh = Mysql.real_connect("localhost", "kyoto_cabinet", "kyoto_cabinet", "kyoto_cabinet") dbh.autocommit(false) st = dbh.prepare("select value from simple_table where `key` = ?") 10000.times { st.execute(local_start_number) st.fetch() } rescue Mysql::Error => e puts "Error code: #{e.errno}" puts "Error message: #{e.error}" puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate") ensure dbh.close if dbh end } all_threads << current_thread } all_threads.each { |thread| thread.join } puts "1.000.000 kayit sorgulanmistir. Toplam süre: " + (Time.now.to_f - start_time.to_f).to_s
KyotoCabinet kod parçası;
require 'kyotocabinet' include KyotoCabinet start_number = 905420000000 all_threads = [] start_time = Time.now begin db = DB::new(DB::OCREATE | DB::GCONCURRENT) db.open("simple_table.kch") 100.times { |index| period_start_number = start_number + (index * 10000) current_thread = Thread.new(period_start_number) { |local_start_number| 10000.times { db[local_start_number] local_start_number += 1 } } all_threads << current_thread } all_threads.each { |thread| thread.join } rescue Error => e puts "Error #{e.to_s}" ensure db.close if db end puts "1.000.000 kayit sorgulanmistir. Toplam sure: " + (Time.now.to_f - start_time.to_f).to_s
Teşekkürler, kolay gelsin.
1 Response
[…] Go here to review a rest: Uordek :: Ruby ile Kyoto Cabinet – 5 […]