Upload
danielmattes
View
1.446
Download
0
Embed Size (px)
Citation preview
begin RailsWayCon.new ...
Zusammenfassung der Ruby on Rails Konferenz 2009 in Berlin
Daniel Mattes, 4. Juni 2009
04.06.2009 RailsWayCon 2009 2
Über michDaniel Mattes
Angestellter bei der BurdaWireless GmbH
email: [email protected]://www.xing.com/profile/Daniel_Mattes2http://www.actsasblog.de
04.06.2009 RailsWayCon 2009 3
AgendaAsynchronous Processing in RubyHAML/SASS/COMPASSJRubyRails PerformanceFrontend OptimizationjQuery…others
04.06.2009 RailsWayCon 2009 4
Asynchronous Processing in Ruby
Title: The State of Asynchronous Processing in Ruby - Mathias MeyerSlides: http://www.paperplanes.de/2009/5/27/railswaycon_slides.htmlLinks
http://github.com/ezmobius/nanite/tree/masterhttp://www.rabbitmq.com/http://github.com/tobi/delayed_job/tree/master
04.06.2009 RailsWayCon 2009 5
Asynchronous Processing in Ruby
When?Requests are taking too longTasks on a certain timeLonger running tasks
04.06.2009 RailsWayCon 2009 6
Asynchronous Processing in Ruby
Nanite (the big one) Using RabbitMQScalling
Build in error/exceptions reportsRecommendations
simple delayed_jobs
distributedWhen using EC2 -> Amazon SQS
heavy load, scalableNanite/RabbitMQ
04.06.2009 RailsWayCon 2009 7
HAML/SASS/COMPASS
Title: Show the Frontend some Love: HAML and SASS - Jan KrutischSlides: http://www.slideshare.net/jan_mindmatters/haml-sass-and-compassLinks
http://haml.hamptoncatlin.com/http://haml.hamptoncatlin.com/docs/rdoc
04.06.2009 RailsWayCon 2009 8
HAML
ERB<div id='content'><div class='left column'>
<h2>Welcome to our site!</h2><p>
<%= print_information %></p>
</div><div class="right column">
<%= render :partial => "sidebar" %></div>
</div>
HAML#content.left.column
%h2 Welcome to our site!%p= print_information
.right.column= render :partial => "sidebar"
04.06.2009 RailsWayCon 2009 9
HAML
HAMLoutputs beautiful codegem install hamlautomatically creates self-closing tags for img, br,... attributes
ruby hash syntax: %head{ :language => 'german'} & html_escape
can be set as default== interpolates ruby strings- = don't output, e. g. for .eachautomated id generation: %li[obj] <li id=obj.id..... / output html commentsyou can migrate your erb step by step
04.06.2009 RailsWayCon 2009 10
SASS
SASS!main_bg= #46ar12!main_width= 40em
#main:background-color= !main_bg:width= !main_width.sidebar:background-color= !main_bg +
#333333:width= !main_width - 25em
CSS
#main {background-color: #46a312;width: 40em; }#main .sidebar {background-color: #79d645;width: 15em; }
04.06.2009 RailsWayCon 2009 11
SASS
SASSinstallation: its included in hamlyou can create nested stylesyou can create constantscan do calculationsmixins, by using = for definition, + for usageyou can use loops
04.06.2009 RailsWayCon 2009 12
COMPASS
COMPASS = CSS-Framework
04.06.2009 RailsWayCon 2009 13
Migration to JRuby
Title: The Pleasure and Pain of Migrating to jRuby - Steven Bristol
Why switch?performancescalabilityjava api
04.06.2009 RailsWayCon 2009 14
Migration to JRuby
Problems:Gems like ferret, file_column take othersolutionsDeployment with Glassfish
Complicatedmuch slower than with mongrel
RecommendationIf you don‘t need to convert your hole app, just build a small application which exposes a rest interface.
04.06.2009 RailsWayCon 2009 15
Rails PerformanceTitle: Rails Performance - Michael Koziarskifirst focus to frontend performance
yslow: http://developer.yahoo.com/yslow/javascript_include_tag:defaults, :cache => true
My suggestionhttp://github.com/yolk/rucksack/tree/masterIt‘s a packer like asset_package, asset_compressor
sprite your images: http://websitetips.com/articles/css/sprites/
04.06.2009 RailsWayCon 2009 16
Rails Performance1. What is slow?
heavily used? cache
etagslast updated headerExpires header
browser don't look for a specific time
fresh_when
04.06.2009 RailsWayCon 2009 17
Rails Performance2. Why is it slow?
performance testsrake test:benchmarkNewRelic RPM: http://www.newrelic.com/Fiveruns Tuneup: http://www.fiveruns.com/http://github.com/dsboulder/query_reviewer/tree/master
04.06.2009 RailsWayCon 2009 18
Rails Performance3. Improve it
often used image create image tag manuallylook at url generatorslook at garbage collection
RUBY_HEAP_MIN_SLOTS RUBY_GC_MALLOC_LIMITRUBY_HEAP_FREE_MIN
04.06.2009 RailsWayCon 2009 19
Rails PerformanceAt least…
you can start to cache, scale, dbpartitioning,…http://railslab.newrelic.com/scaling-rails
04.06.2009 RailsWayCon 2009 20
Frontend Optimazation
Title: Boost your Website's Performance with Frontend Optimization - Ralph von der HeydenSlides: http://www.slideshare.net/ralphvdh/front-end-performance-railswaycon-2009-short-talk
04.06.2009 RailsWayCon 2009 21
Frontend Optimazation
Why?e. g. Amazon sells 1% less stuff per 100ms more loading time
Backend: 10 % loading timeFrontend: 90 % loading timeWho?
Fewer RequestsSmaller RequestsSpeed up Requests
04.06.2009 RailsWayCon 2009 22
Frontend Optimazation
Fewer requestsJoin CSS/JavascriptsSprite imagesexpires header
04.06.2009 RailsWayCon 2009 23
Frontend Optimazation
Smaller requestsgzip your text
Apache: mod_deflateminify js and cssimages
png is usually smaller than gifstrip JPG meta datahttp://smush.it/
04.06.2009 RailsWayCon 2009 24
Frontend Optimazation
Speed up requestsmost browsers load 2 files per hostMultiple domains for static contentRails: Set 4 asset hosts 8 parallel downloadsconfig.action_controller.asset_host = „http://assets%d.foobar.com“
Content Delivery Networks for static files
04.06.2009 RailsWayCon 2009 25
Frontend Optimazation
Tools?FirebugYSlow
04.06.2009 RailsWayCon 2009 26
jQuery
Title: jQuery with Rails - Yehuda KatzSlides: http://yehudakatz.com/wp-content/uploads/2009/05/jquerytutorial.pdfLinks
http://docs.jquery.com/Main_PageWhy?
Write less, do more!Separation of JavaScript and HTMLA lot of plugins
04.06.2009 RailsWayCon 2009 27
jQuery
Observer$(“h1”).click(function() {
$(this).fadeIn();});
Selectors#id, element, .class, class.classparent, child, prev, next:first, :last, :not(..)[attribute=value]
$("input[name='newsletter']").next().text(" is newsletter");
04.06.2009 RailsWayCon 2009 28
jQuery
Traversal$(“div”).attr(“id”, “hello”) $(“div”).removeAttr(“id”);$(“div”).addClass(“foo”)$(“div”).toggleClass(“foo”)$(“div”).html(“<p>Hello</p>”)
Manipulation$(“div”).append(“<p>Hello</p>”)$(“<p>Hello</p>”).insertAfter(“div”)
04.06.2009 RailsWayCon 2009 29
jQuery
$(document).ready(function() { ... })
$(“div”).bind(“click”, function() { ... })Alias: $(“div”).click(function() { ... })
$(“div”).hover(function() { ... }, function() { ... })
$(“div”).toggle(function() { ... }, function() { ... })
$(“div”).live(“click”, function() { ... })
04.06.2009 RailsWayCon 2009 30
jQuery
$(“div”).fadeIn()$(“div”).fadeOut(“slow”)$(“div”).slideUp(200)$(“div”).slideDown(“slow”)$(“div”).animate({height: “toggle”, opacity: “toggle”})$(“div”).animate({fontSize: “24px”, opacity: 0.5}, {easing: “expo”})
04.06.2009 RailsWayCon 2009 31
OthersRuby sittin on the Couch - Alexander Lang
http://www.slideshare.net/langalex/ruby-sittin-on-the-couch
it uses javascriptrestful http interfaceit scales
optimistic lockingreplication
written in erlang it saves json
04.06.2009 RailsWayCon 2009 32
OthersFrom Rails to Rack: Making Rails 3 a better Ruby Citizen - Yehuda Katz
http://pivotallabs.com/users/woosley/blog/articles/878-from-rails-to-rack-making-rails-3-a-better-ruby-citizen-yehuda-katz-Features
Middlewarerack-testsdifferent ORMs (ActiveRecord, DataMapper,…)Javascript no more Prototype-specefic (jQuery, Mootools,…)faster Filters and Controllers
04.06.2009 RailsWayCon 2009 33
OthersRuby/Rails in the Enterprise - MaikSchmidt
xmluse libxml for xml operations
implemented in c very fast you can validate by schema
internationalization
04.06.2009 RailsWayCon 2009 34
...rescue TimeLimitExceeded
puts "...habe fertig!"puts "danke ;-)"
end