Asynchronous Personalization at Groupon - JSConf 2011


Published on

Slides from my talk at JSConf 2011. Covers the usage of asynchronous personalization, CDNs, and A/B testing with Finch.js at Groupon.

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Asynchronous Personalization at Groupon - JSConf 2011

  1. 1. asynchronous personalization [and CDNs and A/B testing and stuff] Jon Pliske Performance Engineering, Groupon @jonpliske
  2. 2. You might know me from this leaked photo on TechCrunch Jon PliskePerformance Engineering, Groupon @jonpliske
  3. 3. overview background CDN caching async personalization a/b/multivariate testing /w finch.js
  4. 4. performance anxiety big rails app performance issues big team === development process hurdles big traffic drinking problems Reaching limit of Rails caching Low-level optimizations too "incremental" Rewriting SQL is boring Improve platform architecture
  5. 5. super bowl partyprelude:jan 1. "btw we have pre/post super bowl commercials"jan 15. "scored an in-game spot, we good?"feb 15. offend the world"spike mode": CDN cache it all! disable login offload geocoding/subscriptions/orders to EC2 limited functionality === unhappy users
  6. 6. pics or it didnt happen
  7. 7. pics or it didnt happen
  8. 8. CDNs are neatpros conslow latency dynamic content"edge side nodes" personalizationhigh capacity complexitystatic content overkill? specifically: personalized content (login menu, deals) analytics tracking a/b testing Rails developers
  9. 9. async personalizationtarget: deal/division pages (> 50% of traffic)approach:1. cache "anonymous" page in CDN2. hide stuff3. make AJAX request for personalized data/content4. show stuffSee Chris Williams "Rails’ Best Caching Method is JavaScript"from GoRuCo 2010
  10. 10. obligatory omnigraffle diagram
  11. 11. "Anonymous" userbefore:initial page response time: 0.8 secrendering time (e.g. loading css/js/images): 1 sectotal: 1.8 secafter:initial page response time: 0.1 secrendering time: 1 sectotal: 1.1 seconly a little bit faster...(1.1 vs 1.8 sec)basically no server load => huge capacity increase!
  12. 12. Logged-in User / Subscriberbefore:initial page response time: 3 secrendering time (e.g. loading js/css/images): 1 sectotal time: 4 secafter:initial page response time: 0.1 secrendering time (include AJAX call:1 sec): 1 sectotal time: 1.1 secCapacity constant: AJAX call still needs to hit Rails300% faster!
  13. 13. [wait for applause]
  14. 14. development implicationsless Rails, more JS1 user !== 1 (Rails) requestgoodbye:current_usersessioncookiestesting
  15. 15. onCurrentUserReady(callback)callback when personalize API returns (or callback immediatelyfor anonymous user)before:- if logged_in? do stuff for logged-in user- else do stuff for anonymous userafter:Groupon.onCurrentUserReady(function(){ if (Groupon.currentUser.isAuthenticated) { do stuff for logged-in user } else { do stuff for anonymous user }});
  16. 16. analyticsProblem: Request loggingSolution: Tracking pixel (hit Nginx only, not Rails)Problem: Content changesSolution: Dynamic tracking pixelProblem: Tracking params (e.g. utm params, affiliate id, etc...)Solution: Store in cookie; append params to API request
  17. 17. a/b testing with FinchProblem: Finch uses view/controller logic to choose and trackexperiments and variants- experiment Two vs. Three Step Subscription do |e| - e.variant Original do %h1 Fill out this form to subscribe now - e.variant Two Step do %h4 Follow these two steps to subscribe - e.variant Three Step do %p Subscribe now - it only takes a few seconds
  18. 18. Finch.jsFinch.Experiments.DelayedJSExperiment = { defer: function() { var experiment = this; FinchDemo.onCurrentUserReady(function() { experiment.deferedRun(this); }); }, before: function() { $(#delayed).hide(); }, after: function() { $(#delayed).show(); }, variants: { original: function() { $(#delayed .original).show(); }, alternate: function() { $(#delayed .alternate).show();}, }};$(function() {;});
  19. 19. Finch.js based on Googles "Overlapping Experiment Infrastructure" written in coffee-script open source soon-ishly ~ 15k of JS doesnt handle tracking/analytics/analysis side of testing (yet?)
  20. 20. the futurepure-JSON API requestsclient-side rendering (/w mustache.js)HTML5 storagedecouple from Railsdevelopment practices:front/back-end integrationbetter testingbetter monitoring
  21. 21. Thank you!