Skalieren von Rails Anwendungen mit Amazon S3 und EC2
-
Upload
jonathan-weiss -
Category
Technology
-
view
2.957 -
download
0
description
Transcript of Skalieren von Rails Anwendungen mit Amazon S3 und EC2
Skalieren von Rails Anwendungenmit Amazon S3 und EC2
Jonathan Weiss, Peritor Wissensmanagement GmbH22.06.2007, Rails Konferenz
2
Ausgangslage
Eine Maschine:
• Apache
• Ruby / Rails
• MySQL
3
Worst Case Popularität
4
Steiniger Weg
5
Problem: Backup
• Hochverfügbar
• Redundant
• Große Datenmengen
6
Problem: File System
• Wichtige Dateien müssen allen Systemen zugänglich sein
• NFS / Samba unpraktikable Lösungen
7
Problem: Plötzliche Lastspitzen
8
Problem: UngleichmäßigeBelastung
9
Don‘t reinvent the wheel!
10
Amazon Web Services
Simple Storage Service - S3
Redundanter Speicherplatz
$0,15 per GB Speicherplatz
$0,10 - $0,20 pro GB Traffic
Virtueller Server pro Stunde
$0,10 pro CPU Stunde
$0,10 - $0,20 pro GB Traffic
Elastic Compute Cloud - EC2
…….
E-Commerce S..
11
S3 - Simple Storage Service
• Beliebig viel redundanter, hochverfügbarer Speicherplatz
• max. 5 GB pro Datei
• Organisiert in „Buckets“
• Upload über Web Service API
• Abruf über
• Web Service
• HTTP / HTTPS
• BitTorrent
12
S3 - Buckets
• Unique über ganz S3
• Enthalten beliebigviele Key-Value-Metadata Tupel
• Enthalten keine Buckets!
• Key kann „/“ enthalten
MyBucket_name
S3
foto_5.jpg
/backups/januar.tgz
/fotos/2007/001.png
www.peritor.com
/site/screen.css
/site/script.js
FreeBSD-6.2.iso
13
S3 mit AWS::S3Upload
Download
14
EC2 - Elastic Compute Cloud
• XEN basiert
• (Beliebig) viele virtuelle Server steuerbar über Web Service
• 1,7 GHz
• 1,75 GB RAM
• 160 GB lokaler Speicherplatz (nicht persistent!)
• Einsatz der Linux Distribution der Wahl (Linux 2.6.16),Verwaltung der Amazon Machine Images (AMI) auf S3
• ACLs regeln Zugriff auf Hosts / Ports
15
EC2 ToolsVerfügbare Images auflisten
Neue Instanz starten
Einloggen per SSH
Instanz beenden
16
Und jetzt?
Wie löse ich meineProbleme damit?
17
S3 - Backup
• s3sync.rb
• Brackup
• Jungle Disk
• S3 FUSE
• s3DAV
• Duplicity
• S3Browser
• Firefox S3 Organizer extension
• …
18
s3sync.rb
Backup
Restore
19
S3 als asset host
20
S3 als asset host
Setup DNS
Setup Rails Konfiguration
21
S3 als asset host
welcome.rhtml Template
Output
22
S3 - User Data Speicher
23
attachment_fu Rails plugin
Setup
24
attachment_fu Rails plugin
Upload
Download
25
On-Demand Computing mit EC2
Zeitgesteuert, z.B. mit cron
26
On-Demand Computing mit EC2
Lastgesteuert, z.B. mit Monit
27
On-Demand Computing mit EC2
28
Load Balancer / Proxy
Am Beispiel mod_proxy_blancer:
• Ansprechen von multiplen Backend-Servern (Mongrel)
• Zentrale Proxy/Load-BalancerKonfiguration mit Wissen über Nodes
• Typischerweise Neustart des Proxy beiVeränderung der Backend-Server
29
Swiftiply
Swiftiply Proxy:
• Multiple Backend-Clients verbindensich persistent zum Backendport
• Proxy nimmt Anfragen überClusterport entgegen und verteilt sieauf verbundene Clients
Keine Re-Konfiguration nötig
30
Swiftiply Proxy
Konfiguration
Start
Installation
31
Swiftiplied Mongrel
• Gem plugin um Mongrel zu patchen
• Wandelt Mongrel in Swiftiply-Client um
• Noch experimentell
Start
oder
32
EC2 on Demand vor Swiftiply
33
EC2 on Demand mit Swiftiply
34
EC2 on Demand mit Swiftiply
35
Ressourcen
• Amazon Web Serviceshttp://aws.amazon.com
• Swiftiplyhttp://swiftiply.swiftcore.org
• Attachment_fuhttp://svn.techno-weenie.net/projects/plugins/attachment_fu/
• Elastic Railshttp://www.elasticrails.com
• Capazonhttp://capazon.rubyforge.org
• RightScalehttp://www.rightscale.com
• WeoCEOhttp://weoceo.weogeo.com/
36
Peritor Wissensmanagement GmbH
Lenbachstraße 212157 Berlin
Internet: www.peritor.comE-Mail: [email protected]
© Peritor Wissensmanagement GmbH - Alle Rechte vorbehalten
Telefon: +49 (0)30 69 40 11 94Telefax: +49 (0)30 69 40 11 95