Google Cloud Platform

  • Google App Engine - Host your applications
  • Google Compute Engine - Host your Virtual Machines
  • Google Cloud Storage - Host your files
  • Google Cloud SQL - Host your databases
  • Google BigQuery - Analyze data
  • Google Cloud Datastore - No-SQL database in the cloud
  • Details at cloud.google.com

What is Google App Engine?

  • PaaS (Platform as a Service)
  • A web application platform
    • Create applications in Java, Python, Go or PHP
    • Store data in the cloud
  • A set of APIs, including
    • Data Storage
    • Task Queues
    • Users
  • Easy to
    • Build and Deploy
    • Manage
    • Scale
  • Details at developers.google.com/appengine

Developing with Google App Engine

You focus on building awesome web applications, App Engine does the rest

Always remember: developers.google.com/appengine

Four easy steps

  • Step 1: Get the Google App Engine SDK
  • Step 2: Write code
  • Step 3: Test locally
  • Step 4: Deploy to App Engine

Get the Google App Engine SDK

The base for your application

The Google App Engine SDK

The SDK contains:

  • Libraries for the many APIs the platform provides
    • Get it here
    • For Java, there is an Eclipse plugin
  • Utilities to deploy locally (Local Dev Server) and to your App Engine instance

Write some code

Use the SDK libraries to build your application

A Google App Engine application

Your application can be written in

  • Java
  • Python
  • Go (*)
  • PHP (*)

Your application will execute in a sandbox

  • More secure
  • More scalable
  • More distributable
(*) Experimental

The sandbox

The sandbox aims to make it better for everyone

  • Applications don't interfere with each other
  • Applications don't rely on machine-specific resources (e.g. filesystem)

Restrictons vary per language, but generally

  • No filesystem access (use Datastore to persist data)
  • No opening sockets (use URLFetch to make HTTP/HTTPS requests)
  • Complete a web request in < 60 seconds (return fast, use Tasks)
  • No system calls
(*) Experimental

Java

  • Implement servlets and JSPs
  • Support for Java 6 or Java 7
  • The Java App Engine environment supports a subset of the JRE libraries
  • IDE Plugins for
    • Eclipse (Google-supported)
    • Netbeans
    • IntelliJ

Anatomy of a (Java) web application

  • Project Root
    • src/
      • Source code goes here
    • war/
      • Static files go here
      • index.html
      • style/
      • js/
      • WEB-INF/
        • web.xml - Servlet configuration
        • appengine-web.xml - App Engine configuration

Python

  • Applications can use any WSGI-compatible web application framework
  • webapp2 is included in the runtime
  • Support for Python 2.5 (deprecated) and 2.7
  • Supports some useful libraries (Django, Jinja, etc.)

PHP

  • PHP 5.4 runtime
  • > 35 extensions enabled

Go

  • Support for Go v1
  • Use the Go http package
  • Writing App Engine apps is the same as writing stand-alone Go web servers

Anatomy of a (Python|PHP|Go) web application

  • Project Root
    • app.yaml - App Engine configuration
    • Source code
    • Static files
  • SDK contains new_project_template and demos directories to help

Storing data

  • Datastore
    • Schema-less, NoSQL database
    • You define entities with properties
    • Max of 1MB per entity
  • Blobstore
    • Store large amounts of data
  • Google Cloud SQL
    • MySQL database in the cloud
    • Uses the familiar MySql client library approach
  • Google Cloud Storage
    • Cloud-based file-system
    • ACLs
    • Resume functionality

Google App Engine Services

Support differs per language

Free quota and then start paying

  • URL Fetch
    • Make an HTTP/S request
    • Use normal lanuage-specific approach, e.g. java.net.URL.openStream
  • Task Queues
    • Defer longer tasks
    • Task has 10 minutes to complete
  • Memcache
    • Store key/value pairs in memory
    • 1MB data limit per entry

Google App Engine Services

  • Users
    • Authenticate users
    • Use their Google account (incl. Google Apps accounts) or OpenID(*)
  • Logs
    • Access logs data from your application
    • Request logs - contains data about each HTTP/S request
    • Application logs - contains messages you log from your application
The authentication choice is made when you setup the application and cannot be changed later. OpenID support is experimental.

Test your application locally

Run your code in a development application server

Testing your application locally

  • SDK: Use dev_appserver.py
  • Eclipse: Run or debug as Web Application
  • Management console similar to production
  • Acts like App Engine with small differences
    • Datastore is a local file
    • User service is mocked
    • URL Fetch is from your computer

Deploy to App Engine

It works! Let's go!

Deploying to App Engine

  • SDK: Use appcfg.py
  • Eclipse: Deploy to App Engine
  • The SDK will package your application and update it
  • You'll need to create an App Engine account first and create an Application ID

Google App Engine Management Console

  • Visit appengine.google.com
  • Perform many admin functions
    • Manage applications and instances
    • View Logs
    • View Data (Datastore, Blobstore)
    • Manage versions
    • Manage Task Queues
    • View detailed quota-usage information

Some pointers

  • Read fast, write slow
    • Use memcache for common data
    • Defer writing of data with Task Queue
    • Think about indexes on your data
  • De-normalise your data
    • Decrease the number of join-like queries to Datastore
    • For example, in your entity, use a list of objects for a parent-child relationship
  • If you're using Java
    • Use JDO/JPA to make entity persistence simpler
  • If you can, use Google Cloud Endpoints
    • Python and Java only
    • Create an API to manage your entities
    • The SDK generates libraries for iOS, Android and Javascript
    • Single API for different consumers

Summary

<Thank You!>