Tutorial: Google App Engine


Overview of GAE

Google App Engine or GAE or App Engine is a public platform as a service (PaaS), one of the service models of cloud computing as described by the NIST definition of Cloud computing. GAE was developed by Google and was made available for public usage in 2008. Its stable release is 1.8.2 in July 2013. GAE is written in Python, Java, Go, and PHP. GAE provides facility to develop and host applications in resources managed by Google. Entry level usage has certain restriction with free tier. App Engine provides free tier to get started. All applications can use up to one GB of storage and sufficient CPU and bandwidth to support a resourceful application serving around five million page views a month.

GAE supports Java, Python, Go, and PHP. It also supports other JVM languages such as Clojure and PHP via a special version of Quercus, JRuby, Groovy, and Scala by extension. GO and PHP are not in full fledged mode, they are in experimental phase. GAE makes it simple to build an application that is highly available and reliable even under huge demand with vast amounts of data requests. It provides automatic scaling and load balancing, persistent storage, full support for common web technologies, APIs for authenticating users and sending email using Google Accounts, full featured simulation of Google App Engine on your local development environment, scheduled tasks, and task queues.
In GAE, applications run in a secure environment that provides limited access to the core resources. This sandbox isolates applications in its own highly available, reliable, secure environment that is independent of the compute resources.
  1. Only HTTP request execution is allowed
  2. Only pure-Python can be uploaded
  3. Does not support session affinity
  4. Access to virtual file systems only and read-only access available to the filesystem on App Engine
  5. Does not support domains without www such as http://clean-clouds.com
  6. Java applications may only use a subset of the classes from the JRE standard edition
  7. In-equality filters on two or more entity properties per query is not allowed in datastore
  8. Minimum request processing time is 60 seconds

 

Language
Supported Framework
Java
Spring Framework, Apache Struts 1, Struts 2 with some changes, Servlet 2.5 technology using the open-source Jetty Web Server, JavaServer Faces with some changes. Java runtime environment uses Java 7. The limits of the sandbox environment are implemented in the JVM.
Python
Framework that supports the WSGI using the CGI adapter can be used to create an application on GAE. Django, GAE framework, CherryPy, web2py and webapp2, Flask, Pyramid, etc. It includes the Python standard library with limitations imposed by sandbox environment. webapp2 Python web application framework is available for creating applications with ease.

Data Storage in GAE

Option
Description
GAE Datastore
·         Distributed NoSQL service
·         Entities have a set of properties that support retrieval of Entities with specific requirements
·         Schemaless Entities
·         Python datastore and Java JDO/JPA interfaces interface are used for applying and enforcing datastore structure within application
·         Supports query engine and transactions
·         ACID transactions and efficient concurrency control
Google Cloud SQL
·         Fully managed relational database service in Google’s cloud
·         Capabilities of a popular MySQL database
·         Administration, Management, and Monitoring of Database
·         Built in backup, recovery and patch management as it is managed by Gogle and not users
·         Built in replication across multiple geographic regions
·         GUI to create, manage, configure, and monitor your DB instance
·         Many options for configuration are available
Google Cloud Storage
·         RESTful service for storing, managing and accessing data with web-based interface
·         Reliable, Highly Available, Scalable Object Store
·         Data replicated across multiple data centers.
·         Read-your-writes data consistency
·         Support to objects can be terabytes in size, resumable uploads and downloads
·         OAuth 2.0 Authentication
·         Efficient  access controls for individuals, projects and group-level
·         Authenticated uploads and downloads
·         Project, Buckets-Containers, and Objects-Data are basic building blocks of data

Setup Eclipse and Configure Google Plug-in for Eclipse

Download Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/
Install Google Plug-in for Eclipse and follow instructions given at: http://code.google.com/eclipse/docs/install-eclipse-3.6.html
55.1 GAE Plugin Installation in Eclipse

 

Figure 1– GAE Plugin Installation in Eclipse
Next -> Review Items to be installed
Next -> Review Licenses – Select the radio button – I accept the terms of License Agreement – Click Finish
It will take some time to install GAE environment in your local system.
Click New-> Select Google -> Select Web Application Project
55.2 Google Web Application Project

 

Figure 2– Google Web Application Project
Deselect Google Web Toolkit from Google SDKs Section
55.3 Google SDK settings for Web Application

 

Figure 3– Google SDK settings for Web Application
Click Finish
55.4 Web Application Structure for GAE

 

Figure 4– Web Application Structure for GAE
It is a normal web application structure and the only difference is appengine-web.xml
Table 1– appengine-web.xml Structure
<?xml version=”1.0″ encoding=”utf-8″?>
<appengine-web-app xmlns=”http://appengine.google.com/ns/1.0″>
  <application></application>
  <version>1</version>
  <!–
    Allows Google App Engine to send multiple requests to one instance in parallel:
  –>
  <threadsafe>true</threadsafe>
  <!– Configure java.util.logging –>
  <system-properties>
    <property name=”java.util.logging.config.file” value=”WEB-INF/logging.properties”/>
  </system-properties>
  </appengine-web-app>
Now just open http://localhost:8888in browser
55.5 Local Environment of GAE
Figure 5– Local Environment of GAE
Click on GAETest to run it in local environment
55.6 Execution of GAE Application in Local E
Figure 6– Execution of GAE Application in Local Environment
Deploy Sample Hello, Open Source For You web application on GAE
55.7 Deploy Application to GAE from Eclipse

 

Figure 7– Deploy Application to GAE from Eclipse
To deploy it on GAE, Authentication is required.
Provide username and Password in a new window.
Accept the terms of service and privacy policies.
If Application ID is not set then Deployment process will give error: “GAETest does not have an application ID”
To create an application Id -> Open https://appengine.google.com Login and Create New Application ID
55.8 Create Application Identifier for GAE A

 

Figure 8– Create Application Identifier for GAE Application
Click on Create Application. It will give message “Application Registered Successfully” if all goes well.
To proceed further, Click on the project settings link in the same dialog box.
55.9 Provide Application Identifier in Eclipse
Figure 9– Provide Application Identifier in Eclipse Properties
Click ok and Application ID error will be solved. Now Click on Deploy.
55.10 Deploy Project to GAE

 

Figure 10– Deploy Project to GAE
Once the deployment Process will complete, Console output will be like:
Table 2– Deployment Output from Eclipse
———— Deploying frontend ————
Preparing to deploy:
      Created staging directory at: ‘C:UsersadminAppDataLocalTempappcfg1977774409461224969.tmp’
      Scanning for jsp files.
      Scanning files on local disk.
      Initiating update.
      Cloning 2 static files.
      Cloning 23 application files.
Deploying:
      Uploading 3 files.
      Uploaded 1 files.
      Uploaded 2 files.
      Uploaded 3 files.
      Initializing precompilation…
      Sending batch containing 3 file(s) totaling 4KB.
      Deploying new version.
      Closing update: new version is ready to start serving.
      Uploading index definitions.
Deployment completed successfully
Now let’s verify the GAE dashboard and verify the status of newly deployed application:
55.11 Application Status in GAE Dashboard

 

Figure 11– Application Status in GAE Dashboard
Let’s run the application:
Figure 12 – Available Servlets for an App in GAE
55.13 Web Application in GAE Environment
Figure 13 – Web Application in GAE Environment

GAE vs AWS

GAE
Amazon Ec2
Provider
Google
AWS
Service Model
PaaS
IaaS
Auto scaling
Yes
Yes
Network Availability
99.999%
99.9%
Load Balancing
Yes (Extra Charge)
Yes (Free)
Programming Language Supported
APL
Java
PHP
Python
Ruby
WinDev
Java
Python
Free Tier
Free of cost for limited usage, and trial
Free Tier for 1 Year. User needs to provide Credit Card details
Flexibility
Less considering PaaS
More considering IaaS
Published in OSFY.

References

 

Leave a comment

Your email address will not be published. Required fields are marked *