Google App Engine PaaS Application Development
Lecture notes (YouTube Part 1) (YouTube Part 2)
Recommended Reading/Viewing
- Java Google App Engine (GAE)
- Getting started with App Engine and Google APIs
- Go through the Google App Engine Java API to learn about other API options.
- Intro to REST Web services with JAX-RS
- Brief Intro to REST
Introduction:
- Set up an App Engine account and AppID for yourself. Read/Implement the steps on this page under "Getting a project ID" ONLY.
- Set up Java 7, maven, the App Engine SDK, and deploy a Hello World sample app on App Engine and locally via the App Engine development server using these steps and links.
(Note that I use cs263 as my projects directory herein)
- Tutorial 1: Complete the steps above. Ensure you can do all of this via the command line tools. Setup an IDE (e.g. Eclipse has an App Engine plugin) if you prefer and ensure you can deploy to App Engine and to the local Development Server (and update a running app) via the IDE. The requirements for the assignment are to do so via the command line tools only.
Other resources
- Many resources are provided on the Asgn 1 document/steps page. Try here first.
- App admin details on your app can be found here. Click on the appID and pull down the menu (3 parallel lines) in top left. Select Logging to see your logs, App Engine to see your app's usage and quota information, Datastore to see the data the app has saved (click Entities on left, you can also delete the data here directly; Indexes on left show your indexes (needed for debugging in the future perhaps)).
- Other resources to help you get started but are not required for preparation of this class can be found under "Language/Framework" on the projects page.
- Setting up Eclipse:
Application Development and Cloud SDK Use: Required Reading
- Datastore overview. Please use the low-level API.
- Memcache overview
- GAE Task Push Queue API. Here is the GAE overview.
- REST/Jersey Tutorial
- Jersey is a framework implements JAX-RS Specification for developing REST web services in Java. It simplifies and replaces Java Servlets. Jersey uses a single web.xml entry (org.glassfish.jersey.servlet.ServletContainer) to intercept all REST calls and forwards them to your plain-old-java objects (POJOs). You add Java annotations to your POJO classes to tell Jersey where to route things for REST calls. Jersey also takes care of marshalling and unmarshalling request and response data. Jackson extends Jersey's HTML, XML, and Text support for requests and responses with JSON support. Jersey+Jackson eliminate the need for using Java Servlets.
- JAX-RS Deployment
- javax.wx.rs API
- Jersey Documentation
Complete the following tutorials and exercises
Exercise 1:
- Implement this tutorial and proceed through each step/page of the entire tutorial.
- Upon tutorial completion ensure that your code works for both the local dev server and on App Engine.
Important Info:
- Java application classes will be in src/main/java/...
- Project configuration file is src/main/webapp/WEB-INF/appengine-web.xml
- Deployment configuration file is src/main/webapp/WEB-INF/web.xml
- By default, any file in src/main/webapp/ or in a subdirectory other than WEB-INF/ that has the file suffix .jsp is automatically mapped to a URL path consisting of the path to the .jsp file, including the filename. E.g. file XXX.jsp will be mapped automatically to the URL /XXX.jsp.
- Do NOT use the word "key" as a property name anywhere (datastore, request/response, memcache) -- change it if its in the tutorial!
- Make sure and read the entire section on Indexes (under the Creating required indexes section when you reach there).
- Always ensure that your project works on the local dev server and that you've added all of your indexes before uploading to App Engine (mvn appengine:update).
- Note that the cloud datastore is eventually consistent -- which means you will likely NOT see the data you just added ("put") for a bit of time. Click refresh to retry. This is especially true for the deployed app in App Engine!
-
If you are having trouble with bugs (deployment/runtime errors), do a clean build and retry (dev server first) uploading/testing: mvn clean install
Note that this cleans out your datastore data and indexes so you will need to regenerate the indexes (manually or by running the dev server successfully) before uploading to App Engine. - App admin details on your app can be found here. Click on the appID and pull down the menu (3 parallel lines) in top left. Select Logging to see your logs, App Engine to see your app's usage and quota information, Datastore to see the data the app has saved (click Entities on left, you can also delete the data here directly; Indexes on left show your indexes (needed for debugging in the future perhaps)).
- If you get a 500 Server error when accessing your app, there are many possible reasons:
- You didn't wait long enough after app deploy/upload (could be many seconds).
- You have a bug in your app
(the local dev server does not behave exactly like App Engine so even if it works locally this may happen). Download or view your logs (See App admin details above) for errors in your app. Download command:
appcfg.sh request_logs target/guestbook-1.0-SNAPSHOT mylogs.txt
Exercise 2:
- Create a new project and project directory in your projects/gae directory.
- Write a web app that uses Datastore, Memcache, and Push queues (TaskQ). Then extend this exercise to convert the datastore accesses (currently in Servlets) to a JAX-RS REST interface.
Follow the instructions at this link for steps! (Note that I use cs263 as my projects directory herein)
Resources and Help
- Datastore overview. Read through this entire doc to understand how the Datastore works. Use the Low Level API to access it. The maximum size of any single entity is limted to 1MB (check/test all stores to verify that this limit is adhered to). Be careful when testing on App Engine not to exceed your quotas.
To clean up the data in your datastore, run the app (locally) and navigate to http://localhost:8080/_ah/admin. Click on view Entities and select them and click Delete at the bottom. You can do something similar in the admin page of App Engine for your deployed app. The App admin pages for your app can be found at the admin page. Click on the appID and pull down the menu (3 parallel lines) in top left. Select on Datastore to see the data the app has saved (click Entities on left, you can also delete the data here directly).
Check that all of your indexes are listed via the Indexes tab (mvn clean install clears them so if you did this and didn't run in the dev app server locally before uploading, App Engine won't receive them and your app will not work). See this link under Creating required indexes and this link under Uploading your Application for more info.
- Getting Started with Memcache. Read through this entire doc to understand how Memcache works. Use the default/shared memcache (not dedicated) and the Low Level API (not JCache).
Your memcache stats can be viewed via the Admin Console for your appID: click on App Engine (in top left menu icon) then MemCache. You can search for keys here, flush the cache, and find other details about cache use.
Production Cloud Application Development: Now you should understand the App Engine model and deployment methodology. Develop large scale applications (each with their own appID -- in open source available on github) that use the APIs Datastore (low-level), Memcache, and Task Queue. Mirror customer application functionality so that the applications are realistic and production quality. Test them fully and provide a set of tests that access the REST APIs of each for easy access by analyses, performance monitoring, and use/integration by the PaaS APM system. Set up synthetic tests that exercise the applications using realistic workloads.
Some application ideas and other APIs can be found on the projects page.