Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Cloud Computing, CS596-015 Google App Engine. Introduction Google App Engine Components :  Programming Languages and Runtime / Sandbox  Datastore.

Similar presentations


Presentation on theme: "1 Cloud Computing, CS596-015 Google App Engine. Introduction Google App Engine Components :  Programming Languages and Runtime / Sandbox  Datastore."— Presentation transcript:

1 1 Cloud Computing, CS596-015 Google App Engine

2 Introduction Google App Engine Components :  Programming Languages and Runtime / Sandbox  Datastore  Services/APIs  Java Persistence API  Memcache  Fetching URLs and Web Resources  Sending & Receiving Mail and Instant Messages  Task Queues and Scheduled Tasks  Web-based Admin Console  SDK Deploying & Managing Applications Things that the App Engine doesn’t Do … Yet Summary and Conclusions 2 Outline

3 3 Introduction

4 4 Google App Engine: Introduction - Challenges Building Web Apps

5 Idle capacity Software patches & upgrades License fees Lots of maintenance Traffic & utilization forecasting Upgrades 5 Google App Engine: Introduction - Practical Considerations Google App Engine does the difficult work for you

6 App Engine is a Web application hosting service You build & test your app Then upload your app to Google App Engine runs everything No need to worry about machines, network, storage, scalability, etc. 6 Google App Engine: Introduction

7 By “web application,” we mean an application or service accessed over the Web with a web browser by many simultaneous users You pay only for the resources you use; no monthly fees or upfront charges Google App Engine provides two possible runtime environment (Java VM, Python) and fully support Google Web Toolkit (GWT) Google App Engine supports static file servers, away from the Application Servers where the Datastore is used to store data while serving HTTP request for future need  Datastore stores the data in one or more datastore entities. An entity has one or more properties, each has a name (one of named kind) and a value based on several value types  Datastore query returns zero or more entities of a simple kind  App Engine provides a set of indexes for simple queries, based on which properties exists on entities of a kind  When an App creates new entities and when updating existing ones, the datastore updates every corresponding index 7 Google App Engine: Introduction – App Engine Components

8  To support many clients attempting to R/W the same data simultaneously, App Engine ensures all updates to an entity successed or the entire updates fail; an update of a single entity occurs in a transaction  When an App calls the Datastore to update an entity, controls does not return to the application until the transaction succeeds or fails  An App can bundle multiple datastore operations in a single transaction, i.e., start transaction….. Commit transaction Google App Services are the datastore’s relationship with the runtime environment. An App uses an API to access a supported service. These services are self scaling independent from the language runtime environment. These services include Memcache (K/V short term store), URL fetch, Mail Service, task queues & Cron job, etc. Developer tools: Google provides free tools (SDK for different languages/OS) for developing App Engine application in Java (Java SDK as plug-in for Eclipse) or Python (Python SDK in the form of GUI application for Windows & Mac OS) Administrative Console: needs to creates an administrative acct and set up the application on the App Engine. You sign to the Administrative Console using your Google account 8 Google App Engine: Introduction – App Engine Components

9 9 Google App Engine: Introduction – Scalable Infrastructure

10 10 Programming Languages & Runtime / Sandbox

11 11 Google App Engine Components: Programming Languages & Runtime/Sandbox

12 12 Google App Engine Components: Programming Languages & Runtime/Sandbox Alternative API/Runtime are available Python: Based on Python runtime is based on V 2.7.2 Extremely rapid development Very low barrier of entry Simple but yet robust syntax Rich library of packages/modules App Engine’s 1s language API Java: Ubiquitous in Enterprise computing Adheres to Java servlet standard & JSP Includes Java SE Runtime Environment (JRE) 6 platform Access to most App Engine services using Java APIs including: Java Data Objects (JDO), Java Persistence API (JPA), JavaMail API, Memcache, URL fetch service, etc. Rich library of packages/modules Eclipse Plug-in support Alternative language support such as Javascript, Ruby, Scala, etc.

13 13 Google App Engine Components: Programming Languages & Runtime/Sandbox Flexible Alternative

14 14 Google App Engine Components: Programming Languages & Runtime/Sandbox Alternative API/Runtime are available

15 Extended Language Support through JVM: Java Scala Jruby (Ruby) Groovy Quercus (PHP) Rhino (JavaScript) Jython (Python) 15 Google App Engine Components: Programming Languages & Runtime/Sandbox

16 The Sandbox:  Limited access from application to the underlying OS  Sandbox isolates your application in its own secure, reliable environment that is independent of the hardware, OS, and physical location of the web server  Application can access other computers on the Internet through the provided URL fetch and email services  Other computers can only connect to the application by making HTTP or HTTPS requests on the standard ports  Applications cannot write to the file system in any of the runtime environments  An application can read file, but only files uploaded with the application code  Application uses the App Engine datastore, memcache or other services for all data that persists between requests 16 Google App Engine Components: Programming Languages & Runtime/Sandbox

17 The Sandbox:  Python 2.7 environment allows bytecode to be read, written, and modified  Application code only runs in response to a web request, a queued task, or a scheduled task, and must return response data within 30 seconds in any case  A request handler cannot spawn a sub-process or execute code after the response has been sent  Sandboxing allows App Engine to run multiple applications on the same server w/o the behavior of one application affecting another  Runtime environment limits the amount of clock time, CPU use, and memory a single request can take  App Engine runtime ensures stricter limits to applications that use up more resources to protect shared resources from “runaway” applications 17 Google App Engine Components: Programming Languages & Runtime/Sandbox

18 18 Datastore

19 Many scalable web applications use separate systems for handling web requests and for storing data Request handler, which may be served on one of many machines, behave as if it is stateless even though it needs to interact with a data store to fetch/update the application state. Such datastore is stateful by definition The App Engine let the application interact with an abstract model that hides the details of managing the pool of datastores Entities, Keys, and Properties:  Datastore is thought of as object database  An object is an entity  Each object has a key to uniquely identify and fetch the object across the system. Key is 19 Google App Engine Components: Datastore: Datastore Entities

20  Once a key is created it cannot be changed  The entity data is stored in one or more properties; each property has name and at least one value (i.e., can’t be zero value), and each value is one of a set of data types. A property can have multiple values (multivalued properties) of different data types  For Java, App Engine supports two standard APIs for the Databases: Java Data Objects (JDO) and Java Persistence API (JPA). Using these APIs make the application database independent (could be RDBMS or object database, etc).  These APIs translate to App Engine datastore concepts:  Classes are kinds  Objects are Entities  Fields are properties 20 Google App Engine Components: Datastore: Datastore Entities

21  JDO and JPA are built on top of low-level API for the App Engine Datastore  You must use the low-level API to manipulate entities with properties of unknown names or value types  You can use the low level API to build your own data management layer  Each value data type supported by the datastore is represented by a primitive type in the language for the runtime or a class provided by the API 21 Google App Engine Components: Datastore: Datastore Entities

22 Data is useful because you query them Significant difference between App Engine and traditional database is that when user asks a query, App engine does not go the data records and determine the answer. Instead, the App Engine precompute the answers and when asked query, it searches for the answer in a list of possible answers! As a result, answer is very quick This is possible because the App Engine maintains an index for every query the application can perform! List of answers are indexes The above indexing strategy has drawback; the datastore’s built-in query engine is weak compared to RDBMS and is not suitable for sophisticated data processing but rather is adequate for web applications, i.e., calculate the answers to known questions when the data is written so query response would be fast 22 Google App Engine Components: Datastore: Datastore Queries (GQL)

23 Given a key your can retrieve an entity from the datastore In most cases applications do not know the key but rather has only a general idea about criteria that it needs entities that meet To extract such entities, a query include:  The kind of entities to query  Zero or more filters (criteria that property values must meet for an entity to be returned)  Zero or more sort orders that determine the order in which results are returned based on property values A query based on property values can only return entities of a single kind It is also possible to perform limited set of queries on entities regardless of kind Query Results and Keys: when retrieving query results, the datastore returns the full entity with all its properties; it is not possible to query/return a subset of the entity properties 23 Google App Engine Components: Datastore: Datastore Queries (GQL)

24 GQL: Python and Java runtime environment provide several ways to formulate queries; they all do the same thing They all return entities (or keys for entities) whose keys and properties meet some filter criteria – optionally returned in sorted order Example: SELECT * FROM Player WHERE level > 5 AND level < 20 ORDER BY level ASC, score DESC The above query retrieve all player entities whose “level” property is an integer between 5 and 20, sorted by level in ascending order, then by score in descending order From the administrative console, you can use GQL to browse the contents of the datastore The Java Query API: if you are using JPA or JDO APIs, you will use the query facilities of those interfaces to perform datastore queries 24 Google App Engine Components: Datastore: Datastore Queries (GQL)

25 Example: import com.google.appengine.api.datastore.DatastoreService; import com.google.appengine.api.datastore.DatastoreServiceFactory; import com.google.appengine.api.datastore.Entity; import com.google.appengine.api.datastore.PreparedQuery; import com.google.appengine.api.datastore.Query; //…………. DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); Query q = new Query(“Book”);// Book is the name of the kind q.addFilter (“copyrightYear”, Query.FilterOperator.LESS_THAN_OR_EQUAL, 1950); q.addSort(“title”); PrepareQuery pq = ds.prepare(q); for (Entity result : pq.asIterable() ) { String title = result.getProperty(“title”); …. } 25 Google App Engine Components: Datastore: Datastore Queries (GQL)

26 26 Google App Engine Components: Namespace Datastore

27 With web applications, many users access/update data concurrently; needs transactions to maintain data consistency and perform multiple operations atomically Web applications are at odds with transactions: response to operations should be independent of how much data we have or how it is distributed across servers. Being slow will block others from accessing shared which will impact the overall system throughput! App Engine provides transactions with strong consistency (other sees the changes once the transaction complete vs. eventual consistency) but with low overhead; this is done by limiting the scope of a transaction and leverage Google’s BigTable A single transaction can only R/W to entities that belong to a single entity group. Every entity belongs to a single entity group (default is group of your own). When an entity is created it is assigned to an entity group permanently With concurrent transactions, datastore treats each group independently when applying concurrent transactions; 2 transactions using different groups can execute independently w/o harm – maximize throughput 27 Google App Engine Components: Datastore: Datastore Transactions

28 28 Services / APIs

29 29 Google App Engine Components: Services/APIs

30 JPA needs a configuration file to specify desire to use the App Engine implementation of JPA JPA serves as a data modeling layer. It describes the structure of the object in terms of Java classes JPA can be used to define/enforce consistent data schema on top of the App Engine’s schemaless datastore Both JPA and JDO (Java Data Objects) implementations use the open source DataNucleus Access Platform product You define data classes in POJO. Use annotations to tell JPA which classes to persist to the datastore, and how to store its members JPA lets you use an XML file instead of annotations to describe how to persist data classes Fields of the Java class become the entity properties. One of defined set of types can be used as the field type; field can have serializable object as a single property JPA uses embedded data objects & relationships between entities using fields JPA API for transactions is similar to the datastore API but was designed to work with RDBMS and supports global transaction; optionally you can use App Engine extensions to JPA to manage entity groups 30 Google App Engine Components: Services: Java Persistence API (JPA)

31 Most high-performance web applications use a memory cache App Engine provide distributed memory cache service (memcache) which stores K/V pairs. You can set/get a value for a key & value can be up to megabyte in size & key can be up to 250 bytes Updating a value is an atomic operation (not transaction support like the datastore) Ability to increment/decrement value atomically Typically memcache is used to cache the datastore entities by their keys When entity is updated in the datastore, you should attempt to update memcache as well, no transactional update to both – one may successed and the other fails! Memcache can be used for datastore queries, and web services calls made with URL fetch You can specify name space for memcache key with any setter or getter calls. Namespace is meant to avoid key collisions Cache expiration – you can tell memcache to delete/evict a value automatically after a period of time when you set/update the value 31 Google App Engine Components: Services: Memcache

32 32 Google App Engine Components: Namespace API - Memcache

33 App Engine can connect to other sites on the Internet to retrieve data and communicate with web services It does not do that by opening a connection to the remote host but rather through a scalable service called the URL Fetch service This takes the burden of maintaining connections by the app server and ensures that resource fetching performs well regardless of how many request handlers are fetching resources simultaneously Fetching URL supports both subset of HTTP operations (GET, POST, PUT, HEAD, DELETE) and HTTPS URL Fetch service cannot fetch URL that maps to the request handler doing the fetching The outgoing request can contain URL parameters, request body, and HTTP header Both Python & Java runtime environments include interfaces to the URL Fetch service. These interfaces implement synchronous URL fetching, as well as asynchronous interface that allows the app to trigger fetch request, do other work, and retrieve results when the request is ready 33 Google App Engine Components: Services: Fetching URLs and Web Resources

34 App Engine can communicate with the outside world in 3 ways:  HTTP requests using URL Fetch service  App can send/receive email messages by calling the Mail service  Instant Messaging (XMPP-compatible chat service) including Google Talk and any Jabber server An app might send email to notify users of system events or the actions of other users, confirm user actions, follow up on long term user actions, or send system notification to administrators App can use XMPP (useful for chat interfaces) to push real-time updates to clients Sending email and chat messages is similar to initiating HTTP request Receiving email and chat messages is similar to receiving HTTP response Every app has its own set of email & XMPP addresses, based on its application ID; currently App Engine does not support email & XMPP addresses with custom domains 34 Google App Engine Components: Services: Sending & Receiving Mail and Instant Messages

35 App Engine is optimized for handling web requests (small amount of work that run in a stateless environment) with very fast response back to the client Other web applications don’t fit the above model, instead you can write the request to persistent store, respond immediately back to the user, and do the work in the background within seconds/minutes. The 1 st model is appropriate for READ and the 2 nd is for Update entities in datastore 3 rd model is to get work done independently of user actions (Cron jobs) App Engine support both three models: task queues (2 nd model) and scheduled tasks (3 rd model). Scheduled tasks are not retried, but a scheduled task can use a task queue to take advantage of the retry behavior In the above models, task is a request to request handler. The task specifies the URL path of the application to be called with optional data passed by the App Engine to the request handler URL of a networked application to perform a task is known as a web hook App Engine invokes a request handler for a task in the same environment as it does a handler for a user request, i.e., task handler runs with the same sandbox and resource restrictions including 30 sec deadline 35 Google App Engine Components: Services: Task Queues and Scheduled Tasks

36 36 Web-based Admin Console

37 37 Google App Engine Components: Web-based Administration

38 Application Monitoring: 38 Google App Engine Components: Web-based Administration App Engine Dashboard

39 Application Monitoring: 39 Google App Engine Components: Web-based Administration App Engine Health History

40 40 SDK

41 41 Google App Engine Components: SDK

42 42 Google App Engine Components: Java SDK as Plug-in for Eclipse

43 43 Deploying & Managing Applications

44 Uploading your application to App Engine is easy: just click a button or run a command, then enter your acct email and password. All your code, configuration, and static files are sent to the App Engine No worries about server software, how server s connect to services, scalability issues, system software maintenance, etc. App Engine support application versioning. You can test new versions before making it public, revert to previous version, and migrating the datastore & service configuration for the app from one version to another Service configuration is shared across all versions of an app, including datastore indexes, task queues, and scheduled tasks. When you upload the app, the service configuration files on your computer are uploaded as well Service configuration is separate from application configuration, which includes URL mapping, runtime environment selection and inbound service activation. App configuration is bound to a specific app version App Engine provides facilities to inspect app performance during runtime as well maintenance tasks (Administrative Console) 44 Google App Engine: Deploying & Managing Applications

45 45 Things that the App Engine doesn’t Do … Yet

46 App Engine does not support secure connections to custom domains, but supports secure connections to appspot.com only App Engine can use URL Fetch service to make HTTPS request to another site, but App Engine does not verify the certificate used on the remote server An app can receive incoming mail and XMPP chat messages at several addresses; none of these addresses can use a custom domain name App Engine does not host long-running background processes. Task queues & scheduled tasks can invoke request handlers outside of a user request and can drive batch processing; this is different from full-scale distributed computing tasks App Engine does not support streaming or long-term connections App Engine only support web requests via HTTP/HTTPS, email and XMPP messages via the services; does not support other connections’ types App Engine does not support full-text search queries 46 Google App Engine: Things that the App Engine doesn’t Do … Yet

47 47 Summary and Conclusions

48 Current Status Always free to get started 1 GB data storage 1 GB/day bandwidth (each for incoming/outgoing) ~5 M pageviews/month 6.5 CPU hours daily Email 2K recipients, 650K IM & 650K URL fetches Purchasing additional resources Outgoing bandwidth $0.12/GB Incoming Bandwidth $0.10/GB CPU Time $0.10/hr Storage Data $0.15/GB/month Recipients Emailed $0.0001$ Future More features More robustness Additional libraries 48 Google App Engine: Summary and Conclusion:

49 Google App Engine is meant to serve web applications, and is built over scalable infrastructure It consists of set of components: multiple languages runtime/sandbox environment, Datastore, Services, Web- based Administrative Console, and SDK App Engine supports rich set of services including: JPA, JDO, Memcache, URL Fetch, send/receive mail and instant messages, and task queues & scheduled tasks The App Engine relieves the user from many concerns including scalability, system software maintenance, etc. App Engine supports application versioning Still App Engine has few limitations 49 Google App Engine: Summary and Conclusion:

50 50 END


Download ppt "1 Cloud Computing, CS596-015 Google App Engine. Introduction Google App Engine Components :  Programming Languages and Runtime / Sandbox  Datastore."

Similar presentations


Ads by Google