Infinite Scale - Introduction to Google App Engine

30
Infinite Scale Introduction to Google App Engine

Transcript of Infinite Scale - Introduction to Google App Engine

Page 1: Infinite Scale - Introduction to Google App Engine

Infinite Scale

Introduction to Google App Engine

Page 2: Infinite Scale - Introduction to Google App Engine
Page 3: Infinite Scale - Introduction to Google App Engine

There are only 10 types of people in the world: those who understand

binary, and those who don’t

Page 4: Infinite Scale - Introduction to Google App Engine

There are only 10 types of people in the world: those who understand

binary, and those who don’t

If you smiled, chances are you’ll understand thispresentation, if not, at least you’ll know this stuff exists

Page 5: Infinite Scale - Introduction to Google App Engine

Google Cloud Platform

Page 6: Infinite Scale - Introduction to Google App Engine

Google App Engine

• Platform as a Service

• Run applications on Google’s infrastructure

• Used by millions

• Best Buy / Coca Cola / Ubisoft / Sony

Page 7: Infinite Scale - Introduction to Google App Engine

Google App Engine

• Build and deploy

• No worrying about servers or load balancers

• Auto scale to 7 billion requests per day

• Java / Python / PHP / Go

Page 8: Infinite Scale - Introduction to Google App Engine

GAE Python Runtime Environment

• App Engine executes Python app code using an interpreter in a "sandboxed" environment

• The interpreter can run any pure Python code

• The "sandbox" environment isolates your app for service and security; an application cannot:

– Write to the filesystem

– Respond slowly

– Make other kinds of system calls

Page 9: Infinite Scale - Introduction to Google App Engine

GAE Python Runtime Environment

• GAE Request Headers– Sanitized for security

– Additional headers: country, region, city, latlong

• GAE Responses– All output data is sent, does not support sending data

to the browser before the handler returns

– Additional headers when accessing the site as administrator:• Estimate of what 1,000 similar requests would cost

• Resources used by the request, including server-side time

• GAE automatically uses the SPDY protocol

Page 10: Infinite Scale - Introduction to Google App Engine

Google App Engine Python Tutorial

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 11: Infinite Scale - Introduction to Google App Engine

Google App Engine Python Tutorial

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 12: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Hello, Universe!

• Configuration file: app.yaml

– YAML: recursive acronym for “YAML Ain’t Markup Language”

– YAML is a human friendly data serialization standard for all programming languages

• Python script: hellouniverse.py

<CODE/>

Page 13: Infinite Scale - Introduction to Google App Engine

Google App Engine Python Tutorial

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 14: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Frameworks

• GAE supports any framework written in pure Python that speaks WSGI– Django, CherryPy, Pylons, web.py, web2py, etc.

• WSGI – Web Server Gateway Interface– Interface between web servers and web

applications or frameworks for Python

• Webapp2– App Engine includes a simple web application

framework, called webapp2

Page 15: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Frameworks

• A webapp2 application has two parts

– one or more RequestHandler classes that process requests and build responses

– a WSGIApplication instance that routes incoming requests to handlers based on the URL

Page 16: Infinite Scale - Introduction to Google App Engine

Google App Engine Python Tutorial

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 17: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Users

• GAE provides several useful services based on Google infrastructure

• Users service lets your application integrate with Google user accounts

• With the Users service, your users can use the Google accounts they already have to sign in to your application

<CODE/>

Page 18: Infinite Scale - Introduction to Google App Engine

Google App Engine Forms

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 19: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Forms

• The webapp2 framework makes processing form data easy

– Define handlers to send form data

– Define classes or methods to process data

<CODE/>

Page 20: Infinite Scale - Introduction to Google App Engine

Google App Engine Datastore

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 21: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Datastore

• App Engine's data repository, the High Replication Datastore (HRD), replicates data across multiple datacenters

• Data is written in Entities

• The entities form a hierarchically-structured space similar to a directory structure

<CODE/>

Page 22: Infinite Scale - Introduction to Google App Engine

Google App Engine Templates

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 23: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Templates

• With a templating system the HTML is kept in a separate file with special syntax

• There are many templating systems for Python: EZT, Cheetah, ClearSilver, Quixote, Django, Jinja2, etc.

• App Engine includes the Django and Jinja2 templating engines

<CODE/>

Page 24: Infinite Scale - Introduction to Google App Engine

Google App Engine Assets

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 25: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Assets

• GAE does not serve files directly out of your application's source directory

• There are many cases where you want to serve static files directly to the web browser: Images, CSS stylesheets, JavaScript code, movies, Flash animations, etc.

• App Engine can serve specific files without you having to code your own handler

<CODE/>

Page 26: Infinite Scale - Introduction to Google App Engine

Google App Engine Tests

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 27: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Tests

• Instead of writing tests after you finish developing your application, consider writing the tests as you go

• App Engine provides testing utilities that use local implementations of datastore and other App Engine services, by using service stubs (local service simulators)

<CODE/>

Page 28: Infinite Scale - Introduction to Google App Engine

Google App Engine Deployment

1. Hello, Universe!2. Frameworks3. Users4. Forms5. Datastore6. Templates7. Assets8. Tests9. Deployment

Page 29: Infinite Scale - Introduction to Google App Engine

GAE Tutorial Deployment

• Use appcfg.py script or GAE Launcher

• Each project can have one Release Pipeline:– Building the application

– Running unit tests (optional)

– Deploying the application to App Engine

– Sending notifications upon completion (optional)

• Trigger the Release Pipeline by pushing the source to the master branch of your Cloud Repository <EXAMPLE/>

Page 30: Infinite Scale - Introduction to Google App Engine

Resources:

• Google Cloud Platformhttps://cloud.google.com/

• Google App Engine Docshttps://cloud.google.com/appengine/docs

• GAE Developers Consolehttps://console.developers.google.com

• This tutorial is based on the official Python Getting Started guide from Google App Engine, created by the App Engine team and licensed under the Creative Commons Attribution 3.0 License

Thank You!