際際滷

際際滷Share a Scribd company logo
DISTRIBUTED CLUSTER
in Ruby
ABOUT ME
 Mikhail Bortnyk
 Ruby developer at Amoniac O
 Co-founder of Kottans
 Github: @vessi
 Twitter: @mikhailbortnyk
 2 cats
BACKGROUND STORY
Special
processing
box
Your data
Something
useful
BACKGROUND STORY
0
25
50
75
100
125
0 7.5 15 22.5 30
Loadpercentage
Amount of requests
Application load
TYPICAL SOLUTION
Special
processing
box
#1
Your data
Something
useful
Special
processing
box
#2
Your data
Something
useful
PROBLEMS OF TYPICAL
SOLUTION
 you are now available to process 2 times (less in
reality) of your typical load
 for 102% load 98% is not utilised
 and you scale all parts even ones that dont need to be
scaled
 spending money, alcoholism, drugs, depression, life is
over
LOOK OUT OF IN THE BOX
Special
processing
box
Your data
Something
useful
in reality is:
Your data
request
processo
r
databas
e
request
business
logic
respons
e
processo
r
Somethin
g
useful
SO WHAT?
 in reality, your 100% of processing power is:
 5% of request processor
 20% of database requests
 60% of business logic
 10% of serialisation
 5% of response processor
 Load differs from stage to stage.
LOOK LIKE I SEE THE IDEA!
 What if we will scale only most loaded part of
application?
 Typical case: request processor + database +
business logic + serialiser + response * 2 = 200%
 This case: request processor + database +
business logic * 2 + serialiser + response = 160%
 For 102% of load only 58% is not utilised
OK, OK, I JUST STOLE IDEA
FROM ERLANG
SIDE STORY OF
CONCURRENCY IN RUBY
 Threads
 DRuby
 Celluloid
 concurrent-ruby
 Guild model (planned for Ruby 3, author: Koichi
Sasada)
THREADS CAVEATS
 Some people, when confronted with a problem,
think, "I know, I'll use threads," and then two
they hav erpoblesms.
 All multithreading low-level stuff
 Aware thread-safety!
 Ruby VM is shared/copied to child process
LONG STORY SHORT
 DRuby is too low-level
 Have you seen anyone who uses this in
reality?
 concurrent-ruby does not have network
solutions
 Guild is not out yet
DCELL
OK, WHATS WRONG WITH
THIS?
 you dont know which node runs what
 Celluloid. NUFF SAID
 No, seriously. Thread per actor is too
expensive
 But they gave the idea
LADIES AND GENTLEMEN
I AM PROUD TO PRESENT
TOTALLY NOT FINISHED
CONCEPT
 di-cluster gem
 github://vessi/di-cluster.git
 lot of things to complete
 clean code
 write tests
 write documentation
DICLUSTER
 NIH syndrome
 role-based registry
 based on concurrent-ruby
 buggy and unfinished
 only JSON-compatible data
DEMO
I will need courageous person from listeners
SAMPLE CODE
Q&A
SO LONG AND THANKS
FOR ALL THE LINKS

More Related Content

Distributed Cluster in Ruby