270 likes | 335 Views
Understand the core functionality, supported languages, and APIs of Google App Engine (GAE). Learn about serving web sites, storing data, and using other APIs like UI Toolkit, asynchronous tasks, caching, and more. Explore reasons to start with GAE, its limitations, and how it functions in a sandbox environment.
E N D
CS569 Selected Topics in Software EngineeringSpring 2012 GAE Overview
Start installation in parallel with this presentation • Oracle JDK 1.6 (already installed on Macs) • Eclipse Galileo • http://eclipse.org/galileo/ • GAE plugins • http://code.google.com/appengine/downloads.html
Google App Engine (GAE)is a Platform-as-a-service • Infrastructure-as-a-service (IaaS) • Virtual (and physical ) machines on demand • E.g., Rackspace • Platform-as-a-service (PaaS) • Scalable servers with rich but restrictive APIs • E.g., Google App Engine (GAE) • Software-as-a-service (SaaS) • Servers with customizable web apps you can lease • E.g., SalesForce.net
Google App Engine (GAE)core functionality • Serving up custom web sites (Servlets API) • Storing data for you (JDO and JPA APIs) • Other APIs • UI Toolkit (GWT) • Asynchronous tasks • Retrieving web content • Caching • Image processing • …
Reasons to start with GAE • Free to start • Uses a language you probably know • Integrated with tools you probably know • Provides exposure to cloud funkiness • No support for inner joins • Automatic load balancing • Non-DBMS transactions • Sandboxing
Languages supported by GAE • Java • This is what I will use in this class • Mainly thanks to its nice Eclipse integration • Python • Somewhat richer API and command-line tools • Feel free to use this instead of Java if you like • (But I do not know Python, FYI) • Go • New Google language with built-in concurrency • Feel free to use it (but FYI, I don’t know Go)
Still other languages • As long as you can compile it to Java 1.6-compatible bytecode • JRuby • Scala • Rhino-compatible JavaScript • … • Feel free to use these • I know JavaScript and have briefly used Rhino but haven’t used the Rhino compiler to Java
Serving up custom web sites • GAE implements the Java servlet specification • Your Eclipse project implements a web site • Servlets: • Handlers for URLs of the form “/myservlet” • An XML document maps URLs to servlets • JSPs: • Text files that mix HTML and Java • Automatically converted to servlets • Feel free to use either one
Storing data for you • Java Data Objects (JDO) • A standardized way of storing objects • Create an object, store it, load it later • No need to mess around with INSERT statements • Java Persistence API (JPA) • Another standardized way of storing objects • JPA is basically a refinement of JDO • As well supported in GAE as JDO • Low-level APIs • Which are more powerful and easier to misuse
Other APIs: UI Toolkit • Google Web Toolkit (GWT) • Define your application’s UI in Java • Code looks very similar to what you’d write to create a desktop GUI • Compiles to JavaScript • Support for multiple targets • Desktop browser • Mobile browsers • Available for you to investigate as a How-To
Other APIs: Asynchronous tasks • Very similar to “cron” jobs • Create a task • Pass it some parameters • Schedule to run at a certain time if you like • Put it on a queue • Very handy for… • Loading data • Generating reports • Performing sophisticated transactions
Other APIs: Retrieving web content • Your application can retrieve data from other servers • Retrieve XML from remote web services • Retrieve zip files, uncompress them, store data • Very handy for… • Loading data • Integrating with other systems
Other APIs: Caching • GAE provides a distributed RAM cache • Server RAM is copied to all the other computers • Very very fast data access (versus JDO) • Still can take advantage of using multiple servers • Caveat: it has only a limited capacity • You can’t cache everything • Stuff can disappear (similar to Java “weak references”) • Effective caching and asynchronous computation are two of the most important concepts for achieving high-performance cloud applications
A few of the other APIs • Image Processing • Good for manipulating photos • Channels • Persistent socket-like connection to browser • Emails • Implements the JavaMail specification • Can send attachments • XMPP • For sending messages between applications
Limitations • Functional • Due to the architecture • Sandbox • You can’t access all Java SDK APIs • Quotas and timeouts • You can’t use unlimited resources
Functional limitations • Data are copied and stored on many servers • Sometimes servers fail • Sometimes servers have inconsistent data • Certain data manipulations are not tractable • E.g., GAE cannot do DB table joins like you’re used to • Servers start and stop to meet your load • Servers might lose in-memory state at any time • You can’t write to an individual server’s files • You can’t have a server all to yourself
Sandbox limitations • No writing to file system or DBMS • Serialize to the data store via JDO instead • No spawning threads • Use asynchronous tasks instead • No killing the JVM • Just return from servlet; no need to kill anyone • No loading native code • Put it on another server, invoke via web service • … And several other less important limitations
Quotas and timeouts • Free tier (last time I checked) • Max request size: 32MB • Max response size: 32MB • Max handler time per server hit: 60 seconds • Max stored data: 1GB • Max outbound bandwith: 1GB/day, 56 MB/minute • Max incoming bandwidth: ditto • And many other limitations • If you want to raise quotas, pay $$ (optional)
Basic steps for creating app • Create new project in Eclipse • Implement, test browser-based app locally • Push to GAE and test remotely • Test + refine performance, reliability, security • Expose refined functionality via web services • Implement mobile app • Test + refine usability, security
Hello, world Creating a simple GAE application
A few words about the How-To • Part 1: Cloud platform • Can cover IaaS, PaaS, or Saas, as long as there’s a way to demonstrate the stuff below • Part 1A: Specify the steps required to install and configure the platform • Part 1B: Specify the steps required to read data from the browser and store the data away • Part 1C: Specify the steps required to retrieve data from its storage location and send to the browser
Suitable cloud platforms(feel free to suggest others) • Windows Azure (I have some free licenses) • Amazon EC2 • HP Cloud Services • RackspaceIaaS • SalesForceSaaS • Oracle Public Cloud • … more every day
More words about the How-To • Part 2: Mobile platform • Can be a binary platform or a web-based platform (i.e., can be for making native apps or for making web apps that look good on a mobile device) • Part 2A: Specify the steps required to install and configure the platform • Part 2B: Specify the steps required to retrieve an XML document from a remote server • Part 2C: Specify the steps required to display some text from some XML elements to the user
Suitable mobile platforms(feel free to suggest others) • Google Web Toolkit • jQTouch • PhoneGap • Adobe Air • Windows mobile SDK • Rhodes • … more every day
More information • Each How-To part only needs to explain how to use platforms on one operating system • Windows/Mac/Linux for cloud • iOS/Android/Blackberry/Windows for mobile • Probably should be only 6-10 pages long • You get to work on this in groups of ~ 4 people • Maybe working in pairs on cloud and mobile parts
Don’t turn this into a really big deal.An example… • These 3 pages from the GAE “Getting started” guide” would make a great Part 1 • http://code.google.com/appengine/docs/java/gettingstarted/installing.html • http://code.google.com/appengine/docs/java/gettingstarted/usingjsps.html • http://code.google.com/appengine/docs/java/gettingstarted/usingdatastore.html • These parts of the Titanium “Quick start” would make a great Part 2. • https://wiki.appcelerator.org/display/guides/Quick+Start • Mobile SDK Installation and Configuration • Installing and configuring Titanium Studio • Hello World! • And relevant pages from the API docs, e.g., Titanium.Network.HTTPClient, Titanium.UI.Label
Next steps for you… • As a group, start trying to install and configure a cloud platform for your How-To • Strongly encouraged • Buy the textbooks (available at bookstore) • Read GAE Book, chapters 1 and 2 this weekend • Bring your laptop to every class