Home > Cloud computing Tips > Cloud development > Running a Web service on Google App Engine
Cloud computing Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

CLOUD DEVELOPMENT

Running a Web service on Google App Engine


William Brogden, Contributor
07.21.2009
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


App Engine is Google's service for building Web applications in the cloud. The initial version only supported Python, but Java servlet support has recently entered early release. Developers can experiment with a quota of free resources, so naturally I was interested. I downloaded the software development kit (SDK) Version 1.2.1 and got the Google plug-in for Eclipse 3.4.2. Documentation for the Java version has not quite caught up with the quality of the Python documentation, but you'll find what you need with a little digging.

App Engine Java servlet environment
The runtime environment for the App Engine is Java 6 with the standard libraries. The structure of a Java servlet in the App Engine environment follows normal Java practice for Servlet API 2.5 with certain restrictions. All of the static resources normally served directly by the servlet container -- such as HTML files, CSS files and images -- are placed according to convention under the root directory of the application. For example, you might have a logo image addressed as "/graphics/mylogo.gif."

Resources that are private to the application and are only read, never written, such as jar libraries, class files and configuration files, are stored under the usual "/WEB-INF" directory. For obvious security reasons, Google can't let an application wander unrestrained through the file system, so if your application reads and writes files, you will have to make some major adjustments to use the persistent data-storage methods that App Engine supports. Furthermore, your servlet must complete a response within 30 seconds and may not start any new processes.

Scaling to an increased user-request load is handled automatically by creating new instances of an application and removing them when the load decreases. The App Engine environment ensures that all instances will have access to correctly updated common resources. Here are some of the Google specific tools your application can make use of.

  • Google account integration. By default, your application will be open to the internet, but you can use Google accounts to control access by authenticated users.
  • Mail service. Your application can send normal email using the standard JavaMail application programming interface (API), subject to security restrictions on mime type and volume limits.
  • Memcache for performance. The Memcache API lets you cache data that may be expensive to compute. Cached data is available to all instances of your application. The current maximum size of a cached value is 1 MB.
  • Internet communication. You can use standard Java APIs for connecting to other Internet locations, but the actual connection will be made by Google's "URL Fetch" networking proxy, which imposes security and size limits.
  • Java Datastore service. The Google BigTable database/distributed storage system is not provided directly. Instead, the Datastore system for storing and retrieving Java objects is built on top of BigTable. Datastore supports two popular APIs for Java object persistence: Java Data Objects (JDO) and the Java Persistence API. Datastore is supposed to be able to support very large data collections.
  • Application monitoring. Google provides a convenient Web "dashboard" for monitoring your application. You can monitor usage, consumption of resources and error logging.

The Eclipse development environment for App Engine
Currently, plug-ins are available only for Eclipse 3.3 and 3.4 -- as of this writing, there are no plug-ins for the newest 3.5 "Galileo" Eclipse. If you are downloading and installing Eclipse for the first time, go for the "Java EE Developers" package. The Google plug-ins provide extensive support for simulating the App Engine environment. Selecting the "New Web Application Project" option automatically creates the proper directory structure with the correct Java library files.

Creating an example service
As an example, I decided to try porting a servlet-based Web service to App Engine. The service is a simple one I have used for several example coding projects. It lets you look up lists of words that sound alike using the "metaphone" phonetic code algorithm. It uses some serialized Java objects to hold the lookup structures for thousands of precomputed phonetic codes. Since these are read-only objects, they can be stored with other application resources.

Getting a Google App Engine account
Since I've had an account with Google for years, I figured this should be the simplest part of the process, but I was wrong. For some reason, Google wanted to verify my account by means of a SMS message to my cell phone -- I don't have a cell phone! With help from a cell phone owner, I got my verification code, and I was able to proceed. I suspect that this SMS capability will find its way into the API soon as Google integrates App Engine with other Google projects. With the verification accomplished, my normal Google account let me request an application name. I chose "phonetic01" so the full URL to the service is "phonetic01.appspot.com."

Installing to Google's system
The Eclipse App Engine plug-in guides you through configuration of your application and uploads all of the components. In addition to the usual web.xml deployment descriptor, App Engine uses an AppEngine-web.xml file to associate a name and version number with the code. Eclipse makes modification of components and redeployment quite easy and fast.

After the application had been inactive for a while, I found that response time to a request took a few seconds, presumably because App Engine does not keep every application loaded all the time. Subsequent requests were quite fast.

Conclusions
Although it is still under development, Google's App Engine support for Java servlet-based Web services is very usable. With good Eclipse support, it is easy to start experimenting. If you don't have Eclipse, the SDK has command-line utilities to support development and deployment with your normal tools.

Resources


Rate this Tip
To rate tips, you must be a member of SearchCloudComputing.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Platform as a Service and cloud computing
Microsoft's Data as a Service offering, code-named Dallas, on tap
Windows Azure slated to go live in January 2010
Intuit muscles into the Platform as a Service game
Platform as a Service speeds time to market of iPhone app startup
Gartner thinks cloud computing's the tops
Online auction firm taps Force.com to glue apps together
Developers discuss pros and cons of Force.com
Micro Focus pitches COBOL in the cloud
XCP aims to standardize open source virtualization
An introduction to developing for Microsoft Azure

Evaluating cloud services
Cloud computing less cloudy, but IT pros still skeptical
Azure's early 2010 launch comes with RightScale support
Rackspace customer downplays cloud outage
Major players form cloud coalition, challenge traditional hardware vendors
Financial services group and consumer health giant venture into cloud
L.A. bets on cloud computing with Google Apps despite financial woes
City of Angels is now City of Google
EC2 email blackout raises new concerns about security, reliability in the cloud
Amazon EC2 attack prompts customer support changes
Cloud computing: Appeal, origins and economics

Cloud development
Five requirements for deploying an application in a public cloud
Introducing the key cloud computing platforms
The IT clouds: IBM, Microsoft and Sun
Amazon's EC2 and the open source cloud projects
Platform as a Service: Google and Force.com
Backup to the compute cloud
Code sample illustrates how to write Azure applications for the cloud
Cloud computing and application security: Issues and risks
Introduction to Windows Azure for developers

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Infrastructure as a Service (IaaS)  (SearchCloudComputing.com)
Platform as a Service (PaaS)  (SearchCloudComputing.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts