Successfully reported this slideshow.

Faster on Rails

1,824 views

Published on

Tips to improve you Rails Web Application

Published in: Self Improvement, Technology
  • Be the first to comment

Faster on Rails

  1. 1. Faster on RailsDavid PaluyMay 28, 2012
  2. 2. MeCo-Founder, Startup.Previously, Co-Founder AlgoTrading StartupWorking with Ruby, since 2007 dpaluy dpaluy davidpaluy IsraelRb @LinkedIn
  3. 3. AgendaUsabilityWeb ServersRack Web ServersBack-endFront-endNote: Links
  4. 4. CNN ExampleSource WebPage Test by Google
  5. 5. UsabilityDelay User Reaction0-100 ms Instant0-300 ms Feels sluggish100-1000ms Machine is working...1s + Mental context switch10s + Ill come back later...Source
  6. 6. UsabilityDelay User Reaction0-100 ms Instant0-300 ms Feels sluggish100-1000ms Machine is working...1s + Mental context switchWere here!!! (on average...)10s + Ill come back later...Source
  7. 7. Navigation Timing (W3C)Source Measuring Site Speed with Navigation Timing – Ilya Grigorik
  8. 8. WebPageTest NY Times - test
  9. 9. Best Practice:Measure Analyze Optimize
  10. 10. Scaling RailsView 21 ScreenCasts by Gregg Pollack
  11. 11. Web ServersProcess-Based Server Event-Based Server
  12. 12. Web Servers: Apache vs NginxSource
  13. 13. Web Servers: Apache vs NginxSource The main advantage of the asynchronous approach is scalability!
  14. 14. Rack Web ServerSource
  15. 15. Rack Web Server bySource
  16. 16. Rack Web Server bySource
  17. 17. Rack Web Server VS Read more about Unicorn here Dont use Unicorn without NGINX!
  18. 18. Unicorn sucks at:3rd-party APIsOpenID consumersReverse proxy implementations with editing/censoringHTTP server pushLong pollingReverse AJAXReal-time upload processing
  19. 19. Rainbows! - Unicorn for sleepy apps and slow clients Rainbows ThreadPool Application Source Read more about Rainbows here and Github
  20. 20. Back-End
  21. 21. HTTP Pipelining Communication
  22. 22. SPDY – by GoogleAllows client and server to compress request and response headersAllows multiple, simultaneously multiplexed requests over a single connectionAllows the server to actively push resources to the client that it knows the client will need (e.g. JavaScript and CSS files) SPDY on Rails by Roman Shterenzon
  23. 23. Databases
  24. 24. N+1 redundancy
  25. 25. Tidbits: Automatic Query Explains (Rails 3.2)Log slow queries:Console: Source
  26. 26. Tidbits: Giant queries loading everything into memory Source
  27. 27. Tidbits: Kill Long Running Requests
  28. 28. Tidbits: Favicons and 404 ErrorsAvoid
  29. 29. Tidbits: Linux Serverulimit -nmemcached -t x // x – CPU coresMonitor everything (StatsD with Graphite, Munin, NewRelic, UnionStation)
  30. 30. Client SideYSlowPageSpeed by GoogleHAML vs ERB (Source)How to make your JavaScript Fast
  31. 31. Wish you Faster Browsing!Scaling = replacing all components of a car while driving it at 100 mph (Mike Krieger, Instagram)
  32. 32. ReferencesWebPage Test by GooglePageSpeed by GoogleSPDY by GoogleHow to scale a Ruby Web ServiceScaling InstagramMeasuring Site Speed with Navigation Timing
  33. 33. Thank you!

×