0
Merb, not rails? !
A practical introduction to a new framework.
Intro to merb
What is merb?

• MVC Framework.
• Similar to Rails.
• Lightweight, extensible, fast.
Merb Ideology

• Hacker-friendly.
• Core should be small, plugins bountiful.
• Code should be as simple as possible.
• Cod...
Merb is like rails


• Application structure is very similar
• Can use ActiveRecord
What does merb-core include?

• rack-based request handling
• session handling
• before / after filters
• layouts / views w...
What does merb-core include?

• gem-based plugins
• mailers
• partials
• exceptions
• generator for controllers, and model...
What is elsewhere?

• an ORM (can use ActiveRecord,
  DataMapper, Sequel)
• form helpers such as form_for
  (merb_helper)
...
What is elsewhere?
• flash (merb_has_flash and
  redirect :message)
 • redirect(quot;/posts/34quot;, :message =>
    { :noti...
DataMapper

• Thread-safe.
• Supports data stores you don’t manage.
• Optimizations in eager-loading, lazy-loading,
  etc.
What do we need
 helper functions for?

• Why not just use HTML for templating
  instead of all those helper functions?
• ...
Thread-safety

• Merb is thread-safe now.
• Rails will be thread-safe in 2.2.
• What does that mean? http://
  blog.headiu...
Considerations
• Does your app block?
 • File uploads
 • Remote HTTP calls
   • Facebook app: 1-2s wait time?
• Do you hav...
Instances Required
                                Merb   Rails

C MRI, one core, no blocking     1      1

C MRI, one cor...
Case study
The Project

• CMS for Faculty.
• Keeps track of courses, education,
  biography info, etc.
• Deployed to Tomcat.
Requirements

• 2500 faculty websites.
• 5 concurrent backend users.
• 500 users per day on the public facing
  pages.
Can Rails handle that?


• One process per file upload?
• RAM requirements?
Why merb?

• Thread-safe.
• Low memory footprint.
• ???
Why JRuby?


• Authentication integration using JRadius
• Java platform lowers IT stress level.
What is development
         like?
• There are no books... yet.
• The codebase is changing.
• Smaller userbase than rails....
Problems
• File upload broken in Tomcat deploy.
• Partial behavior is totally weird.
• Render syntax changed / broke expor...
Other Issues


• acts_as_list had to be extracted from
  ActiveRecord files and manually included in
  init.rb.
Post-mortem
Speed Comparison

•   Test with simple merb / rails apps using ActiveRecord

•   Tests using ab -n 10000

•   Testing seri...
C MRI Mongrel


• Merb: 170 requests / second
• Rails: 32 requests / second
JRuby Tomcat


• Merb: 69 requests / second
• Rails : 121 requests / second
JRuby Mongrel


• Merb: 104 requests / second
• Rails: 29 requests / second
JRuby Glassfish


• Merb: 106 requests / second
• Rails : 125 requests / second
What is the deal?

• JRuby thread pool, instead of thread
  instantiation?
• Default session handling?
• Overspinning thre...
Tomcat Memory Usage

• Merb: ~30 MB for all threads
• Rails: ~60 MB+ additional memory per
  process


• (Tested on Tomcat)
Was it worth it?
• Thread-safety is a minor advantage when it
  comes to file uploads.
• Merb uses less memory.
• Merb is s...
Conclusion
Consider merb if...
• you’re writing a small tool.
• you have limited memory requirements.
• you like trying new ORMs.
• y...
Upcoming

• Merb 1.0 is released Oct 11-12.
• MerbCamp is in San Diego Oct 11-12.
• Merb in Action book (2009?).
Available

• I’m available for contracts again. Talk to me
  here, at 408-646-2240 or
  paulboone@mindbucket.com.
• http:/...
Practical Intro Merb
Upcoming SlideShare
Loading in...5
×

Practical Intro Merb

1,574

Published on

from http://www.mindbucket.com

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

No Downloads
Views
Total Views
1,574
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Practical Intro Merb"

  1. 1. Merb, not rails? ! A practical introduction to a new framework.
  2. 2. Intro to merb
  3. 3. What is merb? • MVC Framework. • Similar to Rails. • Lightweight, extensible, fast.
  4. 4. Merb Ideology • Hacker-friendly. • Core should be small, plugins bountiful. • Code should be as simple as possible. • Code should not be “magical.”
  5. 5. Merb is like rails • Application structure is very similar • Can use ActiveRecord
  6. 6. What does merb-core include? • rack-based request handling • session handling • before / after filters • layouts / views with erb • routing
  7. 7. What does merb-core include? • gem-based plugins • mailers • partials • exceptions • generator for controllers, and models (integrates with your chosen ORM).
  8. 8. What is elsewhere? • an ORM (can use ActiveRecord, DataMapper, Sequel) • form helpers such as form_for (merb_helper) • ActiveSupport and all those little ruby extensions (extlib?)
  9. 9. What is elsewhere? • flash (merb_has_flash and redirect :message) • redirect(quot;/posts/34quot;, :message => { :notice => 'Post updated successfully!' }) • scaffolding • caching (merb-cache) • ajax library (merb_jquery)
  10. 10. DataMapper • Thread-safe. • Supports data stores you don’t manage. • Optimizations in eager-loading, lazy-loading, etc.
  11. 11. What do we need helper functions for? • Why not just use HTML for templating instead of all those helper functions? • Why not just use JQuery for AJAX instead of all those AJAX helper functions?
  12. 12. Thread-safety • Merb is thread-safe now. • Rails will be thread-safe in 2.2. • What does that mean? http:// blog.headius.com/2008/08/qa-what-thread- safe-rails-means.html
  13. 13. Considerations • Does your app block? • File uploads • Remote HTTP calls • Facebook app: 1-2s wait time? • Do you have native threads? • JRuby / C ruby differences
  14. 14. Instances Required Merb Rails C MRI, one core, no blocking 1 1 C MRI, one core, 80% blocking 1 5 C MRI, two cores, no blocking 2 2 C MRI, two core, 80% blocking 2 10 Jruby, one core, no blocking 1 1 Jruby, one core, 80% blocking 1 5 Jruby, two cores, no blocking 1 2 Jruby, two core, 80% blocking 1 10 Jruby, 16 cores, 80% blocking 1 80
  15. 15. Case study
  16. 16. The Project • CMS for Faculty. • Keeps track of courses, education, biography info, etc. • Deployed to Tomcat.
  17. 17. Requirements • 2500 faculty websites. • 5 concurrent backend users. • 500 users per day on the public facing pages.
  18. 18. Can Rails handle that? • One process per file upload? • RAM requirements?
  19. 19. Why merb? • Thread-safe. • Low memory footprint. • ???
  20. 20. Why JRuby? • Authentication integration using JRadius • Java platform lowers IT stress level.
  21. 21. What is development like? • There are no books... yet. • The codebase is changing. • Smaller userbase than rails. • If you are doing anything weird, be prepared to corepatch!
  22. 22. Problems • File upload broken in Tomcat deploy. • Partial behavior is totally weird. • Render syntax changed / broke export code. • Activerecord-jdbc mysql quote error. • String concurrency problem??
  23. 23. Other Issues • acts_as_list had to be extracted from ActiveRecord files and manually included in init.rb.
  24. 24. Post-mortem
  25. 25. Speed Comparison • Test with simple merb / rails apps using ActiveRecord • Tests using ab -n 10000 • Testing serially, not concurrently. • Tested on this MacBook Pro
  26. 26. C MRI Mongrel • Merb: 170 requests / second • Rails: 32 requests / second
  27. 27. JRuby Tomcat • Merb: 69 requests / second • Rails : 121 requests / second
  28. 28. JRuby Mongrel • Merb: 104 requests / second • Rails: 29 requests / second
  29. 29. JRuby Glassfish • Merb: 106 requests / second • Rails : 125 requests / second
  30. 30. What is the deal? • JRuby thread pool, instead of thread instantiation? • Default session handling? • Overspinning threads in app server? • Incorrect JIT compilation?
  31. 31. Tomcat Memory Usage • Merb: ~30 MB for all threads • Rails: ~60 MB+ additional memory per process • (Tested on Tomcat)
  32. 32. Was it worth it? • Thread-safety is a minor advantage when it comes to file uploads. • Merb uses less memory. • Merb is slower than rails. • Merb may die on string thread-safe bug until JRuby / Merb team fix it.
  33. 33. Conclusion
  34. 34. Consider merb if... • you’re writing a small tool. • you have limited memory requirements. • you like trying new ORMs. • you need fast performance (and you’ve figured out why it runs so slow on JRuby). • you like hacking about in frameworks.
  35. 35. Upcoming • Merb 1.0 is released Oct 11-12. • MerbCamp is in San Diego Oct 11-12. • Merb in Action book (2009?).
  36. 36. Available • I’m available for contracts again. Talk to me here, at 408-646-2240 or paulboone@mindbucket.com. • http://www.mindbucket.com/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×