狠狠撸

狠狠撸Share a Scribd company logo
Rubyで作った“mission critical”システムについて江森 真由美
PROFILEMayumi Emori  (@emorima)KCS Carrot Corp.Asakusarb
PROFILE2004
PROFILERuby
PROFILE2004
PROFILECGIKit
PROFILE2005
PROFILERuby onRails
PROFILERuby歴 7yearsFirst RubyKaigifor 尘别(超初心者)
Today’s point notwebservice(framework)
Today’s pointmissioncritical
Today’s pointdaemonprocess
Today’s pointRuby
Today’s pointmissioncritical ?
mission critical24時間365日、止まらないことを要求される基幹業務、あるいは、そのような業務遂行のために使用されるコンピュータシステムのこと。(中略)このような業務に使用されるシステムには、極めて高い信頼性や耐障害性、障害発生時に被害を最小に食い止める様々な機能、万全のサポート体制などが必要となる。         (IT用語辞典 别-奥辞谤诲蝉より)
mission critical24 hours365 dayscannot stop!
mission criticalhighreliability(高信頼性)
mission critical
mission criticalなにこれ?
mission critical困
whatsystem?
100threadsWhat system?
100processesWhat system?
10,000threadsWhat system?
UDPSocketWhat system?
whatfor?
collect datafromsensorson realtimeWhat for?
Last night,You were protected by Ruby
始まり产别驳颈苍苍颈苍驳
Beginning2004Prototype Ruby 1.6.8
Beginning10,000 threadsちゃんと起動しなかったcannot execute
BeginningWhy?
Beginningディスクリプタ上限を超えていたOver filedescriptor limit
Beginningtimeout10,000 TimeoutErrorもっさりslow in action
BeginningThreadいつの間にか?刺さるthread stuck
Beginning何とかしなければならない(must resolve the problem)
classThreadWatchdefinitialize(timer)    @update_time = nil@alive_timer = timer@mutex       = Mutex.newenddefupdate@mutex.synchronizedo@update_time = Time.nowendenddef valid?@mutex.synchronizedoreturnfalseif!@update_time.nil? &&             (Time.now - @update_time) > @alive_timer)   endtrueendend
defself.thread_main(idx, watch)loop dowatch.update#スレッド処理endenddefself.main(argv)th_infos = Hash.newforiin0…100w  = ThreadWatch.new(600)th = Thread.new(i, w) do |idx, watch|thread_main(idx, watch)endth_infos[i] =[th, w] endcheck_threads(th_infos)end
defself.check_threads(th_infos)loop doth_infos.eachdo |i, info|th, w = infof_restart = falsecaseth.statuswhen“run”, “sleep”f_restart = true unless w.valid?elsef_restart = trueendiff_restartth.killth.jointh = Thread.new(i, w) do |idx, watch|thread_main(idx, watch)endth_infos[i] = [th, w]      endend endend
BeginningOver file descriptor limitroot user timeoutselect()thread stuckown monitoring function.
本番谤别苍别飞补濒
renewal2009
谤别苍别飞补濒蝉辫别别诲大量データの计算処理性能要件を満たすためC言语で开発
renewalprocess count
renewalover230processes
Ifyou developed in C
fun?inRuby
“Rubyすげぇ”(Great! Ruby)
Benefits of           developing in RubyYes! This is Ruby(1)直観的 (intuitive)容易(easy)ThreadUDP/TCP Socket etc.
Benefits of           developing in RubyYes! This is Ruby(2)useful methodsyieldinstance_eval etc.
Benefits of           developing in RubyTest is fun. (テストは楽に楽しく)UDP/TCP Socket無限Loop
think about...
コード量が少なく、変更も容易异常ケースもテストで余裕でカバー罢丑谤别补诲も厂辞肠办别迟通信も简単に実装
Rubyfor 大規模システム
But...
Expectations or Hope in Rubyspeed(速度)
Expectations or Hope in Rubyhighreliability(高信頼性)
まとめ(蝉耻尘尘补谤测)
Today’s SummaryWeb Service以外でもRuby活躍!
Thank you for your attention.ご清聴ありがとうございました
Thank you for your attention.ご清聴ありがとうございました
Rubyで作った“mission critical”システムについて江森 真由美

More Related Content

Rubyで作った"mission critical"システムについて