Monday, February 9, 2009

Google App Engine: Free Hosting and Powerful SDK

(This post is part of the series Web Application on Resources in the Cloud.)

Google App Engine (GAE) [1] is an open platform made available by Google to host Web applications:
  • It can serve static pages (HTML, CSS, JavaScript, images, etc.).
  • It can serve dynamic pages. The programming language is Python [2] (with limited features). The default template framework is Django [3].
  • It can persist data in Google BigTable (with a query language similar to SQL, but with restricted features).
  • It offers transparent scaling and load-balancing.
  • Its sources are open and freely available. Google allows to host up to three applications by account, as sub-domains of appspot.com (at least during the preview period).
Some people, like Dare Obasanjo [4], consider GAE as implementing “Platform as a Service” paradigm. I agree and think GAE offers a core element to implement “Software as a Service” (the hype SaaS). In general, I think that SaaS can help IT companies delivering value to their customers at a better quality/price ratio. Understanding GAE strengths should encourage development teams to give a close look at the entire SaaS concept.

Free Service

GAE is offered free of charges during the preview period. In the future, customers will be billed only for what they have consumed (disk space, bandwidth, CPU time, etc.). This practice has been adopted by many providers of services in the cloud, like Amazon [5] and it Amazon Web Services (AWS) offer.

The Software Development Kit (SDK) [1] is open, and anyone can take a look at it, can customize it for his own needs, and can even submit patches. For now, only one programing language is supported: Python [2]. The SDK is delivered with a standalone runtime environment.

Python is also an open system, created by Guido van Rossum who has been working for Google since 1995. In my opinion, this combination is an argument against developers complaining about the need to learn yet another language: Python is a really powerful language and will continue to have a full support by Google as their favorite language.

In association to Python, Django [3] is the template language helping to create applications compliant with the Model-View-Controller (MVC) pattern [6]. Django is also an open source software.

To get the best of the languages and of the standalone GAE runtime, I strongly suggest setting up Eclipse (another open-source software) [7, 8]. Eclipse might not be the ideal candidate for GAE application development, but it provides an extensible platform easy to leverage. For example, egit [9] is a Eclipse plug-in handling transactions with Git repositories (like Github.com [10]).

Servicing static and dynamic pages

GAE can host 1,000 files, each one smaller than 1Mb, for a grand total of 500 Mb per application [11]. Usually, the static files are accessories: images, style sheets, etc. But the offered space allied to Google's scalable infrastructure can be also leverage to host almost any file (HTML, FLV (Flash), CSS, JavaScript, etc.). App Engine Fan describes how to setup GAE for this usage [12], as Matt Riggott [13].

The following handler definition, which should be located into the app.yaml configuration file, indicates that all requests should be served from the corresponding files located in the directory static.
handlers:
- url: /
  static_dir: static/
Dynamically generated content, like developers are used to producing with PHP for example, can be implemented with Django templates [3]. The following template defines the general Web page pattern. And the second template is just extending it by overriding the extension points.


Common.html template with the Web page organization and the extension points.


Producer.html template overriding the extension points with the page specific elements.

Note: because of internationalization concerns, I strongly recommend to NOT code Web pages as the ones above. Refer to my post on Internationalization of GAE Applications [14] for a better implementation.

Quickly, it is possible to use GAE to host static and dynamic pages on the domain appspot.com (pattern is http://[application-name].appspot.com/). Integrating these pages transparently in your own domain allows future updates without having your readers to point to a new Web address. You need to setup Google Apps for your Domain and follow their instructions [15].

App Engine Fan explains how to prevent access to your application from unknown domains [16]. In a private network, you can even open the GAE server to remote access [17].

Access to Google BigTable

In the Web application world, data persist mainly in databases. Databases scale, maintain indexes (providing quickly search results), support transaction (update, then commit or revert). Most databases are relational databases [18]. Among the well know relational databases, there are: Derby, Oracle, DB2, MySQL. SQL (Structured Query Language) is often the query language of relational databases.

GQL (Google Query Language) is very similar to SQL [19]. The discrepancies are due to GAE architecture. For example, to preserve its scalability of the underneath database, GQL does not offer the possibility to JOIN tables. I am not database expert, but I consider all limitations being workable and some of them are very sane.

One important issue with database is related to their central place: if they are corrupted, system can stop working. Being able to backup and restore them is critical. In April 2008, Google communicated about possible export file formats [20]. I have not found if this feature has been published... However, I found Aral Balkan's Gaebar application (GAE Backup And Restore) [21] which covers the basic functionality and even more (like the staging concept).

Update 2009/02/10:
In the SDK release 1.1.9, Google describes ways to upload data from a CSV into BigTable, and to download data into a local development server. Refer to the documentation on GAE Website [1].

Going further

Google has developed a GAE application that is gallery for other GAE applications [22]. Many applications are described there. Interviews of successful implementers are also available on GAE Website [1].

On April 10, 2008, Niall Kennedy posted a detailed article describing GAE architecture [23]. Many others people continue to publish on GAE and on Cloud computing issues in general [24]. It is a really hot topic ;)

Update 2009/02/10:
Dare Obasanjo published another post on Dare Obasanjo: Google App Engine on the road to becoming useful for building real web applications

A+, Dom
--
Sources:
  1. Google App Engine Website, and GAE Service API documentation.
  2. Official Python Website. Python history on Wikipedia. Guido van Rossum's blog (Python inventor).
  3. Django Website, with the section on its template language.
  4. Cloud Computing Conundrum: Platform as a Service vs. Utility Computing by Dare Obasanjo.
  5. Amazon Web Services Website.
  6. MVC Pattern applied to GAE Applications... (another post to be published soon).
  7. Eclipse Website.
  8. Article Configuring Eclipse on Windows to Use With Google App Engine from GAE documentation site.
  9. Eclipse plug-in for Git repositories: egit. Check egit short installation guide.
  10. My post on Git as my New SCM Solution.
  11. Quota description on GAE Website, on GAE blog, and on Wikipedia.
  12. Free Webhosting, Google App Engine style, by App Engine Fan.
  13. Using Google App Engine as your own Content Delivery Network by Matt Riggott.
  14. Internationalization of GAE Applications... (another post to be published soon).
  15. Access to the Standard Edition of Google Apps for Your Domain (GYAD) service and instruction on how to setup a GAE application for your domain.
  16. The darker side of multiplexing, or how to prevent site hijacking by App Engine Fan.
  17. Access Google App Engine Development Server Remotely, by Josh Cronemeyer.
  18. Definition of relational database by Wikipedia.
  19. GQL reference page on GAE Website.
  20. Getting your data on, and off, of Google App Engine on GAE official blog.
  21. Google App Engine Backup and Restore (Gaebar) by Aral Balkan
  22. Google GAE Application Gallery, being itself a GAE application.
  23. Google App Engine for Developers, by Niall Kennedy.
  24. Architectural manifesto: An introduction to the possibilities (and risks) of cloud computing on developerWorks.

1 comment:

  1. please do write the article for beginner as well .

    ReplyDelete