ActionEmbedding Phil Cowans - LRUG, July 2010
Pagelets (http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919)
 
Characteristics Of Pagelets <ul><ul><li>Substantial content. </li></ul></ul><ul><ul><li>Independence from the containing p...
Why Think About Pages This Way? <ul><ul><li>Helps define a ubiquitous language. </li></ul></ul><ul><ul><li>Clean code: sep...
Existing Tools / Patterns / Work <ul><ul><li>Rails: </li></ul></ul><ul><ul><ul><li>ActionController::Components in early v...
Why Start Again? <ul><ul><li>An excuse to dig around inside of Rails. </li></ul></ul><ul><ul><li>Experiment with various t...
HMVC <ul><ul><li>Pagelet render handled by secondary internal request. </li></ul></ul><ul><ul><li>Secondary request handle...
Request Forwarding <ul><ul><li>Primary application forwards request to back end server </li></ul></ul><ul><ul><li>Separate...
Edge Side Includes <ul><ul><li>Page composition handled by a proxy server. </li></ul></ul><ul><ul><li>Works with proxies w...
XHR Composition <ul><ul><li>Pagelets are loaded via secondary XHR requests in JavaScript. </li></ul></ul>
Other Options (not yet implemented) <ul><ul><li>Parallel execution. </li></ul></ul><ul><ul><ul><li>Potential to scale out ...
Internals <ul><ul><li>HMVC requests use Rack internally. </li></ul></ul><ul><ul><li>Easy on Rails 2.3, as routing and cont...
Practical Experience <ul><ul><li>Songkick activity feeds use ActionEmbedding / HMVC since Thursday. </li></ul></ul><ul><ul...
Issues / Todos <ul><ul><li>Try XHR embedding in production. </li></ul></ul><ul><ul><li>Better exception handling (right no...
Thanks... <ul><li>http://github.com/philcowans/action_embedding </li></ul><ul><li>[email_address] </li></ul><ul><li>@philc...
Upcoming SlideShare
Loading in …5
×

ActionEmbedding

954 views

Published on

Presentation on ActionEmbedding, a Rails plugin for working with pagelets. This talk was given at an LRUG meeting on July 12th 2010.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
954
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

ActionEmbedding

  1. 1. ActionEmbedding Phil Cowans - LRUG, July 2010
  2. 2. Pagelets (http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919)
  3. 4. Characteristics Of Pagelets <ul><ul><li>Substantial content. </li></ul></ul><ul><ul><li>Independence from the containing page. </li></ul></ul><ul><ul><li>Potential to be handled by a back-end service. </li></ul></ul><ul><ul><li>Can typically be cached. </li></ul></ul><ul><ul><li>Localisation. </li></ul></ul>
  4. 5. Why Think About Pages This Way? <ul><ul><li>Helps define a ubiquitous language. </li></ul></ul><ul><ul><li>Clean code: separation of responsibilities. </li></ul></ul><ul><ul><li>Code reuse. </li></ul></ul><ul><ul><li>Scalability. </li></ul></ul>
  5. 6. Existing Tools / Patterns / Work <ul><ul><li>Rails: </li></ul></ul><ul><ul><ul><li>ActionController::Components in early versions of Rails - dropped for performance reasons. </li></ul></ul></ul><ul><ul><ul><li>Cells - plugin implementing similar functionality. </li></ul></ul></ul><ul><ul><ul><li>Embedded Actions - another plugin. </li></ul></ul></ul><ul><ul><li>Elsewhere: </li></ul></ul><ul><ul><ul><li>Kohana - PHP framework based on Hierarchical Model-View-Controller (HMVC) pattern. </li></ul></ul></ul><ul><ul><ul><li>Facebook BigPipe framework - Javascript tricks to get as much of the page to render as quickly as possible.  </li></ul></ul></ul>
  6. 7. Why Start Again? <ul><ul><li>An excuse to dig around inside of Rails. </li></ul></ul><ul><ul><li>Experiment with various techniques for composing content. </li></ul></ul><ul><ul><li>Make it easy for pagelet infrastructure to grow with the application: </li></ul></ul><ul><ul><ul><li>Easy to start using pagelets without complex infrastructure. </li></ul></ul></ul><ul><ul><ul><li>Confidence that it will be possible to swap in more sophisticated embedding mechanisms without a rewrite. </li></ul></ul></ul><ul><ul><li>A couple of niggles with existing work: </li></ul></ul><ul><ul><ul><li>Wanted to reuse ActionController::Base for pagelets, rather than defining a new class. </li></ul></ul></ul><ul><ul><ul><li>Use paths/URLs internally rather than controller/action/params. </li></ul></ul></ul>
  7. 8. HMVC <ul><ul><li>Pagelet render handled by secondary internal request. </li></ul></ul><ul><ul><li>Secondary request handled by standard Rails Controller / View (you can hit it directly if you want). </li></ul></ul>
  8. 9. Request Forwarding <ul><ul><li>Primary application forwards request to back end server </li></ul></ul><ul><ul><li>Separate tier scales independently. </li></ul></ul><ul><ul><li>Useful tricks: time out slow back end requests, silently drop pagelet on exception, easy killswitch for feature if necessary.  </li></ul></ul><ul><ul><li>Use appropriate mix of technologies - back end doesn't need to use same framework as front end, e.g. Sinatra for simple things. </li></ul></ul>
  9. 10. Edge Side Includes <ul><ul><li>Page composition handled by a proxy server. </li></ul></ul><ul><ul><li>Works with proxies which support Edge Side Includes (e.g. Varnish) </li></ul></ul>
  10. 11. XHR Composition <ul><ul><li>Pagelets are loaded via secondary XHR requests in JavaScript. </li></ul></ul>
  11. 12. Other Options (not yet implemented) <ul><ul><li>Parallel execution. </li></ul></ul><ul><ul><ul><li>Potential to scale out for latency. </li></ul></ul></ul><ul><ul><li>BigPipe style composition. </li></ul></ul>
  12. 13. Internals <ul><ul><li>HMVC requests use Rack internally. </li></ul></ul><ul><ul><li>Easy on Rails 2.3, as routing and controller speak Rack natively - can just inject request into later parts of standard processing pipeline. </li></ul></ul><ul><ul><li>Rails 2.2 support (needed for SK) - backport bits of 2.3 to push Rack requests into controller. </li></ul></ul>
  13. 14. Practical Experience <ul><ul><li>Songkick activity feeds use ActionEmbedding / HMVC since Thursday. </li></ul></ul><ul><ul><li>Measurable but relatively insignificant overhead - still room for improvement. </li></ul></ul><ul><ul><li>Stable so far... </li></ul></ul>
  14. 15. Issues / Todos <ul><ul><li>Try XHR embedding in production. </li></ul></ul><ul><ul><li>Better exception handling (right now you get the error embedded in the pagelet - should interpret response code). </li></ul></ul><ul><ul><li>Consistent approach to constructing nested requests: </li></ul></ul><ul><ul><ul><li>Headers </li></ul></ul></ul><ul><ul><ul><li>Access to cookies </li></ul></ul></ul><ul><ul><li>Security / access control. </li></ul></ul><ul><ul><li>Investigate patterns for configuring pagelets. </li></ul></ul>
  15. 16. Thanks... <ul><li>http://github.com/philcowans/action_embedding </li></ul><ul><li>[email_address] </li></ul><ul><li>@philcowans </li></ul>

×