google app engine: java technology in the cloud · google app engine: java technology in the cloud...
TRANSCRIPT
Google App Engine:Java TechnologyIn The Cloud
Toby Reyelts, Max Ross, Don SchwarzGoogle
1Thursday, 4 June 2009
Goals
> Google App Engine> Java on App Engine> The App Engine Datastore> Demo> Questions
2
2Thursday, 4 June 2009
What Is Google App Engine?
> A cloud-computing platform> Run your web apps on Google’s infrastructure> We provide the container and services (PaaS)
• Hardware, connectivity• Operating system• JVM• Servlet container• Software services
3
3Thursday, 4 June 2009
Key Features
> No need to install or maintain your own stack> We scale for you> Use Google’s scalable services via standard APIs> Charge only for actual usage
• Always free to get started> Built-in application management console
4
4Thursday, 4 June 2009
App Engine Architecture
5
Incoming Requests
5Thursday, 4 June 2009
App Engine Architecture
5
Incoming Requests
App Engine Front End
App Engine Front End
App Engine Front End
5Thursday, 4 June 2009
App Engine Architecture
5
AppServer AppServer AppServer
Incoming Requests
App Engine Front End
App Engine Front End
App Engine Front End
5Thursday, 4 June 2009
App Engine Architecture
5
AppServer AppServer AppServer
Incoming Requests
App Engine Front End
App Engine Front End
App Engine Front End
Load Balancer
5Thursday, 4 June 2009
App Engine Architecture
5
AppServer AppServer AppServer
Incoming Requests
App Engine Front End
App Engine Front End
App Engine Front End
Load Balancer
AppServer
API Layer
Other Google Infrastructure
- Bigtable
- Google Accounts
- Memcache
- Image manipulation
App App App
5Thursday, 4 June 2009
When To Use Google App Engine
> Targeting web applications• Serve HTTP requests, limited to 30 seconds• No long-running background processes• No server push
> Sandboxed environment• No threads• Read-only file system
6
6Thursday, 4 June 2009
WebHooks (coming soon)
> Incoming email> XMPP> Google Wave> Task Queues
7
7Thursday, 4 June 2009
Java Support
> Servlets> Software services> Sandboxing> DevAppServer> Deployment> Tooling
8
8Thursday, 4 June 2009
Servlet API
> Full Servlet 2.5 Container• HTTP Session• JSP
> Uses Jetty and Jasper• Powered by Google’s HTTP stack• No Jetty-specific features• Subject to change
9
9Thursday, 4 June 2009
Software Services
10
Service Java Standard Google InfrastructureAuthentication Servlet API Google Accounts
Datastore JPA, JDO Bigtable
Caching javax.cache memcacheg
E-mail javax.mail Gmail gateway
URLFetch URLConnection Caching HTTP proxy
10Thursday, 4 June 2009
Sandboxing
> What do we do?• Restrict JVM permissions• WhiteList classes
> Why is it necessary?• Clustering - JVMs come and go• Protect applications from one another
11
11Thursday, 4 June 2009
Sandboxing Restrictions
12
Restriction Alternative
Threads Async and Queue API (Soon!)
Direct network connections URLConnection
Direct file system writes Memory, memcache, datastore
Java2D Images APISoftware rendering
Native code Pure Java libraries
12Thursday, 4 June 2009
Flexible Sandboxing
13
13Thursday, 4 June 2009
Flexible Sandboxing
13
JVM Permissions often too coarse.
13Thursday, 4 June 2009
Flexible Sandboxing
13
JVM Permissions often too coarse.They either provide a cramped sandbox.
13Thursday, 4 June 2009
Flexible Sandboxing
13
JVM Permissions often too coarse.They either provide a cramped sandbox.
Or they hand over the nuclear launch codes.
13Thursday, 4 June 2009
Flexible Sandboxing
13
JVM Permissions often too coarse.They either provide a cramped sandbox.
Or they hand over the nuclear launch codes.
App Engine delivers a happy medium.
13Thursday, 4 June 2009
Flexible Sandboxing - Reflection
14
14Thursday, 4 June 2009
Flexible Sandboxing - Reflection
> Access private fields, call private methods• suppressAccessChecks• accessDeclaredMembers
14
14Thursday, 4 June 2009
Flexible Sandboxing - Reflection
> Access private fields, call private methods• suppressAccessChecks• accessDeclaredMembers
14
Field f = String.class.getDeclaredField(“count”);f.setAccessible(true);
f.set(“Hello World”, 2);
Bad!
14Thursday, 4 June 2009
Flexible Sandboxing - Reflection
> Access private fields, call private methods• suppressAccessChecks• accessDeclaredMembers
14
Field f = String.class.getDeclaredField(“count”);f.setAccessible(true);
f.set(“Hello World”, 2);
Field f = MyClass.class.getDeclaredField(“foo”);f.setAccessible(true);
f.set(myObj, aFoo);
Bad!
Good!
14Thursday, 4 June 2009
Flexible Sandboxing - Class Loading
15
15Thursday, 4 June 2009
Flexible Sandboxing - Class Loading
> Create user-controlled ClassLoaders• createClassLoader
15
15Thursday, 4 June 2009
Flexible Sandboxing - Class Loading
> Create user-controlled ClassLoaders• createClassLoader
15
Bad!ClassLoader myClassLoader = new URLClassLoader() {
public PermissionsCollection getPermissions(CodeSource cs) {
// return AllPermission;
}
};
15Thursday, 4 June 2009
Flexible Sandboxing - Class Loading
> Create user-controlled ClassLoaders• createClassLoader
15
Bad!ClassLoader myClassLoader = new URLClassLoader() {
public PermissionsCollection getPermissions(CodeSource cs) {
// return AllPermission;
}
};
Good!ClassLoader myClassLoader = new URLClassLoader() {
public Class findClass(String className) {
// define and load some newly generated bytecode
}
};
15Thursday, 4 June 2009
Flexible Sandboxing - Compatibility
> Dependency Injection Frameworks• Guice, Spring
> Aspect Oriented Programming• AspectJ, Spring AOP
> Web Frameworks• GWT, Tapestry, BlazeDS (Flex), Grails!
> Alternate JVM languages• Scala, Rhino, JRuby, Jython, Clojure, Groovy, PHP
16
16Thursday, 4 June 2009
DevAppServer
> Emulates the production environment> Customized Jetty server> Local implementation of services
• LRU memcache• Disk-backed datastore• HttpClient-backed URLFetch
> Some sandbox restrictions difficult to emulate
17
17Thursday, 4 June 2009
Deployment
> Your app lives at • <app_id>.appspot.com, or• Custom domain with Google Apps for your Domain
> Command line and IDE tools> Admin Console
• Dashboards• Manage multiple versions• View logs (java.util.logging)
18
18Thursday, 4 June 2009
Quotas and Billing
19
Resource Provided Free Additional CostCPU 6.5 hours/day $0.10/hour
Bandwidth In 1GByte/day $0.10/GByte
Bandwidth Out 1GByte/day $0.12/GByte
Stored Data 1 GB $0.005/GB-day
Emails sent 2000/day to users5000/day to admins $0.0001/email
19Thursday, 4 June 2009
Tooling
> SDK Tools API• Command-line tools, Ant, and IDE plugins
> Provides• Deployment• DevAppServer• WhiteList• XML validation
> Google Eclipse Plugin, Intellij Plugin
20
20Thursday, 4 June 2009
The Datastore Is...
> Transactional> Natively Partitioned> Hierarchical> Schema-less> Based on Bigtable> Not a relational db> Not a SQL engine
21
Wow. That isone big table.
21Thursday, 4 June 2009
Simplifying Storage
> Simplify development of apps> Simplify management of apps> App Engine services build on Google’s strengths> Scale always matters
• Request volume• Data volume
22
22Thursday, 4 June 2009
Datastore Storage Model
> Basic unit of storage is an Entity consisting of• Kind (table)• Key (pk)• Entity Group (top level ancestor)
• Has locking implications
• 0..N typed Properties (columns)
23
23Thursday, 4 June 2009
Interesting Datastore Modeling Features
> Ancestor> Multi-value properties> Variable properties> Heterogenous property types
24
Kind PersonEntity Group /Person:EthelKey /Person:EthelAge Int64: 30Hobbies String: Tennis
Kind PersonEntity Group /Person:EthelKey /Person:Ethel/Person:JaneAge Double: 3.5Pets Key:/Turtle:Sam Key:/Dog:Ernie
24Thursday, 4 June 2009
Datastore Transactions
> Transactions apply to a single Entity Group• Global transactions are feasible
> get(), put(), delete() are transactional> Queries are not transactional (yet)
25
/Person:Ethel/Person:Jane
/Person:Ethel
/Person:Max
Transaction
25Thursday, 4 June 2009
Standards-based Persistence
> JDO or JPA (your choice)• Established apis and existing tooling• Easier porting• Mappable (mostly) to the datastore• Soft schemas
> DataNucleus App Engine plugin> Why not a JDBC driver instead?
26
26Thursday, 4 June 2009
@Entity
class Person {
// ...
@OneToMany
List<Pet> pets;
}
Transparent Entity Group Management
> Entity Group layout is important• Write throughput• Atomicity of updates
> Ownership implies co-location within Entity Group
27
Kind PetEntity Group /Person:EthelKey /Person:Ethel/Pet:Sam
27Thursday, 4 June 2009
28
Demo!
28Thursday, 4 June 2009
Demo - Login
29
29Thursday, 4 June 2009
Demo - Question
30
30Thursday, 4 June 2009
Demo - Question Result
31
31Thursday, 4 June 2009
Demo - Scoreboard
32
32Thursday, 4 June 2009
33
Demo - Code!
33Thursday, 4 June 2009
34
http://java-demo.appspot.com
34Thursday, 4 June 2009
Toby Reyelts, Max Ross,Don [email protected] [email protected]@google.com
http://code.google.com/appengineGoogle Group: google-appengine-java
35Thursday, 4 June 2009