1. [bash-10.4 ~]$ ruby talk.rb
Introduction to Distributed Programming:
The Ruby Way
Auvi Rahman
auvi@mutuallyhuman.com
Mutually Human Software, LLC
1
Saturday, April 17, 2010
2. [bash-10.4 ~]$ who am I
• Mechanical/Industrial Engineer by training
• Software developer by trade
• Human as a person
2
Saturday, April 17, 2010
3. [bash-10.4 ~]$ whois mutuallyhuman.com
“Mutually Human Software is a custom software
strategy and design consultancy specializing in
mobile & web-based products and services.”
3
Saturday, April 17, 2010
4. [bash-10.4 ~]$ cat .relevant_history
• Parallel Fluid dynamics simulation (C++/MPI)
• Distributed Analog Computing
• Distributed control systems (Robotics)
• Distributed Discrete-Event Simulation
4
Saturday, April 17, 2010
5. [bash-10.4 ~]$ atq
• Distributed programming and Ruby
• DRb
• Rinda
• Others
5
Saturday, April 17, 2010
6. [bash-10.4 ~]$ whatis ‘distributed programming’
“Distributed programming is like network
programming—only the audience is different.”
- Lucas Carlson (Ruby Cookbook)
6
Saturday, April 17, 2010
8. [bash-10.4 ~]$ cd DRb
• Distributed Ruby
• Also known as dRuby
• Part of the standard library
• 100% Ruby
• Easy to use
• Universally available where Ruby is installed
8
Saturday, April 17, 2010
10. Example method
def humanize(name)
"#{name.capitalize} Human"
end
humanize('auvi') # => "Auvi Human"
10
Saturday, April 17, 2010
11. server.rb
require 'drb'
class HumanServer
def humanize(name)
"#{name.capitalize} Human"
end
end
DRb.start_service("druby://127.0.0.1:48626", HumanServer.new)
DRb.thread.join
11
Saturday, April 17, 2010
12. Protocol IP address Port
DRb.start_service("druby://127.0.0.1:48626", HumanServer.new)
Front
object
12
Saturday, April 17, 2010
14. client.rb
require 'drb'
server = DRbObject.new_with_uri("druby://127.0.0.1:48626")
puts server.humanize('auvi')
14
Saturday, April 17, 2010
15. [bash-10.4 ~]$ ruby client.rb
Auvi Human
[bash-10.4 ~]$
Server Client
15
Saturday, April 17, 2010
16. server2.rb
require 'drb'
class Person
attr_accessor :name
def initialize(name)
@name = name
end
def humanize
"#{@name.capitalize} Human"
end
end
class HumanServer
def personify(name)
Person.new(name)
end
end
DRb.start_service("druby://127.0.0.1:48626", HumanServer.new)
DRb.thread.join
16
Saturday, April 17, 2010
18. client2.rb
require 'drb'
server = DRbObject.new_with_uri("druby://127.0.0.1:48626")
p server
person = server.personify('auvi')
p person
puts person.humanize
18
Saturday, April 17, 2010
20. Solution?
include DRbUndumped
20
Saturday, April 17, 2010
21. server3.rb
require 'drb'
class Person
include DRbUndumped
attr_accessor :name
def initialize(name)
@name = name
end
def humanize
"#{@name.capitalize} Human"
end
end
class HumanServer
def personify(name)
Person.new(name)
end
end
DRb.start_service("druby://127.0.0.1:48626", HumanServer.new)
DRb.thread.join
21
Saturday, April 17, 2010
26. [bash-10.4 ~]$ cd Rinda
• Implements the Linda distributed
computing paradigm
• Also part of the standard library
• 100% Ruby
• Universally available where Ruby is installed
26
Saturday, April 17, 2010