Faster on Rails

  • 1,003 views
Uploaded on

Tips to improve you Rails Web Application

Tips to improve you Rails Web Application

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,003
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
8
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • - In a process-based server, each simultaneous connection requires a thread which incurs significant overhead. - An asynchronous server is event-driven and handles requests in a single (or at least, very few) threads.
  • Hot Standby - A method of redundancy in which the primary and secondary (i.e., backup) systems run simultaneously. The data is mirrored to the secondary server in real time so that both systems contain identical information. Warm Standby - A method of redundancy in which the secondary (i.e., backup) system runs in the background of the primary system. Data is mirrored to the secondary server at regular intervals, which means that there are times when both servers do not contain the exact same data. Cold Standby - A method of redundancy in which the secondary system is only called upon when the primary system fails. The system on cold standby receives scheduled data backups, but less frequently than a warm standby. Used for non-critical applications or in cases where data is changed infrequently.

Transcript

  • 1. Faster on RailsDavid PaluyMay 28, 2012
  • 2. MeCo-Founder, Startup.Previously, Co-Founder AlgoTrading StartupWorking with Ruby, since 2007 dpaluy dpaluy davidpaluy IsraelRb @LinkedIn
  • 3. AgendaUsabilityWeb ServersRack Web ServersBack-endFront-endNote: Links
  • 4. CNN ExampleSource WebPage Test by Google
  • 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. 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. Navigation Timing (W3C)Source Measuring Site Speed with Navigation Timing – Ilya Grigorik
  • 8. WebPageTest NY Times - test
  • 9. Best Practice:Measure Analyze Optimize
  • 10. Scaling RailsView 21 ScreenCasts by Gregg Pollack
  • 11. Web ServersProcess-Based Server Event-Based Server
  • 12. Web Servers: Apache vs NginxSource
  • 13. Web Servers: Apache vs NginxSource The main advantage of the asynchronous approach is scalability!
  • 14. Rack Web ServerSource
  • 15. Rack Web Server bySource
  • 16. Rack Web Server bySource
  • 17. Rack Web Server VS Read more about Unicorn here Dont use Unicorn without NGINX!
  • 18. Unicorn sucks at:3rd-party APIsOpenID consumersReverse proxy implementations with editing/censoringHTTP server pushLong pollingReverse AJAXReal-time upload processing
  • 19. Rainbows! - Unicorn for sleepy apps and slow clients Rainbows ThreadPool Application Source Read more about Rainbows here and Github
  • 20. Back-End
  • 21. HTTP Pipelining Communication
  • 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. Databases
  • 24. N+1 redundancy
  • 25. Tidbits: Automatic Query Explains (Rails 3.2)Log slow queries:Console: Source
  • 26. Tidbits: Giant queries loading everything into memory Source
  • 27. Tidbits: Kill Long Running Requests
  • 28. Tidbits: Favicons and 404 ErrorsAvoid
  • 29. Tidbits: Linux Serverulimit -nmemcached -t x // x – CPU coresMonitor everything (StatsD with Graphite, Munin, NewRelic, UnionStation)
  • 30. Client SideYSlowPageSpeed by GoogleHAML vs ERB (Source)How to make your JavaScript Fast
  • 31. Wish you Faster Browsing!Scaling = replacing all components of a car while driving it at 100 mph (Mike Krieger, Instagram)
  • 32. ReferencesWebPage Test by GooglePageSpeed by GoogleSPDY by GoogleHow to scale a Ruby Web ServiceScaling InstagramMeasuring Site Speed with Navigation Timing
  • 33. Thank you!