Rubyconf presentation

301 views

Published on

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
301
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Rubyconf presentation

  1. 1. Large Scale Ruby Project, Challenges and Pitfalls● Karunakar Revuri● Castle Rock Research● Rails Contributor● @karuna_revuri● https://github.com/Karunakar
  2. 2. Ruby Project● Code● Tests● Performance
  3. 3. Test Driven Development
  4. 4. Good● My_code has_many units and functionals● Thoughtbot-shoulda
  5. 5. Bad● Test suite is taking more than 45 mins
  6. 6. Why?● Many tests● Bad Tests● Unnecessary objects● Unnecessary tests● Tests with assert true● Tests with !assert failure● Big tests● Random failure tests
  7. 7. Solution● Cleanup● Mock your objects when needed● Run tests in parallel
  8. 8. DEMO
  9. 9. Behavior Driven DevelopmentFRAMEWORK● Cucumber-capybaraGOODMyCode has many scenariosBAD● Cucumber is slow because of selenium
  10. 10. Selenium● Running selenium with cucumber can eat up lot of time.● Build time reached more than 3 hours
  11. 11. Solutions● @rack_test● Parallel processes
  12. 12. BORGA Distributed Test Suite Runner for Rails-- Hemant Kumar and Karunakar● Eventmachine is fast, simple eventmachine processing lib● Redis is advanced key value storage
  13. 13. How BORG works? Developer Machine-1 Borg Server Developer Machine-2 CruiseMachine Developer Redis Machine-3 Server
  14. 14. BORG Supports● Shoulda on MRI with rails● Cucumber on MRI with rails● Rake::Test on MRI with rails● Rspec on MRI with railsWorks with 1.8.7 and 1.9.1, 1.9.2 with rails2x and 3xhttps://github.com/Karunakar/borghttps://github.com/gnufied/borg
  15. 15. GOOD and BADGOOD● Fast build● Devs spend less time waiting to checkinBAD● Developer machines● Test Splitting
  16. 16. Code Coverage Tools● Simple Cov 1.9● Rcov 1.8
  17. 17. Continuous Integration● Continuous processes of applying quality● Reduce the time to deliver● Build
  18. 18. Continuous Integration● Continuous processes of applying quality● Reduce the time to deliver● Build
  19. 19. Code Quality● Pair programming● Code review
  20. 20. Pairing Environment
  21. 21. Advantages● Code is clean● Bugs are less● More than one will be familiar with code● Sharing the knowledge is easy● Good Learning curve● Maintaining the code quality
  22. 22. Disadvantages● Active vs Passive● Communication between the pairsSolutions Switch the pairs frequently
  23. 23. Code Reviews● Code review helps spread information about a project between team members● Allows people to suggest ideas and help clarify code● Its a good time to implement some small refactoring, as soon as problems are found● Works best with small groups
  24. 24. Statistical Code AnalysisStatistics of code without actually executing code
  25. 25. rake stats
  26. 26. Code Smell using REEK● Duplicate Code● Long Method● Large Class● Simulated Polymorphism
  27. 27. Performance Improvements● Internal quality● External quality (External quality is end user happiness)
  28. 28. Performance Tools● Bullet● Rails indexes● NewRelic● Oink
  29. 29. Demo on Bullet
  30. 30. Rails Indexes Demo
  31. 31. Oink● Memory usage in rails applications● Memory and active record instantiation information
  32. 32. Oink2012-03-25T03:45:15+00:00 app[web.2]: Oink Action:sessions#new2012-03-25T03:45:15+00:00 app[web.2]: Memory usage:500408 | PID: 32012-03-25T03:45:15+00:00 app[web.2]: InstantiationBreakdown: Total: 13 | RegionalOption: 8 | Region: 3 |Country: 2
  33. 33. New Relic● Performance management tool● Slow web transactions● Database hits and queries● Slow web pages● What are the reasons
  34. 34. Optimization● Find with select● Eager loading● Use active-reload in development● Use ActiveRecord to_xml instead of the xml_bulders● Validations when needed● Use memcache● Use query-analyzer in development
  35. 35. Optimization● Iterators● Explain command● Error notifier
  36. 36. Client Side● Asset pipelining● Load the js at the end of the file● Valid HTML / XHTML
  37. 37. Thanks
  38. 38. Questions

×