Download presentation
Presentation is loading. Please wait.
Published byVictor Byrd Modified over 9 years ago
1
Google Application Engine Introduction Jim Eng with thanks to Charles Severance http://www.appenginelearn.comhttp://www.appenginelearn.com/ http://www.dr-chuck.com/
2
Cloud Computing http://en.wikipedia.org/wiki/Cloud_computing
3
Local Network Pre-Cloud View The Internet... Router
4
Hardware Software ctools.umich.edu In a pre-cloud view servers have a geographic location and we use the Internet to exchange data with those servers.
5
World-Scale Applications For world-scale applications - the servers must be distributed around the world But users must see a uniform “single image” - www.google.com Also the programmers cannot know the structure or grography of the servers - because this always changes
6
Google Server Locations http://royal.pingdom.com/2008/04/11/map-of-all-google-data-center-locations/ This is an educated guess.
7
Programming in the Cloud Programmers operate in a controlled environment Programs do their programming thing - code + data A complex software framework manages getting the right code and data to/from the right servers. Software developers are unaware of geography
8
The geographic location no longer matters - the software “runs somewhere in the cloud”. Resources can be dynamically adjusted as load changes.
9
Local Network Pre-Cloud View The Internet... Router Software Server Busy?
10
Post-Cloud View The Cloud... My Code Your Code My User Your User
11
HTTP - Request / Response The nature of the HTTP Request/Response cycle makes the cloud possible Since clients are not connected for very long - the cloud can be changed in between requests As long as the cloud “fakes” everything about the protocol - no one is the wiser.. The cloud engineers at Google/Amazon/Yahoo are pretty clever.
12
HTTP Request / Response Cycle http://www.oreilly.com/openbook/cgi/ch04_02.html Browser Web Server HTTP Request HTTP Response Internet Explorer, FireFox, Safari, etc.
13
HTTP Request / Response Cycle http://www.oreilly.com/openbook/cgi/ch04_02.html Browser Web Server HTTP Request HTTP Response Internet Explorer, FireFox, Safari, etc. GET /index.html.. Welcome to my application....
14
Post-Cloud View The Cloud My Code Your Code My User
15
Post-Cloud View The Cloud My Code Your Code My User GET
16
Cloud Summary The cloud is the Internet plus computing that is “embedded” “inside” the network Companies like Google, Amazon, and Yahoo put servers all over the world Software runs on whichever server is most appropriate and data/code is moved around and the cloud can be reconfigured dynamically
17
Materials Google Application Engine Free hosted web services using Python http://code.google.com/appengine/ We will be using web materials and making materials as we go.
18
Overview Video Builds a Google App Engine application in 10 minutes Basic structure - GET / POST Form Input Templating Database http://www.youtube.com/watch?v=tcbpTQXNwac
19
Google App Engine
20
Expose Google’s worldwide Infrastructure to us as developers http://www.youtube.com/watch?v=3Ztr-HhWX1c http://www.youtube.com/watch?v=tcbpTQXNwac
21
Google App Engine When you write a Google Application Engine Application - you are running in the Google Cloud Just like you were a Google Developer You don’t know where you are running or if one copy of a thousand copies of you are running Google hosts small applications for *free* - larger applications pay by usage
22
Free Accounts A free account can use up to 500MB of persistent storage and enough CPU and bandwidth for about 5 million page views a month.
23
Installing Google App Engine
24
http://code.google.com/appengine/downloads.html
25
Your First Web Application
26
app.yaml - Tells Google about the application index.py - the code for our application
28
File -> Add Existing Application Pick Your Directory /Users/csev/a539/apps/ae-01-trivial
29
Select your new application and press “Run”. When it has a little green symbol - then press “Browse”.
30
Yay!
31
Remember to ignore files with tildes (~) or JEdit -> Utilities -> Global Options -> Autosave & Backup and set the number of backups to zero
33
A Second Application Dumping Input data
34
Dumper This application makes a form and then we submit the form via POST This application dumps the input variables that come in from the HTTP Request This is the most basic view of a web application It is like a Dinosaur - it is a web program written using the “old ways”
35
Common Gateway Interface A set of rules about taking input parameters and data from an incoming HTTP request and handing them to the program.
36
HTTP Request / Response Cycle http://www.oreilly.com/openbook/cgi/ch04_02.html Browser Web Server HTTP Request HTTP Response
37
HTTP Request / Response Cycle GET /index.html Accept: www/source Accept: text/html User-Agent: Lynx/2.4 libwww/2.14 http://www.oreilly.com/openbook/cgi/ch04_02.html Browser Web Server HTTP Request HTTP Response.. Welcome to my application....
38
Passing Parameters to The Server GET /simpleform.html?yourname=fred Accept: www/source Accept: text/html User-Agent: Lynx/2.4 libwww/2.14 POST /cgi-bin/program.pl HTTP/1.0 Accept: www/source Accept: text/html User-Agent: Lynx/2.4 libwww/2.14 Content-type: application/x-www-form- urlencoded Content-length: 13 yourname=fred HTTP Request Browser Web Server
39
http://hoohoo.ncsa.uiuc.edu/cgi/in.html
40
CGI In App Engine When a Request is received in the App Engine, according to the rules of CGI The environment variables such as server name, document path, etc come in a dictionary object Any POST data comes in on standard input (sys.stdin) Whatever the program prints goes to the browser as the HTTP response
41
Zap Data: Zot Data: Environment Data POST Data zap=Stuff&zot=MoreStuff dict() stdin print CGI Program Browser
42
import os import sys print 'Content-Type: text/html' print ' ' print 'Zap Data: ' print 'Zot Data: ' print ' ' print ‘ ’ The standard output (print statements) produce the HTTP Response. The output consists of HTTP headers followed by the body of the document.
43
print 'Environment keys:' print ' ' for param in os.environ.keys(): print param, ":", os.environ[param] print ' '
44
print 'Data' count = 0 for line in sys.stdin: count = count + 1 print line if count > 100: break print ‘ ’
45
Up Next... If we wanted to write a real web application - we would write a lot of string parsing code that looked at the environment variables and standard input We would spend a lot of time reading the HTTP documents to figure out the exact format of these strings This has already been done for us - this is provided as a framework on App Engine
46
http://code.google.com/appengine/docs/gettingstarted/usingwebapp.html
47
Summary We introduced Cloud Computing - servers move “into” the network cloud Google App Engine allows us to use the Google Cloud Common Gateway Interface - The ancient ways Writing simple low-level Python programs in AppEngine Using the AppEngine web framework (up next)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.