SlideShare a Scribd company logo
1 of 24
Download to read offline
Iā€™ve (probably) been using

Google App Engine
     for a week longer than you have

Simon Willison - http://simonwillison.net/
BarCamp London 4
31st May 2008
Except you have to re-write
     your whole application
If you totally rethink the
 way you use a database
What it can do
ā€¢ Serve static ļ¬les
ā€¢ Serve dynamic requests
ā€¢ Store data
ā€¢ Call web services (sort of)
ā€¢ Authenticate against Googleā€™s user database
ā€¢ Send e-mail, process images, use memcache
The dev environment
                    is really, really nice


ā€¢   Download the (open source) SDK

    ā€¢   a full simulation of the App Engine environment

ā€¢   dev_appserver.py myapp     for a local webserver

ā€¢   appcfg.py update myapp     to deploy to the cloud
Options
ā€¢ You have to use Python
ā€¢ You can choose how you use it:
 ā€¢ CGI-style scripts
 ā€¢ WSGI applications
 ā€¢ Googleā€™s webapp framework
 ā€¢ Django (0.96 provided, or install your own)
Hello World
# helloworld.py
print quot;Content-Type: text/htmlquot;
print
print quot;Hello, world!quot;

# app.yaml
application: simonwillison-helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py
With webapp and WSGI
import wsgiref.handlers
from google.appengine.ext import webapp

class MainPage(webapp.RequestHandler):
Ā  def get(self):
Ā  Ā  self.response.headers['Content-Type'] = 'text/html'
Ā  Ā  self.response.out.write('Hello, webapp World!')

def main():
Ā  application = webapp.WSGIApplication(
    [('/', MainPage)], debug=True)
Ā  wsgiref.handlers.CGIHandler().run(application)

if __name__ == quot;__main__quot;:
Ā  main()
With Django
from django.conf.urls.defaults import *
from django.http import HttpResponse

def hello(request):
    return HttpResponse(quot;Hello, World!quot;)

urlpatterns = patterns('',
    ('^$', hello),
)

(And django_dispatch.py for boilerplate)
ā€¢   Don't use CGI: it requires reloading for every hit

ā€¢   Why use Django over webapp?

    ā€¢   Django has easy cookies and custom 500 errors

    ā€¢   Django is less verbose

    ā€¢   Django middleware is really handy

ā€¢   You can use other WSGI frameworks if you like
Static ļ¬les
# in app.yaml

handlers:
- url: /css
  static_dir: css
- url: /img
  static_dir: img
- url: /favicon.ico
  static_files: img/favicon.ico
  upload: img/favicon.ico
  mime_type: image/x-icon
The Datastore API
ā€œBigtable is a distributed storage system for
 managing structured data that is designed
  to scale to a very large size: petabytes of
    data across thousands of commodity
servers. Many projects at Google store data
 in Bigtable, including web indexing, Google
         Earth, and Google Finance.ā€
The App Engine datastore
ā€¢ Apparently based on BigTable
ā€¢ Absolutely not a relational database
 ā€¢ No joins (they do have ā€œreference ļ¬eldsā€)
 ā€¢ No aggregate queries - not even count()!
 ā€¢ Hierarchy affects sharding and transactions
ā€¢ All queries must run against an existing index
Models and entities
ā€¢ Data is stored as entities
 ā€¢ Entities have properties - key/value pairs
 ā€¢ An entity has a unique key
ā€¢ Entities live in a hierarchy, and siblings exist in
  the same entity group - these are actually really
  important for transactions and performance
ā€¢ A model is kind of like a class; it lets you deļ¬ne
  a type of entity
AppEngine Models
   from google.appengine.ext import db

   class Account(db.Model):
     slug = db.StringProperty(required=True)
     owner = db.UserProperty()
     onlyme = db.BooleanProperty()
     referrers = db.StringListProperty()

(There is a ReferenceProperty, but I havenā€™t used it yet)
Inserting data
account = Account(
    key_name = slug,
    slug = slug,
    referrers = ['...', '...'],
    onlyme = False,
    owner = users.get_current_user()
)
db.put(account) # Or account.put()

Browser.get_or_insert(key_name,
    parent = account,
    slug = browser_slug
)
Running queries

Browser.all().ancestor(account)

Account.gql(quot;WHERE slug = :1quot;, slug))

Story.all().filter(
  'title =', 'Foo'
).order('-date')
BUT...
ā€¢   All queries must run against an existing index

ā€¢   Filtering or sorting on a property requires that
    the property exists

ā€¢   Inequality ļ¬lters are allowed on one property only

ā€¢   Properties in inequality ļ¬lters must be sorted
    before other sort orders

ā€¢   ... and various other rules

ā€¢   Thankfully the dev server creates most indexes
    for you automatically based on usage
How indexes are used
1. The datastore identiļ¬es the index that
  corresponds with the queryā€™s kind, ļ¬lter
  properties, ļ¬lter operators, and sort orders.
2. The datastore starts scanning the index at the
  ļ¬rst entity that meets all of the ļ¬lter conditions
  using the queryā€™s ļ¬lter values.
3. The datastore continues to scan the index,
  returning each entity, until it ļ¬nds the next entity
  that does not meet the ļ¬lter conditions, or until
  it reaches the end of the index.
Further limitations
ā€¢ If you create a new index and push it live,
  you have to wait for it to rebuilt
  ā€¢ This can take hours, and apparently can go
    wrong
ā€¢ You canā€™t safely grab more than about 500
  records at once - App Engine times out
ā€¢ You canā€™t delete in bulk
Other random notes
ā€¢   You have to use the URL Fetch API to do
    HTTP requests (e.g. for web services) - and it
    times out agressively at about 5 seconds
ā€¢   The Google accounts Users API is ridiculously
    easy to use, but...
    ā€¢   no permanent unique identiļ¬er; if the user
        changes their e-mail address youā€™re screwed
ā€¢   The new image and memcache APIs are neat
Final thoughts
ā€¢ Itā€™s really nice not to have to worry about hosting
ā€¢ But... the lack of aggregate queries and ad-hoc
  queries really hurts
ā€¢ Perfect for small projects you donā€™t want to
  worry about and big things which youā€™re sure will
  have to scale
ā€¢ Pricing is comparable to S3 - i.e. stupidly cheap
Pricing

ā€¢ $0.10 - $0.12 per CPU core-hour
ā€¢ $0.15 - $0.18 per GB-month of storage
ā€¢ $0.11 - $0.13 per GB outgoing bandwidth
ā€¢ $0.09 - $0.11 per GB incoming bandwidth
Thank you!

More Related Content

What's hot

Google App Engine
Google App EngineGoogle App Engine
Google App EngineSanguine_Eva
Ā 
Google App Engine
Google App EngineGoogle App Engine
Google App EngineSameer Satyam
Ā 
Platform as a service google app engine
Platform as a service   google app enginePlatform as a service   google app engine
Platform as a service google app engineDeepu S Nath
Ā 
Google App Engine: An Introduction
Google App Engine: An IntroductionGoogle App Engine: An Introduction
Google App Engine: An IntroductionAbu Ashraf Masnun
Ā 
Developing Java Web Applications In Google App Engine
Developing Java Web Applications In Google App EngineDeveloping Java Web Applications In Google App Engine
Developing Java Web Applications In Google App EngineTahir Akram
Ā 
Gentle App Engine Intro
Gentle App Engine IntroGentle App Engine Intro
Gentle App Engine Introrobinb123
Ā 
What is Google App Engine?
What is Google App Engine?What is Google App Engine?
What is Google App Engine?weschwee
Ā 
Google Application Engine
Google Application EngineGoogle Application Engine
Google Application Engineguestd77e8ae
Ā 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Enginerajdeep
Ā 
Google app engine - Overview
Google app engine - OverviewGoogle app engine - Overview
Google app engine - OverviewNathan Quach
Ā 
Google app engine
Google app engineGoogle app engine
Google app engineSuraj Mehta
Ā 
Google app engine
Google app engineGoogle app engine
Google app engineRenjith318
Ā 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App EngineColin Su
Ā 
Google App Engine Introduction
Google App Engine IntroductionGoogle App Engine Introduction
Google App Engine IntroductionSimon Su
Ā 
Google App Engine - Overview #3
Google App Engine - Overview #3Google App Engine - Overview #3
Google App Engine - Overview #3Kay Kim
Ā 
Google App Engine (Introduction)
Google App Engine (Introduction)Google App Engine (Introduction)
Google App Engine (Introduction)Praveen Hanchinal
Ā 
Powering your Apps via Google Cloud Platform
Powering your Apps via Google Cloud PlatformPowering your Apps via Google Cloud Platform
Powering your Apps via Google Cloud PlatformRomin Irani
Ā 
Google Cloud Platform Updates
Google Cloud Platform UpdatesGoogle Cloud Platform Updates
Google Cloud Platform UpdatesRomin Irani
Ā 

What's hot (20)

Google App Engine
Google App EngineGoogle App Engine
Google App Engine
Ā 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
Ā 
Platform as a service google app engine
Platform as a service   google app enginePlatform as a service   google app engine
Platform as a service google app engine
Ā 
Google App Engine: An Introduction
Google App Engine: An IntroductionGoogle App Engine: An Introduction
Google App Engine: An Introduction
Ā 
Developing Java Web Applications In Google App Engine
Developing Java Web Applications In Google App EngineDeveloping Java Web Applications In Google App Engine
Developing Java Web Applications In Google App Engine
Ā 
Gentle App Engine Intro
Gentle App Engine IntroGentle App Engine Intro
Gentle App Engine Intro
Ā 
What is Google App Engine?
What is Google App Engine?What is Google App Engine?
What is Google App Engine?
Ā 
Google Application Engine
Google Application EngineGoogle Application Engine
Google Application Engine
Ā 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
Ā 
Google app engine - Overview
Google app engine - OverviewGoogle app engine - Overview
Google app engine - Overview
Ā 
Google App engine
Google App engineGoogle App engine
Google App engine
Ā 
Google app engine
Google app engineGoogle app engine
Google app engine
Ā 
App Engine
App EngineApp Engine
App Engine
Ā 
Google app engine
Google app engineGoogle app engine
Google app engine
Ā 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
Ā 
Google App Engine Introduction
Google App Engine IntroductionGoogle App Engine Introduction
Google App Engine Introduction
Ā 
Google App Engine - Overview #3
Google App Engine - Overview #3Google App Engine - Overview #3
Google App Engine - Overview #3
Ā 
Google App Engine (Introduction)
Google App Engine (Introduction)Google App Engine (Introduction)
Google App Engine (Introduction)
Ā 
Powering your Apps via Google Cloud Platform
Powering your Apps via Google Cloud PlatformPowering your Apps via Google Cloud Platform
Powering your Apps via Google Cloud Platform
Ā 
Google Cloud Platform Updates
Google Cloud Platform UpdatesGoogle Cloud Platform Updates
Google Cloud Platform Updates
Ā 

Viewers also liked

ROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEY
ROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEYROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEY
ROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEYSupport Driven
Ā 
Google's BigTable
Google's BigTableGoogle's BigTable
Google's BigTablegeorge.james
Ā 
google Bigtable
google Bigtablegoogle Bigtable
google Bigtableelliando dias
Ā 
Google Bigtable Paper Presentation
Google Bigtable Paper PresentationGoogle Bigtable Paper Presentation
Google Bigtable Paper Presentationvanjakom
Ā 
Big table
Big tableBig table
Big tablePSIT
Ā 
Bigtable: A Distributed Storage System for Structured Data
Bigtable: A Distributed Storage System for Structured DataBigtable: A Distributed Storage System for Structured Data
Bigtable: A Distributed Storage System for Structured Dataelliando dias
Ā 
Google Big Table
Google Big TableGoogle Big Table
Google Big TableOmar Al-Sabek
Ā 
Google Bigtable paper presentation
Google Bigtable paper presentationGoogle Bigtable paper presentation
Google Bigtable paper presentationvanjakom
Ā 
The Google Bigtable
The Google BigtableThe Google Bigtable
The Google BigtableRomain Jacotin
Ā 

Viewers also liked (16)

Big table
Big tableBig table
Big table
Ā 
ROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEY
ROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEYROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEY
ROCKING YOUR SEAT AT THE BIG TABLE - ROB BAILEY
Ā 
Google's BigTable
Google's BigTableGoogle's BigTable
Google's BigTable
Ā 
Bigtable
BigtableBigtable
Bigtable
Ā 
google Bigtable
google Bigtablegoogle Bigtable
google Bigtable
Ā 
Google Bigtable Paper Presentation
Google Bigtable Paper PresentationGoogle Bigtable Paper Presentation
Google Bigtable Paper Presentation
Ā 
Big table
Big tableBig table
Big table
Ā 
GOOGLE BIGTABLE
GOOGLE BIGTABLEGOOGLE BIGTABLE
GOOGLE BIGTABLE
Ā 
Bigtable
BigtableBigtable
Bigtable
Ā 
Big table
Big tableBig table
Big table
Ā 
Bigtable
BigtableBigtable
Bigtable
Ā 
Bigtable: A Distributed Storage System for Structured Data
Bigtable: A Distributed Storage System for Structured DataBigtable: A Distributed Storage System for Structured Data
Bigtable: A Distributed Storage System for Structured Data
Ā 
Google Big Table
Google Big TableGoogle Big Table
Google Big Table
Ā 
Google Bigtable paper presentation
Google Bigtable paper presentationGoogle Bigtable paper presentation
Google Bigtable paper presentation
Ā 
Google BigTable
Google BigTableGoogle BigTable
Google BigTable
Ā 
The Google Bigtable
The Google BigtableThe Google Bigtable
The Google Bigtable
Ā 

Similar to I've (probably) been using Google App Engine for a week longer than you have

App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munichdion
Ā 
Castles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App EngineCastles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App Enginecatherinewall
Ā 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
Ā 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
Ā 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
Ā 
Angularjs
AngularjsAngularjs
AngularjsYnon Perek
Ā 
iPhone Development For Experienced Web Developers
iPhone Development For Experienced Web DevelopersiPhone Development For Experienced Web Developers
iPhone Development For Experienced Web Developerslisab517
Ā 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web ComponentsRed Pill Now
Ā 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine DevelopmentRon Reiter
Ā 
Google App Engine tutorial
Google App Engine tutorialGoogle App Engine tutorial
Google App Engine tutorialNameForTheTutorial
Ā 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScalePatrick Chanezon
Ā 
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)Tech in Asia ID
Ā 
Progressive Web Apps. What, why and how
Progressive Web Apps. What, why and howProgressive Web Apps. What, why and how
Progressive Web Apps. What, why and howRiza Fahmi
Ā 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
Ā 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
Ā 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
Ā 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizationsAnup Hariharan Nair
Ā 
Google Cloud Developer Challenge - GDG Belgaum
Google Cloud Developer Challenge - GDG BelgaumGoogle Cloud Developer Challenge - GDG Belgaum
Google Cloud Developer Challenge - GDG Belgaumsandeephegde
Ā 
How and why we evolved a legacy Java web application to Scala... and we are s...
How and why we evolved a legacy Java web application to Scala... and we are s...How and why we evolved a legacy Java web application to Scala... and we are s...
How and why we evolved a legacy Java web application to Scala... and we are s...Katia Aresti
Ā 

Similar to I've (probably) been using Google App Engine for a week longer than you have (20)

App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munich
Ā 
Castles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App EngineCastles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App Engine
Ā 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
Ā 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Ā 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Ā 
Angularjs
AngularjsAngularjs
Angularjs
Ā 
Gae
GaeGae
Gae
Ā 
iPhone Development For Experienced Web Developers
iPhone Development For Experienced Web DevelopersiPhone Development For Experienced Web Developers
iPhone Development For Experienced Web Developers
Ā 
An Introduction to Web Components
An Introduction to Web ComponentsAn Introduction to Web Components
An Introduction to Web Components
Ā 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine Development
Ā 
Google App Engine tutorial
Google App Engine tutorialGoogle App Engine tutorial
Google App Engine tutorial
Ā 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
Ā 
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
Ā 
Progressive Web Apps. What, why and how
Progressive Web Apps. What, why and howProgressive Web Apps. What, why and how
Progressive Web Apps. What, why and how
Ā 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
Ā 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
Ā 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
Ā 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
Ā 
Google Cloud Developer Challenge - GDG Belgaum
Google Cloud Developer Challenge - GDG BelgaumGoogle Cloud Developer Challenge - GDG Belgaum
Google Cloud Developer Challenge - GDG Belgaum
Ā 
How and why we evolved a legacy Java web application to Scala... and we are s...
How and why we evolved a legacy Java web application to Scala... and we are s...How and why we evolved a legacy Java web application to Scala... and we are s...
How and why we evolved a legacy Java web application to Scala... and we are s...
Ā 

More from Simon Willison

How Lanyrd does Geo
How Lanyrd does GeoHow Lanyrd does Geo
How Lanyrd does GeoSimon Willison
Ā 
Cheap tricks for startups
Cheap tricks for startupsCheap tricks for startups
Cheap tricks for startupsSimon Willison
Ā 
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)Simon Willison
Ā 
How we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graphHow we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graphSimon Willison
Ā 
Web Services for Fun and Profit
Web Services for Fun and ProfitWeb Services for Fun and Profit
Web Services for Fun and ProfitSimon Willison
Ā 
Tricks & challenges developing a large Django application
Tricks & challenges developing a large Django applicationTricks & challenges developing a large Django application
Tricks & challenges developing a large Django applicationSimon Willison
Ā 
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & FabricAdvanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & FabricSimon Willison
Ā 
How Lanyrd uses Twitter
How Lanyrd uses TwitterHow Lanyrd uses Twitter
How Lanyrd uses TwitterSimon Willison
Ā 
Building Things Fast - and getting approval
Building Things Fast - and getting approvalBuilding Things Fast - and getting approval
Building Things Fast - and getting approvalSimon Willison
Ā 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesSimon Willison
Ā 
Building crowdsourcing applications
Building crowdsourcing applicationsBuilding crowdsourcing applications
Building crowdsourcing applicationsSimon Willison
Ā 
Evented I/O based web servers, explained using bunnies
Evented I/O based web servers, explained using bunniesEvented I/O based web servers, explained using bunnies
Evented I/O based web servers, explained using bunniesSimon Willison
Ā 
Cowboy development with Django
Cowboy development with DjangoCowboy development with Django
Cowboy development with DjangoSimon Willison
Ā 
Crowdsourcing with Django
Crowdsourcing with DjangoCrowdsourcing with Django
Crowdsourcing with DjangoSimon Willison
Ā 
Class-based views with Django
Class-based views with DjangoClass-based views with Django
Class-based views with DjangoSimon Willison
Ā 
Web App Security Horror Stories
Web App Security Horror StoriesWeb App Security Horror Stories
Web App Security Horror StoriesSimon Willison
Ā 
Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror StoriesSimon Willison
Ā 

More from Simon Willison (20)

How Lanyrd does Geo
How Lanyrd does GeoHow Lanyrd does Geo
How Lanyrd does Geo
Ā 
Cheap tricks for startups
Cheap tricks for startupsCheap tricks for startups
Cheap tricks for startups
Ā 
The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)The Django Web Framework (EuroPython 2006)
The Django Web Framework (EuroPython 2006)
Ā 
Building Lanyrd
Building LanyrdBuilding Lanyrd
Building Lanyrd
Ā 
How we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graphHow we bootstrapped Lanyrd using Twitter's social graph
How we bootstrapped Lanyrd using Twitter's social graph
Ā 
Web Services for Fun and Profit
Web Services for Fun and ProfitWeb Services for Fun and Profit
Web Services for Fun and Profit
Ā 
Tricks & challenges developing a large Django application
Tricks & challenges developing a large Django applicationTricks & challenges developing a large Django application
Tricks & challenges developing a large Django application
Ā 
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & FabricAdvanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Advanced Aspects of the Django Ecosystem: Haystack, Celery & Fabric
Ā 
How Lanyrd uses Twitter
How Lanyrd uses TwitterHow Lanyrd uses Twitter
How Lanyrd uses Twitter
Ā 
ScaleFail
ScaleFailScaleFail
ScaleFail
Ā 
Building Things Fast - and getting approval
Building Things Fast - and getting approvalBuilding Things Fast - and getting approval
Building Things Fast - and getting approval
Ā 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
Ā 
Building crowdsourcing applications
Building crowdsourcing applicationsBuilding crowdsourcing applications
Building crowdsourcing applications
Ā 
Evented I/O based web servers, explained using bunnies
Evented I/O based web servers, explained using bunniesEvented I/O based web servers, explained using bunnies
Evented I/O based web servers, explained using bunnies
Ā 
Cowboy development with Django
Cowboy development with DjangoCowboy development with Django
Cowboy development with Django
Ā 
Crowdsourcing with Django
Crowdsourcing with DjangoCrowdsourcing with Django
Crowdsourcing with Django
Ā 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
Ā 
Class-based views with Django
Class-based views with DjangoClass-based views with Django
Class-based views with Django
Ā 
Web App Security Horror Stories
Web App Security Horror StoriesWeb App Security Horror Stories
Web App Security Horror Stories
Ā 
Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror Stories
Ā 

Recently uploaded

FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhisoniya singh
Ā 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Ā 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
Ā 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
Ā 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
Ā 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
Ā 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
Ā 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
Ā 
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Patryk Bandurski
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024BookNet Canada
Ā 
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024BookNet Canada
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
Ā 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
Ā 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
Ā 

Recently uploaded (20)

FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
Ā 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
Ā 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Ā 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Ā 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Ā 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Ā 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Ā 
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Ā 
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
Ā 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Ā 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Ā 

I've (probably) been using Google App Engine for a week longer than you have

  • 1. Iā€™ve (probably) been using Google App Engine for a week longer than you have Simon Willison - http://simonwillison.net/ BarCamp London 4 31st May 2008
  • 2. Except you have to re-write your whole application If you totally rethink the way you use a database
  • 3. What it can do ā€¢ Serve static ļ¬les ā€¢ Serve dynamic requests ā€¢ Store data ā€¢ Call web services (sort of) ā€¢ Authenticate against Googleā€™s user database ā€¢ Send e-mail, process images, use memcache
  • 4. The dev environment is really, really nice ā€¢ Download the (open source) SDK ā€¢ a full simulation of the App Engine environment ā€¢ dev_appserver.py myapp for a local webserver ā€¢ appcfg.py update myapp to deploy to the cloud
  • 5. Options ā€¢ You have to use Python ā€¢ You can choose how you use it: ā€¢ CGI-style scripts ā€¢ WSGI applications ā€¢ Googleā€™s webapp framework ā€¢ Django (0.96 provided, or install your own)
  • 6. Hello World # helloworld.py print quot;Content-Type: text/htmlquot; print print quot;Hello, world!quot; # app.yaml application: simonwillison-helloworld version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py
  • 7. With webapp and WSGI import wsgiref.handlers from google.appengine.ext import webapp class MainPage(webapp.RequestHandler): Ā  def get(self): Ā  Ā  self.response.headers['Content-Type'] = 'text/html' Ā  Ā  self.response.out.write('Hello, webapp World!') def main(): Ā  application = webapp.WSGIApplication( [('/', MainPage)], debug=True) Ā  wsgiref.handlers.CGIHandler().run(application) if __name__ == quot;__main__quot;: Ā  main()
  • 8. With Django from django.conf.urls.defaults import * from django.http import HttpResponse def hello(request): return HttpResponse(quot;Hello, World!quot;) urlpatterns = patterns('', ('^$', hello), ) (And django_dispatch.py for boilerplate)
  • 9. ā€¢ Don't use CGI: it requires reloading for every hit ā€¢ Why use Django over webapp? ā€¢ Django has easy cookies and custom 500 errors ā€¢ Django is less verbose ā€¢ Django middleware is really handy ā€¢ You can use other WSGI frameworks if you like
  • 10. Static ļ¬les # in app.yaml handlers: - url: /css static_dir: css - url: /img static_dir: img - url: /favicon.ico static_files: img/favicon.ico upload: img/favicon.ico mime_type: image/x-icon
  • 12. ā€œBigtable is a distributed storage system for managing structured data that is designed to scale to a very large size: petabytes of data across thousands of commodity servers. Many projects at Google store data in Bigtable, including web indexing, Google Earth, and Google Finance.ā€
  • 13. The App Engine datastore ā€¢ Apparently based on BigTable ā€¢ Absolutely not a relational database ā€¢ No joins (they do have ā€œreference ļ¬eldsā€) ā€¢ No aggregate queries - not even count()! ā€¢ Hierarchy affects sharding and transactions ā€¢ All queries must run against an existing index
  • 14. Models and entities ā€¢ Data is stored as entities ā€¢ Entities have properties - key/value pairs ā€¢ An entity has a unique key ā€¢ Entities live in a hierarchy, and siblings exist in the same entity group - these are actually really important for transactions and performance ā€¢ A model is kind of like a class; it lets you deļ¬ne a type of entity
  • 15. AppEngine Models from google.appengine.ext import db class Account(db.Model): slug = db.StringProperty(required=True) owner = db.UserProperty() onlyme = db.BooleanProperty() referrers = db.StringListProperty() (There is a ReferenceProperty, but I havenā€™t used it yet)
  • 16. Inserting data account = Account( key_name = slug, slug = slug, referrers = ['...', '...'], onlyme = False, owner = users.get_current_user() ) db.put(account) # Or account.put() Browser.get_or_insert(key_name, parent = account, slug = browser_slug )
  • 17. Running queries Browser.all().ancestor(account) Account.gql(quot;WHERE slug = :1quot;, slug)) Story.all().filter( 'title =', 'Foo' ).order('-date')
  • 18. BUT... ā€¢ All queries must run against an existing index ā€¢ Filtering or sorting on a property requires that the property exists ā€¢ Inequality ļ¬lters are allowed on one property only ā€¢ Properties in inequality ļ¬lters must be sorted before other sort orders ā€¢ ... and various other rules ā€¢ Thankfully the dev server creates most indexes for you automatically based on usage
  • 19. How indexes are used 1. The datastore identiļ¬es the index that corresponds with the queryā€™s kind, ļ¬lter properties, ļ¬lter operators, and sort orders. 2. The datastore starts scanning the index at the ļ¬rst entity that meets all of the ļ¬lter conditions using the queryā€™s ļ¬lter values. 3. The datastore continues to scan the index, returning each entity, until it ļ¬nds the next entity that does not meet the ļ¬lter conditions, or until it reaches the end of the index.
  • 20. Further limitations ā€¢ If you create a new index and push it live, you have to wait for it to rebuilt ā€¢ This can take hours, and apparently can go wrong ā€¢ You canā€™t safely grab more than about 500 records at once - App Engine times out ā€¢ You canā€™t delete in bulk
  • 21. Other random notes ā€¢ You have to use the URL Fetch API to do HTTP requests (e.g. for web services) - and it times out agressively at about 5 seconds ā€¢ The Google accounts Users API is ridiculously easy to use, but... ā€¢ no permanent unique identiļ¬er; if the user changes their e-mail address youā€™re screwed ā€¢ The new image and memcache APIs are neat
  • 22. Final thoughts ā€¢ Itā€™s really nice not to have to worry about hosting ā€¢ But... the lack of aggregate queries and ad-hoc queries really hurts ā€¢ Perfect for small projects you donā€™t want to worry about and big things which youā€™re sure will have to scale ā€¢ Pricing is comparable to S3 - i.e. stupidly cheap
  • 23. Pricing ā€¢ $0.10 - $0.12 per CPU core-hour ā€¢ $0.15 - $0.18 per GB-month of storage ā€¢ $0.11 - $0.13 per GB outgoing bandwidth ā€¢ $0.09 - $0.11 per GB incoming bandwidth