ap4r - paperplanes.de · the specials • async. logic without extra workers • an async. task is...

18
AP4R Asynchronous Processing for Ruby

Upload: others

Post on 07-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

AP4RAsynchronous Processing for Ruby

Page 2: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

what is it?

• asynchronous job processor

• you mean like backgroundrb?

• yes! and no!

Page 3: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

features

• async. message queueing and dispatching

• reliable messaging

• load balancing

Page 4: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

the specials

• async. logic without extra workers

• an async. task is just another controller action

• supports http post, soap, xmlrpc

Page 5: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

delivery

• immediately through drb

• store and forward

• first store message (through activerecord)

• then deliver

• ensures guaranteed delivery

Page 6: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

message storage

• file based

• database (for now only mysql)

Page 7: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

scenarios

• mass mailings

• cache sweeping

• search index rebuilding

• feed aggregation

Page 8: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

setup

• ap4r is a gem

• and a plugin

• setup

• ap4r_setup ap4r_server

• install rails plugin

Page 9: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

setup

• ap4r dispatcher runs with mongrel

• checks for messages and dispatches

Page 10: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

how it works

Internet

Mongrel/Rails

AP4R

Queue Message

Dispatch

Request

Apache

Page 11: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

but what about backgroundrb?

• ap4r is simpler

• integrates more seamlessly with rails

• it can async'ly execute http calls on any http server

Page 12: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

but i love backgroundrb!

• what's in the background stays in the background

• no scheduling support

• but backgroundrb doesn’t have reliable scheduling anyway

Page 13: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

code!

• immediate delivery

ap4r.async_to( {:controller => ‘search‘, :action => ‘reindex‘},{:id => 12} )

ap4r.async_to( {:url => ‘http://localhost:8080/someServlet’},{:id => 12} )

Page 14: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

code!

• store and forwardap4r.transaction doap4r.async_to( {:controller...}, {:id => 12} )

end

Page 15: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

code!

• store and forwardap4r.transaction doap4r.async_to( {:controller...}, {:id => 12} )

end

Store in SAF

Page 16: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

code!

• store and forwardap4r.transaction doap4r.async_to( {:controller...}, {:id => 12} )

end

Store in SAF

Commit Database, Deliver Message

Page 18: AP4R - paperplanes.de · the specials • async. logic without extra workers • an async. task is just another controller action • supports http post, soap, xmlrpc

thanks!