SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
Performanter, hochskalierbarer
    Web 2.0-Dienst in Ruby
      Realisierbar oder nur ein nettes Märchen?


           Tobias Joch, 11. Mai 2007
Referent:


Tobias Joch, ComBOTS

Titel des Vortrags:
Performanter, hochskalierbarer Web2.0-Dienst in Ruby –
Realisierbar oder nur ein nettes Märchen

Stichworte:
Ruby on Rails,RoR,Ruby,Web2.0, ComBOTS

Vorstellung des Referenten:
Tobias Joch ist der Informatik wegen 1998 aus dem schönen Odenwald nach Karlsruhe gezogen.
Während seinem Studium an der Hochschule Karlsruhe arbeitete er beim Steinbeis Transferzentrum
und T-Systems International GmbH bevor er im Sommer 2004 zur WEB.DE AG wechselte. Zurzeit
verantwortet Tobias Joch bei ComBOTS die Softwareentwicklung der Geschäftssysteme.

URLs:
http://www.ruby-lang.org
http://www.rubyonrails.org
http://www.flickr.com
http://www.myspace.com
http://www.youtube.com
https://shop.combots.com
http://de.wikipedia.org/wiki/Web_2

Zielgruppen:
1. Entwickler
2. Systemarchitekten
3. Projektmanager
Abstract
 Ein neues Zeitalter ist angebrochen: Web2.0. Investoren geben viel Geld aus für
 Web2.0- Dienste. Ein rasanter Wettlauf um User-Generated Content hat begonnen und
 es ist kein Ende in Sicht. MySpace, Flickr, YouTube, Wikipedia, unzählige Blogs oder
 etwa Podcasting ist heute von jung bis alt vielen ein Begriff und wird oft auch im Alttag
 genutzt.

 Zeit spielt eine große Rolle bei der Planung und Konzeption eines neuen Web2.0-
 Dienstes. Deshalb findet man neben den üblichen nicht funktionalen Anforderungen wie
 Hochskalierbarkeit und Ausfallsicherheit auch Forderungen hinsichtlich immer kürzerer
 Implementierungszeiten. Neue Frameworks entstehen wie Sand am Meer und jedes
 verspricht dem Interessenten beim Faktor Time to Market das Beste zu sein. Eines der
 populärsten Frameworks dieser Art ist sicherlich Ruby on Rails.

 Im Verlauf des Vortrages werden einige Erfahrungsberichte beim Einsatz von Ruby on
 Rails bei ComBOTS hinsichtlich Performance, Skalierbarkeit und Ausfallsicherheit
 präsentiert. Am Ende bleibt nur noch die Frage: „Performanter, Hochskalierbarer
 Web2.0-Dienst in Ruby – Realisierbar oder nur ein nettes Märchen“
Agenda
•   Was ist Web 2.0
•   Was ist Ruby
•   Web-Server / Infrastruktur
•   Performance Probleme von …
    • Ruby als Sprache
    • Ruby on Rails als Web-Framework
• Skalierung
    • Sessionhandling
    • Loadbalancing
    • Caching
• Fazit
• Ausblick
Was ist Web 2.0
Kurze Definition




   "Design Patterns and Business Models
   for the Next Generation of Software" 1)




                                    [Tim O'Reilly]
Was ist Web 2.0
• Zerplatzen der .com-Blase (Herbst 2001)
• Brainstorming (O'Reilly und MediaLive International, 2003)
    • Dale Dougherty     (O'Reilly Media VP)


• Konzept:
    • „Web 2.0“ als Wendepunkte im Web
• Geburt der 1. "Web 2.0 Konferenz"
Was ist Web 2.0
• Keine neue Version von Web-Standards
   • URI, HTTP, HTML, …
• Ansammlung von Prinzipien und Praktiken
   • Das Web als Plattform
   • Die Nutzung kollektiver Intelligenz
       • Wikipedia,
   • Folksonomy (kollaborativer Kategorisierung)
• Verbesserte Nutzungsmöglichkeiten
   • Podcasts,
   • RSS-Feeds,
   • Social Software (IM, Blogs, Wikis, Bookmarking, Network
     Services, …)
       • User generated content
   • Web APIs, Web Services, Mashups
Web 2.0-ness




               Web
Enorme Geschwindigkeit / Andauernder Beta-Phase




                                            Quelle: http://www.go2web20.net
Wo stehen wir?
Performanter, hochskalierbarer
   Web 2.0-Dienst in Ruby
      Realisierbar oder nur ein nettes Märchen?


           Tobias Joch, 11. Mai 2007
Was ist Ruby?




                Quelle: http://www.ruby-lang.org/en/
•   Japan 1995
•   100% OO
•   Perl, Smalltalk, Eiffel, Ada, and Lisp
•   Exceptions, GC, Threads,
    CrossPlattform...
•   dynamisch typisiert
•   Introspection
•   Module
•   OSS, GPL oder eigene
• Simple Syntax
• Offene Klassen
• Closures / Blocks
• Closures / Blocks
•   Ruby Gem
•   Ruby Doc
•   Interactive Ruby (IRB)
•   Test::Unit
Wo stehen wir nun?
Performanter, hochskalierbarer
  Web 2.0-Dienst in Ruby
      Realisierbar oder nur ein nettes Märchen?


           Tobias Joch, 11. Mai 2007
Was ist Ruby on Rails?
• David Heinemeier Hansson
  • 12 Core Entwickler
  • >100 aktiv Mitwirkende aus der Community
• Fullstack OSS Web-Framework
• Aus bestehender Anwendung extrahiert
 (37signals)

• Implementiert in Ruby
Philosophie
• „…optimized for programmer happiness“
• Convention over Configuration!
  • Keine Komplexe Konfiguration
  • Kein XML für OR-Mapping
  • Anpassbar bei Bedarf
• Don´t repeat yourself! (DRY)
• Testing on all Layers!
Features
•   Scaffolding
•   Rapid Prototyping
•   Model-View-Controller Architektur
•   OR-Mapper
•   DB-Schema Management
•   Configuration Management
•   Ajax Integration
•   Plugins
MVC-Architektur
Webserver-Unterstützung
• Betrieb von Rails-Applikationen via
  • WEBrick
  • mongrel
  • Apache
     • CGI, FCGI, SCGI,
     • mod_ruby
     • mod_proxy (Apache 2.2)
  • lighttpd
     • CGI, FCGI
  • …
Performance Probleme
• Ruby als Sprache
  •   Interpretierte Skriptsprache
  •   ~ 15x langsamer als Java?!
  •   kein Byte-Code, kein JIT, AST wird direkt interpretiert
  •   keine Optimierungen zur Übersetzungszeit
• RoR als Framework
  • Routing
  • ineffiziente Rails Helper-Methoden
  • Assoziationen
  • Ineffizienter DB-Zugriff
  • Langsamer Session Container
Probleme und Lösungen
• step by step …
Ineffizienter DB-Zugriff
• ActiveRecord wurde entwickelt für MySQL
• Oracle Adapter suboptimal
  • keine prepared Statements
  • Spezielles tuning / workaround für Oracle
     • prefetch_rows
     • cursor_sharing

• Model.find_by_sql
• ggf. auch ActiveRecord umgehen
  • direkt per OCI8.new(…)
ActiveRecord
• Verwendung von findern
  • nur das laden, was auch wirklich benötigt wird!
     • :select, :limit, :offset
  • Association Proxies nicht sehr effizient
     • Benötigte Assoziationen gleich mit laden!
     • :include (eager join)
  • dynamische finder
     • mächtig aber auch langsamer
  • MyModel.find_by_sql für
  • Transaktions Block verwenden
ActiveRecord
• Klassisches Database Engineering nicht
  vergessen! ;)
  •   Indexe
  •   Query-Analyse
  •   Views
  •   …
ActionView
• Werden jedes mal neu interpretiert
  • Vergleich zu JSPs
  • Caching, caching, caching
• ViewHelper (=Taglibs)
  • HTML verwenden anstelle von <% form_end %>
  • Plugin verwenden für pre-rendering
• AssetPacker
  • Merged und komprimiert JS und CSS
ActionController
• Filter sind mächtig, aber auch langsam
• Instanzvariablen
  • Pro Request eigene View- und Controller-Instanz
  • Instanzvariabeln werden in die View kopiert
• Eigener Request-Zyklus für Komponenten
  • Besser Partials
Logging
Was kommt jetzt?
Performanter, hochskalierbarer
    Web 2.0-Dienst in Ruby
       Realisierbar oder nur ein nettes Märchen?


            Tobias Joch, 11. Mai 2007
Skalierungsmöglichkeiten
•   Sessionhandling
•   Loadbalancing
•   Caching
•   AJAX / Comet
Sessionhandling
• Memory
• File-System
• Datenbank
  • ActiveRecordStore
  • SQLSessionStore
• Memcached
• DrbStore
Loadbalancing
• Lokal per
  • mod_proxy, mongrel_cluster, fcgi, …
• Mehrstufig
  •   Abhängig vom Sessionhandling
  •   Round-robin
  •   Fastest
  •   Stickiness
Loadbalancing
                 1



               Web-Server
                            mod_fcgi
                2




    FastCGI     FastCGI      FastCGI
     + Ruby     + Ruby        + Ruby

     3a                           3b




          DB                memcached
Loadbalancing (stickiness)
Loadbalancing (round-robin)
                                  Loadbalancer




          Web-Server                                      Web-Server
                       mod_fcgi                                        mod_fcgi




FastCGI    FastCGI      FastCGI              FastCGI       FastCGI      FastCGI
+ Ruby     + Ruby        + Ruby                  + Ruby    + Ruby        + Ruby




                       DB                 memcached
Loadbalancing (round-robin)
Caching
•   Page
     •   Schnell, nur für komplett unpersonalisierte Seiten
•   Action
     •   Zweitschnellste Option
     •   Komplette Rendering-Phase fällt weg
     •   Prozess intensive Berechnungenintensive computations
•   Fragement
     •   Wenn oben Page und Action nicht funktioniert
     •   Extended Fragment Cache Plugin
           •   Content Interpolation
•   Model
     •   acts_as_cached (Plugin)
     •   CachedModel (Plugin)
           •   find(), update()
Caching-Optimierungen
• Module für Apache
  • mod_expires
     • LastModified
  • mod_cache
• memcached
Fazit
  „Performanter, hochskalierbarer Web 2.0-Dienst in Ruby“


• Realisierbar oder nur ein nettes Märchen?
  • Und es geht doch?!
  • Sicherlich nicht für alle Einsatzgebiete
  • „Rails is great but still needs a lot of optimization“
  • Entwicklungsgeschwindigkeit vs. Hardware- und
    Betriebskosten
  • Entwickler… (jobs@combots.com)
Fragen ?!

Tobias Joch, 11. Mai 2007
Ausblick
• Grails
• JRuby

Weitere ähnliche Inhalte

Was ist angesagt?

Grails im Überblick und in der Praxis
Grails im Überblick und in der PraxisGrails im Überblick und in der Praxis
Grails im Überblick und in der PraxisTobias Kraft
 
Informatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und GrailsInformatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und Grailsschmichri
 
SimpleDB - Chancen einer Cloud Datenbank
SimpleDB - Chancen einer Cloud DatenbankSimpleDB - Chancen einer Cloud Datenbank
SimpleDB - Chancen einer Cloud DatenbankONE Schweiz
 
Good by Server... Hello Client!
Good by Server... Hello Client!Good by Server... Hello Client!
Good by Server... Hello Client!Sandro Sonntag
 
Restful Frontend-Architecture
Restful Frontend-ArchitectureRestful Frontend-Architecture
Restful Frontend-ArchitectureSandro Sonntag
 
zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013Andreas Jung
 
Enterprise 2.0 Portale mit Grails. Geht das?
Enterprise 2.0 Portale mit Grails. Geht das?Enterprise 2.0 Portale mit Grails. Geht das?
Enterprise 2.0 Portale mit Grails. Geht das?Tobias Kraft
 
Kann ich mit Grails Enterprise Applikationen umsetzen?
Kann ich mit Grails Enterprise Applikationen umsetzen?Kann ich mit Grails Enterprise Applikationen umsetzen?
Kann ich mit Grails Enterprise Applikationen umsetzen?Tobias Kraft
 
JUG MZ OSGi Lightning Talk
JUG MZ OSGi Lightning TalkJUG MZ OSGi Lightning Talk
JUG MZ OSGi Lightning TalkThilo Käsemann
 
PHP Kongress 2010 - Web-Performance
PHP Kongress 2010 - Web-PerformancePHP Kongress 2010 - Web-Performance
PHP Kongress 2010 - Web-PerformanceNico Steiner
 

Was ist angesagt? (11)

Grails im Überblick und in der Praxis
Grails im Überblick und in der PraxisGrails im Überblick und in der Praxis
Grails im Überblick und in der Praxis
 
Informatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und GrailsInformatik Seminar Groovy Und Grails
Informatik Seminar Groovy Und Grails
 
SimpleDB - Chancen einer Cloud Datenbank
SimpleDB - Chancen einer Cloud DatenbankSimpleDB - Chancen einer Cloud Datenbank
SimpleDB - Chancen einer Cloud Datenbank
 
Good by Server... Hello Client!
Good by Server... Hello Client!Good by Server... Hello Client!
Good by Server... Hello Client!
 
Restful Frontend-Architecture
Restful Frontend-ArchitectureRestful Frontend-Architecture
Restful Frontend-Architecture
 
zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013
 
Jabber/XMPP
Jabber/XMPPJabber/XMPP
Jabber/XMPP
 
Enterprise 2.0 Portale mit Grails. Geht das?
Enterprise 2.0 Portale mit Grails. Geht das?Enterprise 2.0 Portale mit Grails. Geht das?
Enterprise 2.0 Portale mit Grails. Geht das?
 
Kann ich mit Grails Enterprise Applikationen umsetzen?
Kann ich mit Grails Enterprise Applikationen umsetzen?Kann ich mit Grails Enterprise Applikationen umsetzen?
Kann ich mit Grails Enterprise Applikationen umsetzen?
 
JUG MZ OSGi Lightning Talk
JUG MZ OSGi Lightning TalkJUG MZ OSGi Lightning Talk
JUG MZ OSGi Lightning Talk
 
PHP Kongress 2010 - Web-Performance
PHP Kongress 2010 - Web-PerformancePHP Kongress 2010 - Web-Performance
PHP Kongress 2010 - Web-Performance
 

Andere mochten auch

Andere mochten auch (20)

US9004901B2
US9004901B2US9004901B2
US9004901B2
 
Das Microsoft AppStudio (beta)
Das Microsoft AppStudio (beta)Das Microsoft AppStudio (beta)
Das Microsoft AppStudio (beta)
 
Strom von der sonne
Strom von der sonneStrom von der sonne
Strom von der sonne
 
DÉFI SANTÉ LIBERTÉ
DÉFI SANTÉ LIBERTÉDÉFI SANTÉ LIBERTÉ
DÉFI SANTÉ LIBERTÉ
 
Der Schwimmring
Der SchwimmringDer Schwimmring
Der Schwimmring
 
Banner
BannerBanner
Banner
 
Bautagebuch App für Android, iPhone und iPad
Bautagebuch App für Android, iPhone und iPadBautagebuch App für Android, iPhone und iPad
Bautagebuch App für Android, iPhone und iPad
 
J@ck Russell Terrier
J@ck Russell TerrierJ@ck Russell Terrier
J@ck Russell Terrier
 
Ästhetik
ÄsthetikÄsthetik
Ästhetik
 
OPen Government Vortrag Aachen
OPen Government Vortrag AachenOPen Government Vortrag Aachen
OPen Government Vortrag Aachen
 
Bda H1000 211204
Bda H1000 211204Bda H1000 211204
Bda H1000 211204
 
X690 Hd Ib Gemei
X690 Hd Ib GemeiX690 Hd Ib Gemei
X690 Hd Ib Gemei
 
DOC090316-09032016133130
DOC090316-09032016133130DOC090316-09032016133130
DOC090316-09032016133130
 
Internetsucht
InternetsuchtInternetsucht
Internetsucht
 
Pressepaket 2013 Belgien
Pressepaket 2013 BelgienPressepaket 2013 Belgien
Pressepaket 2013 Belgien
 
Windows
WindowsWindows
Windows
 
SEO-Lexikon
SEO-LexikonSEO-Lexikon
SEO-Lexikon
 
Corrientes psicopedagógicas
Corrientes psicopedagógicasCorrientes psicopedagógicas
Corrientes psicopedagógicas
 
Maestria exp
Maestria expMaestria exp
Maestria exp
 
Presentación alberto torres
Presentación alberto torresPresentación alberto torres
Presentación alberto torres
 

Ähnlich wie Performanter, hochskalierbarer Web 2.0-Dienst in Ruby

Was kommt nach den SPAs
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAsQAware GmbH
 
OSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon Meggle
OSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon MeggleOSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon Meggle
OSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon MeggleNETWAYS
 
Schlanke Webarchitekturen nicht nur mit JSF 2 und CDI
Schlanke Webarchitekturen nicht nur mit JSF 2 und CDISchlanke Webarchitekturen nicht nur mit JSF 2 und CDI
Schlanke Webarchitekturen nicht nur mit JSF 2 und CDIadesso AG
 
Agile Softwareentwicklung mit Rails
Agile Softwareentwicklung mit RailsAgile Softwareentwicklung mit Rails
Agile Softwareentwicklung mit RailsHussein Morsy
 
Ruby und Rails für .NET Entwickler
Ruby und Rails für .NET EntwicklerRuby und Rails für .NET Entwickler
Ruby und Rails für .NET EntwicklerNETUserGroupBern
 
Creasoft-Akademie - Mobile Multiplattform Apps
Creasoft-Akademie - Mobile Multiplattform AppsCreasoft-Akademie - Mobile Multiplattform Apps
Creasoft-Akademie - Mobile Multiplattform AppsCreasoft AG
 
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsNever Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsStefan Adolf
 
Ajax in domino web-anwendungen - der nächste schritt
Ajax in domino web-anwendungen - der nächste schrittAjax in domino web-anwendungen - der nächste schritt
Ajax in domino web-anwendungen - der nächste schrittdominion
 
Fanstatic pycon.de 2012
Fanstatic pycon.de 2012Fanstatic pycon.de 2012
Fanstatic pycon.de 2012Daniel Havlik
 
Ist GraphQL das bessere REST
Ist GraphQL das bessere RESTIst GraphQL das bessere REST
Ist GraphQL das bessere RESTMartin Abraham
 
An Introduction to Ruby On Rails
An Introduction to Ruby On RailsAn Introduction to Ruby On Rails
An Introduction to Ruby On RailsJonathan Weiss
 
Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!OPEN KNOWLEDGE GmbH
 
Ruby on Rails - Eine kurze Einführung
Ruby on Rails - Eine kurze EinführungRuby on Rails - Eine kurze Einführung
Ruby on Rails - Eine kurze EinführungThomas R. Koll
 
Supersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusSupersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusOPEN KNOWLEDGE GmbH
 
Icinga 2009 at Nagios Workshop
Icinga 2009 at Nagios WorkshopIcinga 2009 at Nagios Workshop
Icinga 2009 at Nagios WorkshopIcinga
 
Drupal 7 auf Amazon Web Services
Drupal 7 auf Amazon Web ServicesDrupal 7 auf Amazon Web Services
Drupal 7 auf Amazon Web ServicesSven Paulus
 
ShareConf 2014: 10 Gründe warum der SharePoint langsam ist
ShareConf 2014: 10 Gründe warum der SharePoint langsam istShareConf 2014: 10 Gründe warum der SharePoint langsam ist
ShareConf 2014: 10 Gründe warum der SharePoint langsam istDavid Schneider
 

Ähnlich wie Performanter, hochskalierbarer Web 2.0-Dienst in Ruby (20)

Was kommt nach den SPAs
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAs
 
OSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon Meggle
OSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon MeggleOSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon Meggle
OSMC 2012 | End2End-Monitoring von Webapplikationen mit SAHI by Simon Meggle
 
Schlanke Webarchitekturen nicht nur mit JSF 2 und CDI
Schlanke Webarchitekturen nicht nur mit JSF 2 und CDISchlanke Webarchitekturen nicht nur mit JSF 2 und CDI
Schlanke Webarchitekturen nicht nur mit JSF 2 und CDI
 
Agile Softwareentwicklung mit Rails
Agile Softwareentwicklung mit RailsAgile Softwareentwicklung mit Rails
Agile Softwareentwicklung mit Rails
 
Ruby und Rails für .NET Entwickler
Ruby und Rails für .NET EntwicklerRuby und Rails für .NET Entwickler
Ruby und Rails für .NET Entwickler
 
Creasoft-Akademie - Mobile Multiplattform Apps
Creasoft-Akademie - Mobile Multiplattform AppsCreasoft-Akademie - Mobile Multiplattform Apps
Creasoft-Akademie - Mobile Multiplattform Apps
 
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIsNever Code Alone: Von Symfony Forms zu einer SPA auf APIs
Never Code Alone: Von Symfony Forms zu einer SPA auf APIs
 
Ajax in domino web-anwendungen - der nächste schritt
Ajax in domino web-anwendungen - der nächste schrittAjax in domino web-anwendungen - der nächste schritt
Ajax in domino web-anwendungen - der nächste schritt
 
Fanstatic pycon.de 2012
Fanstatic pycon.de 2012Fanstatic pycon.de 2012
Fanstatic pycon.de 2012
 
Ist GraphQL das bessere REST
Ist GraphQL das bessere RESTIst GraphQL das bessere REST
Ist GraphQL das bessere REST
 
Ruby on Rails SS09 02
Ruby on Rails SS09 02Ruby on Rails SS09 02
Ruby on Rails SS09 02
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
An Introduction to Ruby On Rails
An Introduction to Ruby On RailsAn Introduction to Ruby On Rails
An Introduction to Ruby On Rails
 
Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!
 
Ruby on Rails - Eine kurze Einführung
Ruby on Rails - Eine kurze EinführungRuby on Rails - Eine kurze Einführung
Ruby on Rails - Eine kurze Einführung
 
Supersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusSupersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: Quarkus
 
Icinga 2009 at Nagios Workshop
Icinga 2009 at Nagios WorkshopIcinga 2009 at Nagios Workshop
Icinga 2009 at Nagios Workshop
 
ColdFusion gibt's das noch?
ColdFusion gibt's das noch?ColdFusion gibt's das noch?
ColdFusion gibt's das noch?
 
Drupal 7 auf Amazon Web Services
Drupal 7 auf Amazon Web ServicesDrupal 7 auf Amazon Web Services
Drupal 7 auf Amazon Web Services
 
ShareConf 2014: 10 Gründe warum der SharePoint langsam ist
ShareConf 2014: 10 Gründe warum der SharePoint langsam istShareConf 2014: 10 Gründe warum der SharePoint langsam ist
ShareConf 2014: 10 Gründe warum der SharePoint langsam ist
 

Performanter, hochskalierbarer Web 2.0-Dienst in Ruby

  • 1. Performanter, hochskalierbarer Web 2.0-Dienst in Ruby Realisierbar oder nur ein nettes Märchen? Tobias Joch, 11. Mai 2007
  • 2. Referent: Tobias Joch, ComBOTS Titel des Vortrags: Performanter, hochskalierbarer Web2.0-Dienst in Ruby – Realisierbar oder nur ein nettes Märchen Stichworte: Ruby on Rails,RoR,Ruby,Web2.0, ComBOTS Vorstellung des Referenten: Tobias Joch ist der Informatik wegen 1998 aus dem schönen Odenwald nach Karlsruhe gezogen. Während seinem Studium an der Hochschule Karlsruhe arbeitete er beim Steinbeis Transferzentrum und T-Systems International GmbH bevor er im Sommer 2004 zur WEB.DE AG wechselte. Zurzeit verantwortet Tobias Joch bei ComBOTS die Softwareentwicklung der Geschäftssysteme. URLs: http://www.ruby-lang.org http://www.rubyonrails.org http://www.flickr.com http://www.myspace.com http://www.youtube.com https://shop.combots.com http://de.wikipedia.org/wiki/Web_2 Zielgruppen: 1. Entwickler 2. Systemarchitekten 3. Projektmanager
  • 3. Abstract Ein neues Zeitalter ist angebrochen: Web2.0. Investoren geben viel Geld aus für Web2.0- Dienste. Ein rasanter Wettlauf um User-Generated Content hat begonnen und es ist kein Ende in Sicht. MySpace, Flickr, YouTube, Wikipedia, unzählige Blogs oder etwa Podcasting ist heute von jung bis alt vielen ein Begriff und wird oft auch im Alttag genutzt. Zeit spielt eine große Rolle bei der Planung und Konzeption eines neuen Web2.0- Dienstes. Deshalb findet man neben den üblichen nicht funktionalen Anforderungen wie Hochskalierbarkeit und Ausfallsicherheit auch Forderungen hinsichtlich immer kürzerer Implementierungszeiten. Neue Frameworks entstehen wie Sand am Meer und jedes verspricht dem Interessenten beim Faktor Time to Market das Beste zu sein. Eines der populärsten Frameworks dieser Art ist sicherlich Ruby on Rails. Im Verlauf des Vortrages werden einige Erfahrungsberichte beim Einsatz von Ruby on Rails bei ComBOTS hinsichtlich Performance, Skalierbarkeit und Ausfallsicherheit präsentiert. Am Ende bleibt nur noch die Frage: „Performanter, Hochskalierbarer Web2.0-Dienst in Ruby – Realisierbar oder nur ein nettes Märchen“
  • 4. Agenda • Was ist Web 2.0 • Was ist Ruby • Web-Server / Infrastruktur • Performance Probleme von … • Ruby als Sprache • Ruby on Rails als Web-Framework • Skalierung • Sessionhandling • Loadbalancing • Caching • Fazit • Ausblick
  • 5. Was ist Web 2.0 Kurze Definition "Design Patterns and Business Models for the Next Generation of Software" 1) [Tim O'Reilly]
  • 6. Was ist Web 2.0 • Zerplatzen der .com-Blase (Herbst 2001) • Brainstorming (O'Reilly und MediaLive International, 2003) • Dale Dougherty (O'Reilly Media VP) • Konzept: • „Web 2.0“ als Wendepunkte im Web • Geburt der 1. "Web 2.0 Konferenz"
  • 7. Was ist Web 2.0 • Keine neue Version von Web-Standards • URI, HTTP, HTML, … • Ansammlung von Prinzipien und Praktiken • Das Web als Plattform • Die Nutzung kollektiver Intelligenz • Wikipedia, • Folksonomy (kollaborativer Kategorisierung) • Verbesserte Nutzungsmöglichkeiten • Podcasts, • RSS-Feeds, • Social Software (IM, Blogs, Wikis, Bookmarking, Network Services, …) • User generated content • Web APIs, Web Services, Mashups
  • 9. Enorme Geschwindigkeit / Andauernder Beta-Phase Quelle: http://www.go2web20.net
  • 11. Performanter, hochskalierbarer Web 2.0-Dienst in Ruby Realisierbar oder nur ein nettes Märchen? Tobias Joch, 11. Mai 2007
  • 12. Was ist Ruby? Quelle: http://www.ruby-lang.org/en/
  • 13. Japan 1995 • 100% OO • Perl, Smalltalk, Eiffel, Ada, and Lisp • Exceptions, GC, Threads, CrossPlattform... • dynamisch typisiert • Introspection • Module • OSS, GPL oder eigene
  • 16. • Closures / Blocks
  • 17. • Closures / Blocks
  • 18. Ruby Gem • Ruby Doc • Interactive Ruby (IRB) • Test::Unit
  • 20. Performanter, hochskalierbarer Web 2.0-Dienst in Ruby Realisierbar oder nur ein nettes Märchen? Tobias Joch, 11. Mai 2007
  • 21. Was ist Ruby on Rails? • David Heinemeier Hansson • 12 Core Entwickler • >100 aktiv Mitwirkende aus der Community • Fullstack OSS Web-Framework • Aus bestehender Anwendung extrahiert (37signals) • Implementiert in Ruby
  • 22. Philosophie • „…optimized for programmer happiness“ • Convention over Configuration! • Keine Komplexe Konfiguration • Kein XML für OR-Mapping • Anpassbar bei Bedarf • Don´t repeat yourself! (DRY) • Testing on all Layers!
  • 23. Features • Scaffolding • Rapid Prototyping • Model-View-Controller Architektur • OR-Mapper • DB-Schema Management • Configuration Management • Ajax Integration • Plugins
  • 25. Webserver-Unterstützung • Betrieb von Rails-Applikationen via • WEBrick • mongrel • Apache • CGI, FCGI, SCGI, • mod_ruby • mod_proxy (Apache 2.2) • lighttpd • CGI, FCGI • …
  • 26. Performance Probleme • Ruby als Sprache • Interpretierte Skriptsprache • ~ 15x langsamer als Java?! • kein Byte-Code, kein JIT, AST wird direkt interpretiert • keine Optimierungen zur Übersetzungszeit • RoR als Framework • Routing • ineffiziente Rails Helper-Methoden • Assoziationen • Ineffizienter DB-Zugriff • Langsamer Session Container
  • 27. Probleme und Lösungen • step by step …
  • 28. Ineffizienter DB-Zugriff • ActiveRecord wurde entwickelt für MySQL • Oracle Adapter suboptimal • keine prepared Statements • Spezielles tuning / workaround für Oracle • prefetch_rows • cursor_sharing • Model.find_by_sql • ggf. auch ActiveRecord umgehen • direkt per OCI8.new(…)
  • 29. ActiveRecord • Verwendung von findern • nur das laden, was auch wirklich benötigt wird! • :select, :limit, :offset • Association Proxies nicht sehr effizient • Benötigte Assoziationen gleich mit laden! • :include (eager join) • dynamische finder • mächtig aber auch langsamer • MyModel.find_by_sql für • Transaktions Block verwenden
  • 30. ActiveRecord • Klassisches Database Engineering nicht vergessen! ;) • Indexe • Query-Analyse • Views • …
  • 31. ActionView • Werden jedes mal neu interpretiert • Vergleich zu JSPs • Caching, caching, caching • ViewHelper (=Taglibs) • HTML verwenden anstelle von <% form_end %> • Plugin verwenden für pre-rendering • AssetPacker • Merged und komprimiert JS und CSS
  • 32. ActionController • Filter sind mächtig, aber auch langsam • Instanzvariablen • Pro Request eigene View- und Controller-Instanz • Instanzvariabeln werden in die View kopiert • Eigener Request-Zyklus für Komponenten • Besser Partials
  • 35. Performanter, hochskalierbarer Web 2.0-Dienst in Ruby Realisierbar oder nur ein nettes Märchen? Tobias Joch, 11. Mai 2007
  • 36. Skalierungsmöglichkeiten • Sessionhandling • Loadbalancing • Caching • AJAX / Comet
  • 37. Sessionhandling • Memory • File-System • Datenbank • ActiveRecordStore • SQLSessionStore • Memcached • DrbStore
  • 38. Loadbalancing • Lokal per • mod_proxy, mongrel_cluster, fcgi, … • Mehrstufig • Abhängig vom Sessionhandling • Round-robin • Fastest • Stickiness
  • 39. Loadbalancing 1 Web-Server mod_fcgi 2 FastCGI FastCGI FastCGI + Ruby + Ruby + Ruby 3a 3b DB memcached
  • 41. Loadbalancing (round-robin) Loadbalancer Web-Server Web-Server mod_fcgi mod_fcgi FastCGI FastCGI FastCGI FastCGI FastCGI FastCGI + Ruby + Ruby + Ruby + Ruby + Ruby + Ruby DB memcached
  • 43. Caching • Page • Schnell, nur für komplett unpersonalisierte Seiten • Action • Zweitschnellste Option • Komplette Rendering-Phase fällt weg • Prozess intensive Berechnungenintensive computations • Fragement • Wenn oben Page und Action nicht funktioniert • Extended Fragment Cache Plugin • Content Interpolation • Model • acts_as_cached (Plugin) • CachedModel (Plugin) • find(), update()
  • 44. Caching-Optimierungen • Module für Apache • mod_expires • LastModified • mod_cache • memcached
  • 45. Fazit „Performanter, hochskalierbarer Web 2.0-Dienst in Ruby“ • Realisierbar oder nur ein nettes Märchen? • Und es geht doch?! • Sicherlich nicht für alle Einsatzgebiete • „Rails is great but still needs a lot of optimization“ • Entwicklungsgeschwindigkeit vs. Hardware- und Betriebskosten • Entwickler… (jobs@combots.com)
  • 46. Fragen ?! Tobias Joch, 11. Mai 2007