introduction to rabbitmq | meetup at pivotal labs

76
Introduction to RabbitMQ Alvaro Videla - Pivotal / RabbitMQ Friday, September 13, 13

Upload: alvaro-videla

Post on 27-Jan-2015

123 views

Category:

Technology


3 download

DESCRIPTION

The Pub/Sub Pattern image form slide 51 is taken from here: http://www.eaipatterns.com/PublishSubscribeChannel.html

TRANSCRIPT

Page 1: Introduction to RabbitMQ | Meetup at Pivotal Labs

Introduction to RabbitMQ Alvaro Videla - Pivotal / RabbitMQ

Friday, September 13, 13

Page 2: Introduction to RabbitMQ | Meetup at Pivotal Labs

Alvaro Videla

• Developer Advocate at Pivotal / RabbitMQ

• Co-Author of RabbitMQ in Action

• Creator of the RabbitMQ Simulator

• Blogs about RabbitMQ Internals: http://videlalvaro.github.io/internals.html

• @old_sound | [email protected]/videlalvaro

Friday, September 13, 13

Page 3: Introduction to RabbitMQ | Meetup at Pivotal Labs

About Me

Co-authored

RabbitMQ in Action

http://bit.ly/rabbitmq

Friday, September 13, 13

Page 4: Introduction to RabbitMQ | Meetup at Pivotal Labs

Why do we need messaging?

Friday, September 13, 13

Page 5: Introduction to RabbitMQ | Meetup at Pivotal Labs

Classic Web Apps

Friday, September 13, 13

Page 6: Introduction to RabbitMQ | Meetup at Pivotal Labs

Implement a Photo Gallery

Friday, September 13, 13

Page 7: Introduction to RabbitMQ | Meetup at Pivotal Labs

Two Parts:

Friday, September 13, 13

Page 8: Introduction to RabbitMQ | Meetup at Pivotal Labs

Pretty Simple

Friday, September 13, 13

Page 9: Introduction to RabbitMQ | Meetup at Pivotal Labs

‘Till new requirements arrive

Friday, September 13, 13

Page 10: Introduction to RabbitMQ | Meetup at Pivotal Labs

The Product Owner

Friday, September 13, 13

Page 11: Introduction to RabbitMQ | Meetup at Pivotal Labs

Can we also notify the user friends when she uploads a new

image?

Friday, September 13, 13

Page 12: Introduction to RabbitMQ | Meetup at Pivotal Labs

Can we also notify the user friends when she uploads a new

image?

I forgot to mention we need it for tomorrow…

Friday, September 13, 13

Page 13: Introduction to RabbitMQ | Meetup at Pivotal Labs

The Social Media Guru

Friday, September 13, 13

Page 14: Introduction to RabbitMQ | Meetup at Pivotal Labs

We need to give badges to users for each picture upload

Friday, September 13, 13

Page 15: Introduction to RabbitMQ | Meetup at Pivotal Labs

We need to give badges to users for each picture upload

and post uploads to Twitter

Friday, September 13, 13

Page 16: Introduction to RabbitMQ | Meetup at Pivotal Labs

The Sysadmin

Friday, September 13, 13

Page 17: Introduction to RabbitMQ | Meetup at Pivotal Labs

Dumb! You’re delivering full size images!

The bandwidth bill has tripled!

Friday, September 13, 13

Page 18: Introduction to RabbitMQ | Meetup at Pivotal Labs

Dumb! You’re delivering full size images!

The bandwidth bill has tripled!

We need this fixed for yesterday!

Friday, September 13, 13

Page 19: Introduction to RabbitMQ | Meetup at Pivotal Labs

The Developer in the other team

Friday, September 13, 13

Page 20: Introduction to RabbitMQ | Meetup at Pivotal Labs

I need to call your Java stuff but from Python

Friday, September 13, 13

Page 21: Introduction to RabbitMQ | Meetup at Pivotal Labs

I need to call your Java stuff but from Python

And also PHP starting next week

Friday, September 13, 13

Page 22: Introduction to RabbitMQ | Meetup at Pivotal Labs

The User

Friday, September 13, 13

Page 23: Introduction to RabbitMQ | Meetup at Pivotal Labs

I don’t want to waittill your app resizes

my image!

Friday, September 13, 13

Page 24: Introduction to RabbitMQ | Meetup at Pivotal Labs

You

Friday, September 13, 13

Page 25: Introduction to RabbitMQ | Meetup at Pivotal Labs

(╯°□°)╯( ┻━┻

Friday, September 13, 13

Page 26: Introduction to RabbitMQ | Meetup at Pivotal Labs

Let’s see the code evolution

Friday, September 13, 13

Page 27: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> image_handler:do_upload(ReqData:get_file()), ok.

Pseudo Code

Comments

Friday, September 13, 13

Page 28: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> image_handler:do_upload(ReqData:get_file()), ok.

Pseudo Code

Function Name

Friday, September 13, 13

Page 29: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> image_handler:do_upload(ReqData:get_file()), ok.

Pseudo Code

Arguments

Friday, September 13, 13

Page 30: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> image_handler:do_upload(ReqData:get_file()), ok.

Pseudo Code

Function Body

Friday, September 13, 13

Page 31: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> image_handler:do_upload(ReqData:get_file()), ok.

Pseudo Code

Return Value

Friday, September 13, 13

Page 32: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> image_handler:do_upload(ReqData:get_file()), ok.

First Implementation:

Friday, September 13, 13

Page 33: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()), resize_image(Image),

ok.

Second Implementation:

Friday, September 13, 13

Page 34: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()), resize_image(Image),

notify_friends(ReqData:get_user()),ok.

Third Implementation:

Friday, September 13, 13

Page 35: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()), resize_image(Image),

notify_friends(ReqData:get_user()),add_points_to_user(ReqData:get_user()),ok.

Fourth Implementation:

Friday, September 13, 13

Page 36: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()), resize_image(Image),

notify_friends(ReqData:get_user()),add_points_to_user(ReqData:get_user()),tweet_new_image(User, Image),ok.

Final Implementation:

Friday, September 13, 13

Page 37: Introduction to RabbitMQ | Meetup at Pivotal Labs

Can our code scale to new requirements?

Friday, September 13, 13

Page 38: Introduction to RabbitMQ | Meetup at Pivotal Labs

What if

Friday, September 13, 13

Page 39: Introduction to RabbitMQ | Meetup at Pivotal Labs

• We need to speed up image conversion

What if

Friday, September 13, 13

Page 40: Introduction to RabbitMQ | Meetup at Pivotal Labs

• We need to speed up image conversion• User notifications sent by email

What if

Friday, September 13, 13

Page 41: Introduction to RabbitMQ | Meetup at Pivotal Labs

• We need to speed up image conversion• User notifications sent by email• Stop tweeting about new images

What if

Friday, September 13, 13

Page 42: Introduction to RabbitMQ | Meetup at Pivotal Labs

• We need to speed up image conversion• User notifications sent by email• Stop tweeting about new images• Resize in different formats

What if

Friday, September 13, 13

Page 43: Introduction to RabbitMQ | Meetup at Pivotal Labs

• We need to speed up image conversion• User notifications sent by email• Stop tweeting about new images• Resize in different formats• Swap Language / Technology (No Down Time)

What if

Friday, September 13, 13

Page 44: Introduction to RabbitMQ | Meetup at Pivotal Labs

Can we do better?

Friday, September 13, 13

Page 45: Introduction to RabbitMQ | Meetup at Pivotal Labs

Sure.Using messaging

Friday, September 13, 13

Page 46: Introduction to RabbitMQ | Meetup at Pivotal Labs

DesignPublish / Subscribe Pattern

Friday, September 13, 13

Page 47: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()),

Msg = #msg{user = ReqData:get_user(), image = Image},publish_message('new_image', Msg).

First Implementation:

Friday, September 13, 13

Page 48: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()),

Msg = #msg{user = ReqData:get_user(), image = Image},publish_message('new_image', Msg).

First Implementation:

%% friends notifieron('new_image', Msg) ->

notify_friends(Msg.user, Msg.image).

Friday, September 13, 13

Page 49: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()),

Msg = #msg{user = ReqData:get_user(), image = Image},publish_message('new_image', Msg).

First Implementation:

%% friends notifieron('new_image', Msg) ->

notify_friends(Msg.user, Msg.image).

%% points manageron('new_image', Msg) ->

add_points(Msg.user, 'new_image').

Friday, September 13, 13

Page 50: Introduction to RabbitMQ | Meetup at Pivotal Labs

%% image_controllerhandle('PUT', "/user/image", ReqData) -> {ok, Image} = image_handler:do_upload(ReqData:get_file()),

Msg = #msg{user = ReqData:get_user(), image = Image},publish_message('new_image', Msg).

First Implementation:

%% friends notifieron('new_image', Msg) ->

notify_friends(Msg.user, Msg.image).

%% points manageron('new_image', Msg) ->

add_points(Msg.user, 'new_image').

%% resizeron('new_image', Msg) ->

resize_image(Msg.image).

Friday, September 13, 13

Page 51: Introduction to RabbitMQ | Meetup at Pivotal Labs

Second Implementation:

Friday, September 13, 13

Page 52: Introduction to RabbitMQ | Meetup at Pivotal Labs

Second Implementation:

THIS PAGE INTENTIONALLY LEFT BLANK

Friday, September 13, 13

Page 53: Introduction to RabbitMQ | Meetup at Pivotal Labs

What is RabbitMQ

Friday, September 13, 13

Page 54: Introduction to RabbitMQ | Meetup at Pivotal Labs

RabbitMQ

Friday, September 13, 13

Page 55: Introduction to RabbitMQ | Meetup at Pivotal Labs

RabbitMQ

• Multi Protocol Messaging Server

Friday, September 13, 13

Page 56: Introduction to RabbitMQ | Meetup at Pivotal Labs

RabbitMQ

• Multi Protocol Messaging Server• Open Source (MPL)

Friday, September 13, 13

Page 57: Introduction to RabbitMQ | Meetup at Pivotal Labs

RabbitMQ

• Multi Protocol Messaging Server• Open Source (MPL)• Polyglot

Friday, September 13, 13

Page 58: Introduction to RabbitMQ | Meetup at Pivotal Labs

RabbitMQ

• Multi Protocol Messaging Server• Open Source (MPL)• Polyglot• Written in Erlang/OTP

Friday, September 13, 13

Page 60: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

Friday, September 13, 13

Page 61: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java

Friday, September 13, 13

Page 62: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java• node.js

Friday, September 13, 13

Page 63: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java• node.js• Erlang

Friday, September 13, 13

Page 64: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java• node.js• Erlang• PHP

Friday, September 13, 13

Page 65: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java• node.js• Erlang• PHP• Ruby

Friday, September 13, 13

Page 66: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java• node.js• Erlang• PHP• Ruby• .Net

Friday, September 13, 13

Page 67: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

• Java• node.js• Erlang• PHP• Ruby• .Net• Haskell

Friday, September 13, 13

Page 68: Introduction to RabbitMQ | Meetup at Pivotal Labs

Polyglot

Even COBOL!!!11

Friday, September 13, 13

Page 69: Introduction to RabbitMQ | Meetup at Pivotal Labs

Some users of RabbitMQ

Friday, September 13, 13

Page 70: Introduction to RabbitMQ | Meetup at Pivotal Labs

Some users of RabbitMQ

• Instagram

Friday, September 13, 13

Page 71: Introduction to RabbitMQ | Meetup at Pivotal Labs

Some users of RabbitMQ

• Instagram

• Indeed.com

Friday, September 13, 13

Page 72: Introduction to RabbitMQ | Meetup at Pivotal Labs

Some users of RabbitMQ

• Instagram

• Indeed.com

• MailboxApp

Friday, September 13, 13

Page 73: Introduction to RabbitMQ | Meetup at Pivotal Labs

Some users of RabbitMQ

• Instagram

• Indeed.com

• MailboxApp

• Mercado Libre

Friday, September 13, 13

Page 74: Introduction to RabbitMQ | Meetup at Pivotal Labs

Friday, September 13, 13

Page 75: Introduction to RabbitMQ | Meetup at Pivotal Labs

Messaging with RabbitMQ

A demo with the RabbitMQ Simulator

https://github.com/RabbitMQSimulator/RabbitMQSimulator

Friday, September 13, 13

Page 76: Introduction to RabbitMQ | Meetup at Pivotal Labs

Thanks

Alvaro Videla - @old_sound

Friday, September 13, 13