Demos created for public lecture in VarnaLab (19 June 2013)
Online demos : Google App Engine Presentation - 19.06.2013
Services :
Hello App Engine
User Service - Authenticaton
Blobstore
Task Queue
Datastore - Entities
Datastore - Queries and Indexes
Datastore - Transactions
Youtube video : http://www.youtube.com/watch?v=-4BbrINScYI
6. What is Google App Engine(GAE) ?
● Google’s platform to build Web Applications on the
cloud
● Dynamic Web server
● Transactional Data Store Model
7. Why GAE?
● Automatic scaling and load balancing
● Lower total cost of ownership
● Web administration console & utilities
● Enhances developing & deploying of web applications
● Multilanguage support (Java, Python, GO, PHP)
● Fully featured SDK for local development
● Rich set of Google APIs
● Secure environment (Sandbox)
15. GAE Services
● Developers are focused on implementing custom
business logic
● Wide range of services available
○ User service
○ Blobstore
○ Task Queues
○ Mail Service
○ Image
○ Memcache, etc
16. User Services
● Provides a simple API for authentication and
authorization
○ Detect if a user is signed in App
○ Detect if a user is an admin
● Works in combination with web.xml security settings
● Three authentication options
○ Google Account
○ Google Apps domains users
○ OpenID - experimental
18. Blobstore Services
● The Blobstore Service allows your application to serve
binary objects, larger than the entities in the Datastore.
● Blobs are created by uploading files through HTTP
○ The upload and store logic is handled by the
Service
○ The HTTP request is redirected to a dispatcher, by
specified by the developer
20. Task Queues
● Task Queues allow the application to perform work,
initiated by a user request, outside of that request.
● Suitable for triggering background processes
● Different types of queues
○ Push queues
○ Pull queues
○ REST reference
22. Storing Data
● GAE provides different ways of storing application
data
○ Datastore - provides a noSQL schemaless object
datastore with a query engine and transactions
○ Google Cloud SQL - provides a relation database,
based on MySQL
○ Google Cloud Storage - provides a storage service
for objects and files up to terabytes in size
23. Storing Data (2)
● Watch a video demonstration comparing the
Master/Slave and High Replication Datastores.
● Watch a video demonstration comparing SQL vs
NoSQL: Battle of the Backends
25. Datastore
● Based on Google Big Table
● NoSQL object storage
● Schemaless
● No joins and aggregations
● Hierarchical
● Queries must rung against existing indexes
● Access API using an instance of the DatastoreService
Class
26. Datastore - Types
● There are two different Datastore types we can use :
○ High Replication Datastore(HRD)
○ Master / Slave Datastore
27. Datastore - Types (HRD)
● High Replication Datastore(HRD) is replicated across
multiple data centers
○ Highest level of availability
○ Higher latency on writes
○ Query data is eventually consistent
28. Datastore - Types (Master/Slave)
● Master / Slave Datastore - one data center holds
master copy of the data. Data in the master is
asynchronously copied to the slaves.
○ Periods of unavailability
○ Low latency
○ Highest level on consistency
29. Datastore - Entities
● Entities - contain key/value pairs
● Each entity has a unique key comprised of :
○ The kind of the entity (Example : Person, Human)
○ An identifier for the the individual entity that can be
:
■ a key name string
■ an integer numeric ID
○ An optional ancestor path locating the entity in the
Datastore hierarchy
30. Datastore - Entities (2)
● The Entity class
● Creating an Entity
○ Create an instance of the Entity class
○ pass it to the DatastoreService.put() method
● Retrieving an Entity
○ Pass an entity Key to the DatastoreService.get()
● Updating an Entity
○ No different between creating and updating
● Deleting an Entity
○ Pass an entity Key to the DatastoreService.delete()
method
32. Datastore - Queries
● Queries retrieve a number of entities that meet a
specified set of conditions from Datastore
● Queries can specify :
○ Entity kind
○ Zero or more filters, based on entity properties
values
○ Zero or more sort order descriptions
○ Default or you can set a limit clause
● Rung against an existing index
33. Datastore - Queries (2)
● The Query Class
○ Pass entity kind as constructor parameter
● Adding filters - Datastore Filter Class and setFilter
method
○ Property name
○ Operator - a value, defined in FilterOperator
○ Value - the value to compare to
● Sorting - addsort() method
○ Property name
○ Sort order - a value, defined in SortDirection
34. Datastore - Queries (3)
● Fetching results
○ Pass a Query instance to the DatastoreService.
prepare() method
○ Use one of the methods of the PreparedQuery
instance, returned as a result
○ Refine your results using FetchOptions
35. Datastore - Indexes
● Similar to relational database indexes
● Automatic indexed created for some queries
● Other queries require indexes to be manually created
in the datastore-indexes.xml. They include :
○ Queries with multiple sort orders
○ Queries with a sort order on keys in descending
order
○ Queries with one or more inequality filters on a
property and one or more equality filters on other
properties, etc.
36. Datastore - Indexes
● Similar to relational database indexes
● Automatic indexed created for some queries
● Other queries require indexes to be manually created
in the datastore-indexes.xml. They include :
○ Queries with multiple sort orders
○ Queries with a sort order on keys in descending
order
○ Queries with one or more inequality filters on a
property and one or more equality filters on other
properties, etc.
38. Datastore - Transactions
● Transactions - a set of atomic operations
● Transaction type :
○ Default transactions - work on a single entity
○ Cross - group (XG) transactions - work on different
entity groups
● Getting a Transaction instance - DatastoreService.
beginTransaction()
● Manipulating a transaction
○ Transaction.commit() - confirm changes
○ Transaction.rollback - rollback changes, restore
previous state