SlideShare a Scribd company logo
Designing the Call of Cthulhu app with Google App Engine Presented by Chris Bunch at UCSB CS 189A / 172 : Capstone Project / Software Engineering February 10, 2010 http://cs.ucsb.edu/~cgb
Motivation I am what you would call a “nerd” Plays nerdy board games Would like to upload stats from games and analyze them Could do other cool things as well
Specifically
Arkham Horror Lots of variables that can be analyzed Co-op game: all v. the board Mix and match expansions Many different winning / losing conditions But fundamentally boils down to: Save the world from total destruction
App Requirements Must be able to upload game data Should be able to predict a win or loss given some preliminary info Can experiment with prediction algorithms Should be able to summarize game data
App Requirements Allows users to log in to upload their data Allows users to share data with each other Handles users in a sane fashion Harder than it sounds Display a top score list for users to view Game provides scoring metric
Enter the Cloud Why go the cloud route? Simple answer: You likely don’t have your own hardware to host this app on, so just use somebody else’s But cloud computing is confusing and not well defined yet, so...
Defining Cloud Computing Three layers, each building on the last Infrastructure: Programmer gets a virtual machine and / or reliable storage Most control of environment Must scale manually Amazon EC2, Eucalyptus
Defining Cloud Computing Three layers, each building on the last Platform: Programmer gets a scalable API Less control of environment Scaling done automatically Google App Engine, Microsoft Azure
Defining Cloud Computing Three layers, each building on the last Software: Programmer gets to “skin” an existing app No control of environment Scaling done automatically SalesForce, GMail
My Choice Clearly I want the platform! Platform: Scalable API = great! Less control of environment = ok Programability depends on APIs offered  Have personal exp. w/ Google App Engine
What is Google App Engine? Scalable web framework first offered in 2008 Users program apps in: Python Java Unofficially: JRuby, Groovy, JavaScript
Sandboxed Environment Requests limited to 30 seconds Only white-listed libraries can be used Anything non-trivial is quota-ed No reading / writing to the filesystem Web communication over HTTP(S) only
Datastore API A giant hash table Primitives: Get, put, delete - same as regular HT Query, count - new operations Transactions supported (row-level only)
Datastore API GQL queries offered - subset of SQL Select statement, no JOINs Tip: Queries are the most expensive operation, use sparingly If possible, perform it asynchronously
Memcache API Equivalent to memcached Provides access to low latency LRU cache Roughly 100x faster than Datastore But unreliable - remember it’s a cache! Exposes get, set, delete operations Exposes atomic increment / decrement
URL Fetch API Equivalent to curl Used to grab web content from other sites Only allows for HTTP(S) data to be read Can also be done asynchronously Typically grabs images or mashup data
Mail API Equivalent to sendmail Can send or receive mail asynchronously Can also add attachments Not all types allowed - no .doc, .xls, or .ppt in Python SDK
XMPP API Equivalent to jabber Send and receive instant messages to appname.appspotchat.com App can’t join group chat yet Use as a notifier or alternate UI to app
Images API Equivalent to python-imaging Exposes image rotation, flipping, cropping, and histogram Image is stored internally as a blob, then retrieved and manipulated
Users API Equivalent to Google Accounts Provides for simple authentication Allows app to force login or admin on certain pages Also exposes URL to optionally login to
Blobstore API Allows for large file uploads (<50 MB) Users can upload videos, datasets, or large music files for later retrieval Upload must be done via form post
Cron API Equivalent to cron User specifies how often a web page should be accessed (e.g., daily, every Monday) Task is then run in the background Useful for running expensive data analysis
Task Queue API Spawns a new thread in the background But still must visit your app Configuration file specifies queues Useful for short to medium length tasks
To summarize: Many, many APIs available for what we need to do! Use Datastore to store / retrieve user data Use Users to authenticate users Gets around a lot of boilerplate authentication code
To summarize: Use Mail to e-mail users if their score is beat Use XMPP to allow users to add new data Use Cron to run compute-intensive code in the background
To summarize: Think about paid functionality: Maybe use Blobstore to allow users to upload videos explaining gameplay Handle greater traffic if site becomes popular
Let’s Get to Business Data Modeling Upload Stats Page Game Stats Page Game Prediction Page
Data Modeling class Game(db.Model): player = db.UserProperty() goo = db.StringProperty() comments = dbStringProperty(multiline=True) date = db.DateTimeProperty(auto_now_add=True)
Data Modeling num_of_players = db.IntegerProperty() won_game = db.BooleanProperty() doom_counters = db.IntegerProperty() terror_level = db.IntegerProperty() expansions_used = dbListProperty(str)
Uploading Stats class AddGames(webapp.RequestHandler): def get(self): user = users.get_current_user() if user: # means they’re logged in # write html form for getting data else: self.redirect(users.create_login_url(self.request.uri))
Uploading Stats def post(self): new_goo = self.request.get(‘goo’) # validate goo, make sure data type is right game = Game() game.goo = new_goo game.put()
Game Stats games = db.GqlQuery (“SELECT * FROM Game ORDER BY date desc”) for game in games: # find the goo w/ highest player win percentage # can also just display the info here
Game Prediction def get(self): # user specifies the game they will play def post(self): # calculate how likely they are to win # right now we only care about the goo
Routing application = webapp.WSGIApplication([ (‘/upload’, AddGames), (‘/stats’, GameStats), (‘/predict’, PredictGame)])
Thankfully Most requirements have very little state shared between URLs (all saved in DB) Thus each class is one of two forms: get / post: Grab data from user and do something with it get: Just display or synthesize some data
Rendering Web Pages Two main options available: self.response.out.write(“Hello World!”) self.response.out.write(template.render(‘index.html’, {‘my_title: ‘baz’, ‘data’: some_variable})) Use the second for any non-trivial app
Rendering Web Pages Now in your index.html: <title> {{ my_title }} </title> <div> {{ data }} </div>
Tips for Your Programs Separate out your code into files as needed app.yaml specifies this: handlers: - url: /one script: one.py - url: /two/(.*)/(.*) script: /two/\2/\1.py
Tips for Your Programs Make pages with sensitive data ‘secure’ All access done over HTTPS Optional - HTTP and HTTPS work Never - HTTPS redirects to HTTP Always - HTTP redirects to HTTPS
Tips for Your Programs Specify static files in app.yaml - url: /images static_dir: static/images Can also tag ‘secure’ if desired
Tips for Your Programs Be creative! The webapp framework supports: get, post, head, options, put, delete, trace Map user pages to ~name?
Summary Google App Engine is more than flexible enough to handle your web app desires And it’s only getting better! More than enough possibilities to create a web app: you just need a good idea!
 

More Related Content

PDF
Appscale at CLOUDCOMP '09
PDF
Ph.D. Defense
PDF
AppScale Talk at SBonRails
PDF
AppScale @ LA.rb
PDF
Neptune @ SoCal
PDF
AppScale + Neptune @ HPCDB
PDF
Active Cloud DB at CloudComp '10
PDF
A Pluggable Autoscaling System @ UCC
Appscale at CLOUDCOMP '09
Ph.D. Defense
AppScale Talk at SBonRails
AppScale @ LA.rb
Neptune @ SoCal
AppScale + Neptune @ HPCDB
Active Cloud DB at CloudComp '10
A Pluggable Autoscaling System @ UCC

What's hot (14)

PPTX
Tech Talk on Autoscaling in Apache Stratos
PDF
StreamSQL Feature Store (Apache Pulsar Summit)
PPTX
Chatbots with Serverless
PDF
Serverless Summit - Quiz
PPT
DevOpsCon Cloud Workshop
PDF
AWS Lambda from the Trenches
PPTX
Sas 2015 event_driven
PDF
Heterogeneous Workflows With Spark At Netflix
PDF
Serverless Architectures on AWS Lambda
PPT
Docker in the Cloud
PPTX
eCAP Developer Walkthru
PDF
Journey towards serverless infrastructure
PPTX
Introducing Kubernetes
PPTX
Auto Retweets Using AWS Lambda
Tech Talk on Autoscaling in Apache Stratos
StreamSQL Feature Store (Apache Pulsar Summit)
Chatbots with Serverless
Serverless Summit - Quiz
DevOpsCon Cloud Workshop
AWS Lambda from the Trenches
Sas 2015 event_driven
Heterogeneous Workflows With Spark At Netflix
Serverless Architectures on AWS Lambda
Docker in the Cloud
eCAP Developer Walkthru
Journey towards serverless infrastructure
Introducing Kubernetes
Auto Retweets Using AWS Lambda
Ad

Viewers also liked (15)

PPTX
Automating Application over OpenStack using Workflows
PDF
Task flow
PDF
Mistral OpenStack Meetup Feb 5
PPT
OpenStack Atlanta Summit - Build an OpenStack Cluster Before Lunch, Scale Glo...
PDF
OpenStack networking
PDF
Open stack networking vlan, gre
PDF
Introduction openstack horizon
PPTX
OpenStack Horizon: Controlling the Cloud using Django
PDF
Openstack Neutron and SDN
PDF
NFV for beginners
PPTX
Openstack Basic with Neutron
ODP
Deploying & Scaling OpenShift on OpenStack using Heat - OpenStack Seattle Mee...
PDF
OpenStack Neutron Tutorial
PPTX
Introduction to OpenFlow, SDN and NFV
PDF
Introduction to Software Defined Networking (SDN)
Automating Application over OpenStack using Workflows
Task flow
Mistral OpenStack Meetup Feb 5
OpenStack Atlanta Summit - Build an OpenStack Cluster Before Lunch, Scale Glo...
OpenStack networking
Open stack networking vlan, gre
Introduction openstack horizon
OpenStack Horizon: Controlling the Cloud using Django
Openstack Neutron and SDN
NFV for beginners
Openstack Basic with Neutron
Deploying & Scaling OpenShift on OpenStack using Heat - OpenStack Seattle Mee...
OpenStack Neutron Tutorial
Introduction to OpenFlow, SDN and NFV
Introduction to Software Defined Networking (SDN)
Ad

Similar to Designing the Call of Cthulhu app with Google App Engine (20)

PPTX
Googleappengineintro 110410190620-phpapp01
PDF
Having Fun Building Web Applications (Day 1 Slides)
PPTX
Introduction to Google App Engine with Python
PPT
Google App Engine for Java
PDF
App engine devfest_mexico_10
PPT
Google cloud platform
PDF
The Big Picture and How to Get Started
PPT
Play framework
PDF
Serverless ML Workshop with Hopsworks at PyData Seattle
PDF
Google App Engine: An Introduction
PPTX
AngularJS with TypeScript and Windows Azure Mobile Services
PPT
Porting and Maintaining your C++ Game on Android without losing your mind
PDF
Google App Engine for Java v0.0.2
PDF
Having Fun Building Web Applications (Day 2 slides)
PDF
Download full Distributed and Cloud Computing 1st Edition Hwang Solutions Man...
PPTX
Google Cloud Platform
PPTX
What's new in android jakarta gdg (2015-08-26)
PPT
Google Gears
PPT
Developing Java Web Applications In Google App Engine
PDF
Distributed and Cloud Computing 1st Edition Hwang Solutions Manual
Googleappengineintro 110410190620-phpapp01
Having Fun Building Web Applications (Day 1 Slides)
Introduction to Google App Engine with Python
Google App Engine for Java
App engine devfest_mexico_10
Google cloud platform
The Big Picture and How to Get Started
Play framework
Serverless ML Workshop with Hopsworks at PyData Seattle
Google App Engine: An Introduction
AngularJS with TypeScript and Windows Azure Mobile Services
Porting and Maintaining your C++ Game on Android without losing your mind
Google App Engine for Java v0.0.2
Having Fun Building Web Applications (Day 2 slides)
Download full Distributed and Cloud Computing 1st Edition Hwang Solutions Man...
Google Cloud Platform
What's new in android jakarta gdg (2015-08-26)
Google Gears
Developing Java Web Applications In Google App Engine
Distributed and Cloud Computing 1st Edition Hwang Solutions Manual

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Cloud computing and distributed systems.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Cloud computing and distributed systems.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity
Understanding_Digital_Forensics_Presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Advanced methodologies resolving dimensionality complications for autism neur...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Chapter 3 Spatial Domain Image Processing.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Designing the Call of Cthulhu app with Google App Engine

  • 1. Designing the Call of Cthulhu app with Google App Engine Presented by Chris Bunch at UCSB CS 189A / 172 : Capstone Project / Software Engineering February 10, 2010 http://cs.ucsb.edu/~cgb
  • 2. Motivation I am what you would call a “nerd” Plays nerdy board games Would like to upload stats from games and analyze them Could do other cool things as well
  • 4. Arkham Horror Lots of variables that can be analyzed Co-op game: all v. the board Mix and match expansions Many different winning / losing conditions But fundamentally boils down to: Save the world from total destruction
  • 5. App Requirements Must be able to upload game data Should be able to predict a win or loss given some preliminary info Can experiment with prediction algorithms Should be able to summarize game data
  • 6. App Requirements Allows users to log in to upload their data Allows users to share data with each other Handles users in a sane fashion Harder than it sounds Display a top score list for users to view Game provides scoring metric
  • 7. Enter the Cloud Why go the cloud route? Simple answer: You likely don’t have your own hardware to host this app on, so just use somebody else’s But cloud computing is confusing and not well defined yet, so...
  • 8. Defining Cloud Computing Three layers, each building on the last Infrastructure: Programmer gets a virtual machine and / or reliable storage Most control of environment Must scale manually Amazon EC2, Eucalyptus
  • 9. Defining Cloud Computing Three layers, each building on the last Platform: Programmer gets a scalable API Less control of environment Scaling done automatically Google App Engine, Microsoft Azure
  • 10. Defining Cloud Computing Three layers, each building on the last Software: Programmer gets to “skin” an existing app No control of environment Scaling done automatically SalesForce, GMail
  • 11. My Choice Clearly I want the platform! Platform: Scalable API = great! Less control of environment = ok Programability depends on APIs offered Have personal exp. w/ Google App Engine
  • 12. What is Google App Engine? Scalable web framework first offered in 2008 Users program apps in: Python Java Unofficially: JRuby, Groovy, JavaScript
  • 13. Sandboxed Environment Requests limited to 30 seconds Only white-listed libraries can be used Anything non-trivial is quota-ed No reading / writing to the filesystem Web communication over HTTP(S) only
  • 14. Datastore API A giant hash table Primitives: Get, put, delete - same as regular HT Query, count - new operations Transactions supported (row-level only)
  • 15. Datastore API GQL queries offered - subset of SQL Select statement, no JOINs Tip: Queries are the most expensive operation, use sparingly If possible, perform it asynchronously
  • 16. Memcache API Equivalent to memcached Provides access to low latency LRU cache Roughly 100x faster than Datastore But unreliable - remember it’s a cache! Exposes get, set, delete operations Exposes atomic increment / decrement
  • 17. URL Fetch API Equivalent to curl Used to grab web content from other sites Only allows for HTTP(S) data to be read Can also be done asynchronously Typically grabs images or mashup data
  • 18. Mail API Equivalent to sendmail Can send or receive mail asynchronously Can also add attachments Not all types allowed - no .doc, .xls, or .ppt in Python SDK
  • 19. XMPP API Equivalent to jabber Send and receive instant messages to appname.appspotchat.com App can’t join group chat yet Use as a notifier or alternate UI to app
  • 20. Images API Equivalent to python-imaging Exposes image rotation, flipping, cropping, and histogram Image is stored internally as a blob, then retrieved and manipulated
  • 21. Users API Equivalent to Google Accounts Provides for simple authentication Allows app to force login or admin on certain pages Also exposes URL to optionally login to
  • 22. Blobstore API Allows for large file uploads (<50 MB) Users can upload videos, datasets, or large music files for later retrieval Upload must be done via form post
  • 23. Cron API Equivalent to cron User specifies how often a web page should be accessed (e.g., daily, every Monday) Task is then run in the background Useful for running expensive data analysis
  • 24. Task Queue API Spawns a new thread in the background But still must visit your app Configuration file specifies queues Useful for short to medium length tasks
  • 25. To summarize: Many, many APIs available for what we need to do! Use Datastore to store / retrieve user data Use Users to authenticate users Gets around a lot of boilerplate authentication code
  • 26. To summarize: Use Mail to e-mail users if their score is beat Use XMPP to allow users to add new data Use Cron to run compute-intensive code in the background
  • 27. To summarize: Think about paid functionality: Maybe use Blobstore to allow users to upload videos explaining gameplay Handle greater traffic if site becomes popular
  • 28. Let’s Get to Business Data Modeling Upload Stats Page Game Stats Page Game Prediction Page
  • 29. Data Modeling class Game(db.Model): player = db.UserProperty() goo = db.StringProperty() comments = dbStringProperty(multiline=True) date = db.DateTimeProperty(auto_now_add=True)
  • 30. Data Modeling num_of_players = db.IntegerProperty() won_game = db.BooleanProperty() doom_counters = db.IntegerProperty() terror_level = db.IntegerProperty() expansions_used = dbListProperty(str)
  • 31. Uploading Stats class AddGames(webapp.RequestHandler): def get(self): user = users.get_current_user() if user: # means they’re logged in # write html form for getting data else: self.redirect(users.create_login_url(self.request.uri))
  • 32. Uploading Stats def post(self): new_goo = self.request.get(‘goo’) # validate goo, make sure data type is right game = Game() game.goo = new_goo game.put()
  • 33. Game Stats games = db.GqlQuery (“SELECT * FROM Game ORDER BY date desc”) for game in games: # find the goo w/ highest player win percentage # can also just display the info here
  • 34. Game Prediction def get(self): # user specifies the game they will play def post(self): # calculate how likely they are to win # right now we only care about the goo
  • 35. Routing application = webapp.WSGIApplication([ (‘/upload’, AddGames), (‘/stats’, GameStats), (‘/predict’, PredictGame)])
  • 36. Thankfully Most requirements have very little state shared between URLs (all saved in DB) Thus each class is one of two forms: get / post: Grab data from user and do something with it get: Just display or synthesize some data
  • 37. Rendering Web Pages Two main options available: self.response.out.write(“Hello World!”) self.response.out.write(template.render(‘index.html’, {‘my_title: ‘baz’, ‘data’: some_variable})) Use the second for any non-trivial app
  • 38. Rendering Web Pages Now in your index.html: <title> {{ my_title }} </title> <div> {{ data }} </div>
  • 39. Tips for Your Programs Separate out your code into files as needed app.yaml specifies this: handlers: - url: /one script: one.py - url: /two/(.*)/(.*) script: /two/\2/\1.py
  • 40. Tips for Your Programs Make pages with sensitive data ‘secure’ All access done over HTTPS Optional - HTTP and HTTPS work Never - HTTPS redirects to HTTP Always - HTTP redirects to HTTPS
  • 41. Tips for Your Programs Specify static files in app.yaml - url: /images static_dir: static/images Can also tag ‘secure’ if desired
  • 42. Tips for Your Programs Be creative! The webapp framework supports: get, post, head, options, put, delete, trace Map user pages to ~name?
  • 43. Summary Google App Engine is more than flexible enough to handle your web app desires And it’s only getting better! More than enough possibilities to create a web app: you just need a good idea!
  • 44.