SlideShare a Scribd company logo
Google AppEngine
     Paul Bakker
About me
  Paul Bakker
• Trainer Info Support            Hibernat
                         EJB 3
                                  e
• NLJUG speaker          JSF
                                  Flex
• Java Magazine author   Seam
                                  Groovy
                         JavaFX
                                  Grails
                         Spring
About Info Support
•   Financieel gezond sinds oprichting 1986
•   Focus op IT vakmanschap
•   Brede en integrale dienstverlening
•   Partnerships met o.a. Microsoft, IBM, NLJUG
•   Vestigingen in Nederland en België
    - 250+ medewerkers in Nederland
    - 25 medewerkers in België
Presentation Goal

Introduction to
  Developing
    applications for

 AppEngine
Outline         AppEngine
 Cloud          Services
 offerings      Using
 Introducing    frameworks
 AppEngine      Pricing
 Developing
 and
 deploying
 Storing data
Clouds N’ stuff
Infrastructure
 as a Service
                 Platform as a
                    Service
 Software as a
    Service
Infrastructure
              as a Service
 A virtual hardware platform
  Full control of the operating system

Custom configuration of application servers
Infrastructure
                as a Service
Pros
It’s just works like your old hardware
     No development limitations
 No lock-in


                   Cons
                     You still have to manage servers
                         No automatic scaling
Platform as a
                Service
A virtual application server
   No control of the operating system
Running in a sandbox
Platform as a
                 Service
 Pros
No more server management
    Easy deployment
Automatic scaling
                   Cons
                        Limited by the sandbox
                      Can’t run existing apps
Software as a
                  Service
Run an application from the cloud
  Might extend the application using a
             proprietary API
AppEngine
  Intro
AppEngine architecture
Handling requests
Each application gets a free domain name
  http://yourappname.appspot.com
You can add your own domain name
Each request has a 30 second timeout
Streaming responses are not supported
Scaling
JVMs are started on demand
  on app startup
  after inactivity
  when upscaling
Starting a JVM causes a “loading request”
  the app is loaded during that request
Loading request
     optimization
Application startup time is now important
  the app might be started after a request
Reduce the use of libraries
Prevent heavy initialization code
  share data with multiple JVMs using
  MemCache
The sandbox
You can’t
   Write to the file system
   Open sockets
   Start threads
   Invoke most System calls
   Reflect on classes not belonging to the app
   Use JRE classes not on the white list
Supported
Java Data Objects (JDO)
Java Persistence API (JPA)
Java Server Faces (JSF)
Java Server Pages (JSP) and JSTL
Java Servlet API 2.4
JavaBeans Activation Framework (JAF)
Java Architecture for XML Binding (JAXB)
JavaMail
XML processing APIs including DOM, SAX and XSLT
Not Supported
Enterprise Java Beans (EJB)
JAX-WS and JAX-RPC
JDBC
Java EE Connector Architecture (JCA)
Java Management Extensions (JMX)
Java Message Service (JMS)
Java Naming and Directory Interface (JNDI)
Remote Method Invocation (RMI)
Creating and
uploading an application
Storing Data
DataStore
Distributed architecture
Highly scalable
Not relational
Schemaless
Properties have one or more values
Sharded architecture
          Row name   Values
             A        [...]
             B        [...]
             C        [...]


          Row name   Values
             D        [...]
             E        [...]
             F        [...]


          Row name   Values
             G        [...]
             H        [...]
             I        [...]
Entity storage
   Kind => table
   Key => primary key
   Entity Group => partition
   Typed properties => columns

Kind                       Person
Entity Group               /Person:Paul
Key                        /Person:Paul
name                       string: Paul Bakker
colleagues                 Key:/Speaker(68)   Key:/Speaker(15)
Entity Groups

Entities are hierarchical
Useful for “owned” relations
  a chapter can’t exist without a book
  /Book(24)/Chapter(2)/Paragraph(3)
Queries
Supported filters
 < less than

 <= less than or equal to

 = equal to

 > greater than

 >= greater than or equal to

 != not equal to
Indexes
Each query uses an index
One index for each combination of:
  kind
 filter property
 operator
 sort order
Index example
              JPQL queries
                 select s from Speaker s order by s.firstname, s.lastname

select s from Speaker s WHERE s.firstname LIKE :firstname order by s.firstname, s.lastname

select s from Speaker s WHERE lastname LIKE :lastname order by s.lastname, s.firstname




       Index configuration
Transactions
The DataStore is transactional
All DataStore write operations are atomic
Only a single Entity Group can be used
within a transaction
  entities in the same group live physically
  together
Transactions
Transactions
Begin transaction
Transactions
Begin transaction
Create new Speaker (/Speaker(1))
Transactions
Begin transaction
Create new Speaker (/Speaker(1))
Add Talk (/Speaker(1)/Talk(1))
Transactions
Begin transaction
Create new Speaker (/Speaker(1))
Add Talk (/Speaker(1)/Talk(1))
Add new Speaker (/Speaker(2))
Transactions
Begin transaction
Create new Speaker (/Speaker(1))
Add Talk (/Speaker(1)/Talk(1))
Add new Speaker (/Speaker(2))
Commit transaction
Transactions
Begin transaction
Create new Speaker (/Speaker(1))
Add Talk (/Speaker(1)/Talk(1))
Commit transaction
Begin transaction
Add new Speaker (/Speaker(2))
Commit transaction
Transaction Isolation
Within a transaction: Serializable
  transactions are completely isolated
Outside a transaction: Read Committed
  get() will only consist of committed data
  queries are more subtle
Understand commits
      A commit() consists of two milestones
        1 changes to entities visible
        2 changes to indexes visible




the entity is updated, but might not be
    returned by a predicate query
Understand commits
       bob.age == 18

Transaction 1
       bob.age += 1




                      select ... where age = 18
Transaction 2
Understand commits
       bob.age == 18

Transaction 1
       bob.age += 1




                      select ... where age = 18
Transaction 2
                         bob is returned
Understand commits
       bob.age == 18

Transaction 1
       bob.age += 1




                      select ... where age = 18
Transaction 2
                         bob is returned
                           bob.age == 19
The low level API

JDBC like API
Work directly with untyped entities and
properties
Query using GQL
Creating entities
Queries
GQL
SELECT [* | __key__] FROM <kind>
   [WHERE <condition> [AND <condition> ...]]
   [ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
   [LIMIT [<offset>,]<count>]
   [OFFSET <offset>]

<condition> := <property> {< | <= | > | >= | = | != } <value>
<condition> := <property> IN <list>
<condition> := ANCESTOR IS <entity or key>
GQL
Setting up JPA

Add JPA and DataNucleus jars
Create persistence.xml
Configure post-compilation class
enhancement
Persistence Unit
EntityManagerFactory
Creating an Entity
JPA limitations
No “Joined” inheritance
No “Single Table” inheritance
  would be technically possible
No many-to-many relationships
No join-queries
No aggregation queries
No polymorphic queries
Owned relationships

The “owned” entity only has meaning when
it’s parent exists
 Key includes parent key
/Department(24)/Employee(2)
Owned relations
Owned relations
Polymorphic relations




Throws exception!
Using JPA
Unowned relations




No referential checks!
Unowned relations

Both entities can exist without the other
  an employee and it’s colleagues
  Cannot be used within the same
  transaction
Loading collections
Many-to-many


GAE doesn’t support JPA many-to-many
Work around by mapping key collections
Unowned collections
Constraining pages

Uses Google Accounts
Require users to log-in
Require the admin role
  admin == developer on GAE
Require to
  login




 Require
admin role
Login and logout
Login




Logout
Using Google Accounts
Services                Mail
           Users
  Queus
      MemCache

                    Blob Store

                   Cron Jobs
Mail service
Receiving mail
!   Mail can be send to
  somename@appid.appspotmail.com!


                      POST!
        AppEngine!            MyServlet!
                          /_ah/mail/address!
Cron Jobs

Tasks that run automatically on specific
times or intervals
  sending a week report
  nightly cleanup
Executing a job is invoking a URL
Configuring jobs
Configure job in WEB-INF/cron.xml
Cron syntax
              every N (hours|mins|minutes)


("every"|ordinal) (days) ["of" (monthspec)] (time)


          Examples
            every 5 minutes
            every 12 hours
            2nd,third mon,wed,thu of march 17:00
            every monday 09:00
            1st monday of sep,oct,nov 17:00
            every day 00:00
Cron jobs
Task Queues
Process asynchronous, parallel background
tasks
Modeled as web hooks
 a request to a web hook is scheduled
 the request handler is just like any other
 user request
 a web hook has data and code
Task queue use cases
Send multiple confirmation emails
 each email is sent by a request to the
 same task with different data
Place order
 send confirmation email (task 1)
 send notification to admin (task 2)
Adding tasks


/notification
Configuring queues
     WEB-INF/queue.xml




rate: throttling task execution
bucket-size: “token-bucket” algorithm
Task Queues
Saving files
Store files up to 50 mb in the BlobStore
Upload by form POST
  file is uploaded to the BlogStore
  get a blob key in code
Serve file using blob key
Upload file
Serving files
Listing blobs
BlobStore
MemCache

Distributed in-memory cache
 e.g. cache frequent queries
JCache API (JSR 107)
Low level API
Using a cache
 Cache expires after 3600 miliseconds
Memcache
Frameworks
on AppEngine
Frameworks
   A lot of frameworks work “mostly”
         but you never know if/when it breaks...
JSF 1.2                  e.g. RichFaces is not!
 JSF 2                      disable threads
Grails                      using a plugin
 Weld                       multiple issues
JAX-WS
 EJB
Spring                  some modules are not
 JMS
Testing
Unit Testing

Easy out of container unit testing
In-memory DataService, MailService,
MemcacheService, TaskQueue,
AuthenticationService etc.
Appengine Nljug
Setup
  local
datastore
Create
datastore
 instance
Use
datastore
   API
 directly
Using JPA
Appengine Nljug
TaskQueue testing
     (setup)
TaskQueue testing
     (test)
Unit Testing
Costs
Quotas
                       Free Default Quota                     Billing Enabled Default Quota

Resource

                       Daily Limit          Maximum Rate      Daily Limit           Maximum Rate


                                            7,400 requests/   43,000,000            30,000 requests/
Requests               1,300,000 requests
                                            minute            requests              minute

Outgoing                                    56 megabytes/     1 gigabyte free;      10 gigabytes/
Bandwidth (billable,   1 gigabyte                             1,046 gigabytes
                                            minute                                  minute
includes HTTPS)                                               maximum

Incoming                                    56 megabytes/     1 gigabyte free;      10 gigabytes/
Bandwidth (billable,   1 gigabyte                             1,046 gigabytes
                                            minute                                  minute
includes HTTPS)                                               maximum

                                            15 CPU-minutes/   6.5 CPU-hours free;   72 CPU-minutes/
CPU Time (billable)    6.5 CPU-hours                          1,729 CPU-hours
                                            minute                                  minute
                                                              maximum
Pricing
Resource       Unit            Unit cost


Outgoing
               gigabytes       $0.12
Bandwidth


Incoming
               gigabytes       $0.10
Bandwidth


CPU Time       CPU hours       $0.10


               gigabytes per
Stored Data                    $0.15
               month


Recipients
               recipients      $0.0001
Emailed
Setting a budget
The verdict
Deployment can’t get any
easier
Sandbox can be a show
stopper
Apps should be
developed specifically for
AppEngine
Google AppEngine
     Paul Bakker

More Related Content

PPTX
Silicon Valley JUG - How to generate customized java 8 code from your database
PDF
jsf2 Notes
PDF
The Future of Plugin Dev
PPT
SHOW104: Practical Java
PPTX
Intro to .NET for Government Developers
PPT
Proper Connections Development for Proper Domino Developers
PDF
Local storage in Web apps
PDF
HTML5 and CSS3 refresher
Silicon Valley JUG - How to generate customized java 8 code from your database
jsf2 Notes
The Future of Plugin Dev
SHOW104: Practical Java
Intro to .NET for Government Developers
Proper Connections Development for Proper Domino Developers
Local storage in Web apps
HTML5 and CSS3 refresher

What's hot (20)

PPT
Wicket Introduction
PDF
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
PDF
Linguistic Abstraction for the Web
PDF
JavaOne 2011: Migrating Spring Applications to Java EE 6
PDF
Java EE 8 Recipes
PPTX
Getting Started with jQuery
PDF
JavaScript
PDF
HTML5 Refresher
PPTX
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
PPT
Java EE 7 (Hamed Hatami)
PDF
HTML5: the new frontier of the web
PPTX
Domain Driven Design using Laravel
PPTX
Amis conference soa deployment. the dirty tricks using bamboo, nexus and xl ...
PDF
FREE Sql Server syllabus
PDF
Utilizing JSF Front Ends with Microservices
PPT
Hybernat and structs, spring classes in mumbai
PPTX
A Groovy Way to Interface With Cascade Server
PDF
Modern development paradigms
PPT
7 Tips For Better JDeveloper Experience
PDF
Carlos Amador .Net Portfolio
Wicket Introduction
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
Linguistic Abstraction for the Web
JavaOne 2011: Migrating Spring Applications to Java EE 6
Java EE 8 Recipes
Getting Started with jQuery
JavaScript
HTML5 Refresher
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Java EE 7 (Hamed Hatami)
HTML5: the new frontier of the web
Domain Driven Design using Laravel
Amis conference soa deployment. the dirty tricks using bamboo, nexus and xl ...
FREE Sql Server syllabus
Utilizing JSF Front Ends with Microservices
Hybernat and structs, spring classes in mumbai
A Groovy Way to Interface With Cascade Server
Modern development paradigms
7 Tips For Better JDeveloper Experience
Carlos Amador .Net Portfolio
Ad

Viewers also liked (7)

PDF
Spring 2.5
PPT
Els DéUs óLíMpics En L’Art.
PDF
Web Applications of the future: Combining JEE6 & JavaFX
PPT
Rich Enterprise Applications with JavaFX
PPTX
JavaFX - Sketch Board to Production
PDF
JavaFX 2 Rich Desktop Platform
PDF
Building RIA Applications with JavaFX
Spring 2.5
Els DéUs óLíMpics En L’Art.
Web Applications of the future: Combining JEE6 & JavaFX
Rich Enterprise Applications with JavaFX
JavaFX - Sketch Board to Production
JavaFX 2 Rich Desktop Platform
Building RIA Applications with JavaFX
Ad

Similar to Appengine Nljug (20)

PPT
The 90-Day Startup with Google AppEngine for Java
PDF
Google Developer Days Brazil 2009 - Java Appengine
PDF
Java Support On Google App Engine
PDF
Developing, deploying and monitoring Java applications using Google App Engine
PPTX
Google appenginejava.ppt
PDF
Google App Engine - exploiting limitations
PPTX
Google app engine
PDF
Google App Engine
PDF
Software development - the java perspective
PDF
Google App Engine With Java And Groovy
PDF
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
PDF
Programming Google App Engine Build and Run Scalable Web Apps on Google s Inf...
PDF
Google Devfest 2009 Argentina - Intro to Appengine
PDF
Google app engine - Soft Uni 19.06.2014
PDF
Google App Engine for Java v0.0.2
PDF
Proud to be polyglot
PDF
An Introduction to Spring Data
PDF
Google App Engine for Java
PDF
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
PPT
Google App Engine for Java
The 90-Day Startup with Google AppEngine for Java
Google Developer Days Brazil 2009 - Java Appengine
Java Support On Google App Engine
Developing, deploying and monitoring Java applications using Google App Engine
Google appenginejava.ppt
Google App Engine - exploiting limitations
Google app engine
Google App Engine
Software development - the java perspective
Google App Engine With Java And Groovy
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Programming Google App Engine Build and Run Scalable Web Apps on Google s Inf...
Google Devfest 2009 Argentina - Intro to Appengine
Google app engine - Soft Uni 19.06.2014
Google App Engine for Java v0.0.2
Proud to be polyglot
An Introduction to Spring Data
Google App Engine for Java
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
Google App Engine for Java

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
CIFDAQ's Market Insight: SEC Turns Pro Crypto
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Monthly Chronicles - July 2025
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx

Appengine Nljug

Editor's Notes

  • #22: -Maak een nieuwe appengine applicatie -Run de applicatie lokaal -Pas het application id aan in de settings -Upload de applicatie -Bekijk in de browser -Doe een aanpassing -Bekijk opnieuw in de browser
  • #46: Demo 1: DataStoreServlet /datastoredemo Een speaker heeft talks /Speaker(1)/Talk(1) Een speaker en talk kan in dezelfde transactie worden opgeslagen Twee verschillende speakers kunnen niet in dezelfde transactie worden opgeslagen.
  • #56: Demo 1: DataStoreServlet /datastoredemo Een speaker heeft talks /Speaker(1)/Talk(1) Een speaker en talk kan in dezelfde transactie worden opgeslagen Twee verschillende speakers kunnen niet in dezelfde transactie worden opgeslagen.
  • #61: Demo 1: DataStoreServlet /datastoredemo Een speaker heeft talks /Speaker(1)/Talk(1) Een speaker en talk kan in dezelfde transactie worden opgeslagen Twee verschillende speakers kunnen niet in dezelfde transactie worden opgeslagen. Een speaker heeft ook collega&amp;#x2019;s. Collega&amp;#x2019;s zijn niet &amp;#x201C;owned&amp;#x201D; en daarom kan alleen de key worden opgeslagen ipv de entity zelf. Kijk naar speaker.addColleague en speaker.getCollegues
  • #65: web.xml /secure
  • #72: cron.xml demo.cron.ReportServlet
  • #87: http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine
  • #108: Creating and uploading an application