Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Cloud Computing for Hackers
Search
Giovanni Collazo
October 23, 2012
Programming
3
630
Cloud Computing for Hackers
Presented on workshop at Universidad de Puerto Rico, Rio Piedras.
Giovanni Collazo
October 23, 2012
Tweet
Share
More Decks by Giovanni Collazo
See All by Giovanni Collazo
Mis refranes favoritos
gcollazo
7
790
BarcampVSJ
gcollazo
4
63
The Future
gcollazo
0
150
Blimp - How it's Made
gcollazo
5
300
Naming and branding for hackers
gcollazo
0
230
Receta para conseguir "guisos" mientras se estudia a tiempo completo
gcollazo
4
460
Other Decks in Programming
See All in Programming
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
550
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
480
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
140
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
280
Exploring: Partial and Independent Composables
blackbracken
0
100
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
110
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
Zoneless Testing
rainerhahnekamp
0
120
php-conference-japan-2024
tasuku43
0
330
良いユニットテストを書こう
mototakatsu
8
2.8k
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Designing Experiences People Love
moore
138
23k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Language of Interfaces
destraynor
154
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
The Cult of Friendly URLs
andyhume
78
6.1k
Producing Creativity
orderedlist
PRO
341
39k
Six Lessons from altMBA
skipperchong
27
3.5k
How GitHub (no longer) Works
holman
311
140k
Transcript
Cloud Computing for Hackers
Thanks for showing up
We are going to move fast
I will stop for questions
Giovanni Collazo @gcollazo
None
None
Hacker
“jakel”
“To programmers, ‘hacker’ connotes mastery in the most literal sense:
someone who can make a computer do what he wants—whether the computer wants to or not” - Paul Graham
“It can be either a compliment or an insult. It's
called a hack when you do something in an ugly way. But when you do something so clever that you somehow beat the system, that's also called a hack.” - Paul Graham
None
None
None
None
None
If you are here you are a Hacker
So, what’s cloud computing?
a computer in the sky
a computer over network
a computer somewhere on the internet
elastic
providing service as a utility
the illusion of infinite supply
Why so much attention?
Paradigm shift
None
Everything talks to the network
All computers are over the network
Does it matter if the other side of the cable
is in the same building?
For most apps it doesn’t matter
So, I don’t have to buy and maintain servers?
None
Why Hackers should care?
We can deploy a server in seconds
We can deploy hundreds in minutes
Pay for what you use
New kinds of apps are possible
New toy to play with
How many servers they have?
It’s been reported that AWS has somewhere around 500,000
That’s not enough
They are enough because the are virtualized
What’s this virtualization thing?
Hardware virtualization or platform virtualization refers to the creation of
a virtual machine that acts like a real computer with an operating system - Wikipedia
One physical machine can run multiple virtual machines
They share the resources of the physical machine
XEN
XEN x86, x86_64, IA64, ARM
XEN Windows, Linux, Solaris, BSD
They look like “real” machines over the network
They are cheap to run
None
This is specially cool for scaling web apps
Modern web apps are designed to scale horizontally
That means that to support more traffic you just add
more “cheap” machines
...instead of using really big, powerful and “expensive” machines
What does the architecture of a web app looks like?
App Server HTTP Request HTTP Response DB
App Server HTTP Request HTTP Response DB Cache
App Server HTTP Request HTTP Response Cache DB Reads &
Writes
App Server HTTP Request HTTP Response Cache DB Reads &
Writes App Server Load Balancer
Load Balancer App Server App Server App Server App Server
DB Read Slave DB Read Slave Cache Reads DB Master Writes Replication HTTP Request HTTP Response
Load Balancer App Server App Server App Server App Server
Cache DB01 HTTP Request HTTP Response DB02 DB03 Shard01 Shard10 Shard11 Shard20 Shard21 Shard30 Reads & Writes Reads & Writes
what if AWS goes down?
AWS America East Rackspace OpenCloud DNS
18 million visitors per month 3 million + users 410TB
of data
12 Employees
30 million users 150 million photos
3 engineers
Sold for $1 billion to Facebook
OK. Got it! How do I use the cloud?
There are many approaches to “the cloud” but we are
going to talk about 2
The ones I think you’ll care about
None
you rent an instance
you manage your OS
upgrade packages
take care of security
... and availability
it’s the closest to renting a physical server on a
data center
maximum control
management over web console or api
None
They provide a container for your app
Easy deployment
git push heroku master
They take care of OS level issues
Super easy scaling
They enforce good app design
Less control over the environment
They run on top of AWS
What should I use?
Well, it depends
Understand the AWS model
Start with Heroku
Move to AWS when it’s absolutely necessary
None
Hands-on
None
Login to the AWS console
Create a Linux instance
Install Apache and PHP
Create a simple PHP script
Warning
Let’s do it
https://blimp.signin.aws.amazon.com/console
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
chmod 600 keyfile.pem
ssh -i keyname.pem ubuntu@hostname
sudo aptitude install apache2
sudo aptitude install php5 libapache2-mod-php5
cd /var/www/
sudo mv index.html index.php
sudo vim index.php
<?php echo 'AppServer: ' . gethostname(); ?>
Now what?
Live demo
Creating an image from a running instance
Launch an instance from an image
Creating an ELB
Me gusta
ProTips™
Free Tier
Micro instances are throttled down after a few minutes of
heavy use
Using the biggest available instance size gets you a “full”
machine
Chaos Monkey
Homework: Try to learn some Python
That’s it for today... Questions
Day 2
Cloud Computing for Hackers
None
Load Balancer Web Dyno Web Dyno Worker Dyno Cron Dyno
HTTP Request HTTP Response
Load Balancer Web Dyno Web Dyno Worker Dyno Cron Dyno
HTTP Request HTTP Response Ruby, Python, Scala, Java, Javascript, PHP
They do SysOps
You make web apps
Let’s try it
Setup a Python dev environment
Create a virtualenv for our first project
Create the simplest web app ever made
Deploy to Heroku
Make changes to the app
Deploy again
Start * tested on Mac OSX
mkdir ~/.virtualenvs
sudo easy_install pip
sudo pip install virtualenvwrapper
vim ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh .bash_profile
source ~/.bash_profile
cd ~/Desktop mkdir myapp cd myapp
mkvirtualenv myapp
pip install flask pip freeze > requirements.txt
app.py import os from flask import Flask app = Flask(__name__)
app.debug = True @app.route("/") def hello(): return 'Hello: {}'.format(os.uname()[1]) if __name__ == "__main__": port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port)
python app.py open http://localhost:5000
vim Procfile
web: python app.py Procfile
git init git add . git commit -m ‘Initial Commit’
Install the Heroku Toolbelt https://toolbelt.heroku.com
Sign up to Heroku https://api.heroku.com/signup
heroku login
heroku create
git push heroku master
heroku open
import os from flask import Flask app = Flask(__name__) app.debug
= True @app.route("/") def hello(): return 'Bye: {}'.format(os.uname()[1]) if __name__ == "__main__": port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port) app.py
git commit -am ‘Small copy change’
git push heroku master
heroku open
Something more exiting, please * tested on Mac OSX
Let’s use Redis
brew install redis * Mac OSX only
pip install redis
pip freeze > requirements.txt
import os import redis redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379/0') redis =
redis.from_url(redis_url) store.py
mkdir templates vim templates/index.html
<!doctype html> <html> <head> <meta charset="utf-8"> <title>The List</title> </head> <body>
<ul> {% for item in the_list %} <li>{{ item }}</li> {% endfor%} </ul> </body> </html> index.html
import os import time from flask import Flask from flask
import render_template from store import redis app = Flask(__name__) app.debug = True @app.route("/") def hello(): redis.rpush('thelist', 'Hello: {} - {}'.format(os.uname()[1], time.time())) the_list = redis.lrange('thelist', 0, -1) return render_template('index.html', the_list=the_list) if __name__ == "__main__": port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port) app.py
git add . git commit -am ‘Added redis’
heroku addons:add redistogo:nano
git push heroku master heroku open
How can I manage the app?
heroku ps
heroku logs
heroku config
ProTips™
heroku logs --tail
heroku run bash
heroku maintenance:on heroku maintenance:off
Prevent app from sleeping http://pingdom.com
Use foreman locally to run multiple app processes
web: python app.py redis: redis-server Procfile.local
foreman start -f Profile.local
Q&A
Giovanni Collazo @gcollazo