you got ur erlang in my ruby
TRANSCRIPT
![Page 1: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/1.jpg)
You got ur Erlang in my Ruby
Ezra Zygmuntowicz
Join the nanite cloud if you have OSX:curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 2: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/2.jpg)
Two Great tastes that go great together
![Page 3: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/3.jpg)
Erlangcurl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 4: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/4.jpg)
ErlangPROS:
Fault TolerantDistributedActor ModelImmutable
ScalableConcurrency
Let it FailAwesome VM
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 5: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/5.jpg)
ErlangCONS:
Unfamiliar SyntaxPrimitive
String handlingSlow(ish) IO
Much harder to find developers
PROS:Fault Tolerant
DistributedActor ModelImmutable
ScalableConcurrency
Let it FailAwesome VM
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 6: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/6.jpg)
Rubycurl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 7: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/7.jpg)
RubyPROS:Rapid
DevelopmentFamiliar Concise
SyntaxExcellent String
HandlingVery
ApproachableEasy to find developers
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 8: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/8.jpg)
RubyCONS:
1024 open FD limit
No Multi-CoreHorrible GCNo Native Threads
Primadonnas in community :P
Creaky Interpreter
PROS:Rapid
DevelopmentFamiliar Concise
SyntaxExcellent String
HandlingVery
ApproachableEasy to find developers
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 9: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/9.jpg)
What if we can combine the best of both?
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 10: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/10.jpg)
Use Erlang for its strengths
Use Ruby for its strengths
MessagingNetworkingScalability
Distribution
Rapid DevelopmentDSL/concise Syntax
Ease of use/installation
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 11: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/11.jpg)
Erlang VM
![Page 12: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/12.jpg)
NaniteLooks a lot like an exploded Erlang VM
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 13: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/13.jpg)
RabbitMQ
6kloc of beautiful erlangmodels queues as processes
replicates routing info across clustered VMs
Single queue live on single vmAMQP Protocol(win!)
curl -O http://brainspl.at/ef.sh && sh ef.sh
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 14: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/14.jpg)
AMQP Basics
The Trinity...
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 15: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/15.jpg)
AMQP BasicsQueues:
curl -O http://brainspl.at/ef.sh && sh ef.sh
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 16: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/16.jpg)
AMQP BasicsQueues:
Queues are FIFO buffers of messagesMessages consumed from the front of the queue
New messages are placed in the back of the queueQueues can be transient or persistent
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 17: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/17.jpg)
AMQP BasicsExchanges:
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 18: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/18.jpg)
AMQP BasicsExchanges:
Exchanges are where producers send messagesMultiple exchange types:
Direct, Fanout, TopicExchanges are routers with routing tables
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 19: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/19.jpg)
AMQP BasicsBindings:
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 20: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/20.jpg)
AMQP BasicsBindings:
Bindings are the ‘glue’ between exchanges and queuesBindings take exchange routing rules, apply filters
and push messages onto destination queues
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 21: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/21.jpg)
AMQP BasicsPutting it all together
Source: Red Hat Messaging Tutorial: 1.3 Topic Exchange
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 22: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/22.jpg)
Nanite AMQP overview
curl -O http://brainspl.at/ef.sh && sh ef.sh
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 23: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/23.jpg)
Nanite Agents/Actorscurl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 24: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/24.jpg)
Nanite Registration/Advertising
This actor will advertise
these services:/simple/echo/simple/time
And these tags:customer-42
urmomurdad
You can route requests based on services and tags
![Page 25: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/25.jpg)
Nanite StateAgent state can be stored replicated in memory in
the mappers.
Or for more scalable systems, state can be stored in a Redis DHT
We build an inverted index so agent lookup based on tags and services is just one set intersection away
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 26: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/26.jpg)
Nanite Statenanite-foobar: 0.72 # load average or 'status'
s-nanite-foobar: { /foo/bar, /foo/nik } # a SET of the provided services
tg-nanite-foobar: { foo-42, some-tag } # a SET of the tags for this agent
t-nanite-foobar: 123456789 # unix timestamp of the last state update
# inverted indexes/foo/bar: { nanite-foobar, nanite-nickelbag, nanite-another } # redis SETsome-tag: { nanite-foobar, nanite-nickelbag, nanite-another }
![Page 27: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/27.jpg)
Securityrabbitmqctl set_permissions -p /nanite nanite "^nanite.*" ".*" ".*"
rabbitmqctl set_permissions -p /nanite mapper ".*" ".*" ".*"(only available in rabbitmq hg HEAD)
Secure SerializerPackets are encrypted and signed with public/
private keypairs(X.509)Certs are tied to a Nanite’s identity and the mappers have a Cert Store where they can dynamically look
up the proper keys to handle a packet
(Thanks for Raphael from RightScale for the Security code)
![Page 28: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/28.jpg)
Let’s see that demo
curl -O http://brainspl.at/ef.sh && sh ef.sh
![Page 29: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/29.jpg)
What did I make nanite for?
![Page 30: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/30.jpg)
Future Directions
• Use Rabbitmq patch(bug19230) to add ‘presence’ to the broker and get rid of ‘pings’
• Erlang agents/mappers
• Mappers have features that ‘should’ be in the broker, integrate what makes sense directly
![Page 31: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/31.jpg)
Future Directions
• Explore using Erlix for directly integrating ruby as an erlang node in the rabbit broker:
• http://github.com/KDr2/erlix
![Page 32: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/32.jpg)
Future Directions
• Explore creating an AQMP -> Couchdb query interface using the erlang AMQP client and the new native erlang couchdb client
![Page 33: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/33.jpg)
Get Involved
• http://github.com/ezmobius/nanite
• http://groups.google.com/group/nanite
• #nanite on irc.freenode.net
• http://www.rabbitmq.com/
• http://code.google.com/p/redis/
![Page 34: You got ur Erlang in my Ruby](https://reader033.vdocuments.net/reader033/viewer/2022060108/55510972b4c9057b478b5440/html5/thumbnails/34.jpg)
Questions?