From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf ·...

Post on 20-Apr-2020

5 views 0 download

Transcript of From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf ·...

From EC2 to AppEngineJava

@ Alex Tolleyalexandertolley@gmail.com June 2nd, 2009

1. Closer to "Big Switch" idea plug and play.

Why Port to AppEngine?

2. Cheaper vs EC2 costsWhy Port to AppEngine?

Basic EC2 instance: ~ $60/month

AppEngineJava: low usage is FREE

3. Simpler development cycle

Just upload code and go!

Why Port to AppEngine?

Amazon feels like this....

Why Port to AppEngine?

Google is like this...

Toaster with wall socket

Why Port to AppEngine?

The Application

HTML & Javascript coded with GWT (Google Web Toolkit)

Description

Server

Java Servlets

Amazon SimpleDB for database

Amazon S3 for metadata and content storage

Client UI

Web page text and image annotation for research and scholarshoip.

30 second timeout

No threads

No file system writes

No sockets

AppEngine Limitations

more details:http://code.google.com/appengine/docs/java/runtime.html

No long running apps, e.g. genetic algorithm, no streaming.

Servlet cannot spawn threads (impacts SimpleDB)

Impacts on libraries

All writes must be to persistance storage, including log files

AppEngine Limitations

AppEngineJava != Java

Components

Works out of the box ... ...but project structure differences are enough to drive you a little crazy

GWT (Google Web Toolkit) - Eclipse plugin

Standard GWT project layout

Standard GWT project layout

Which means the relative path to the image is direct, e.g: DOM.setStyleAttribute(widget.getElement(), "backgroundImage", "url(image/myimage.jpg)");

AppEngine project layout

AppEngine project layout

Which means the relative path to the image starts from a higher directory e.g: DOM.setStyleAttribute(widget.getElement(), "backgroundImage", "url(../image/myimage.jpg)");

Therefore you will likely have to ensure that all resource strings, in code and CSS files are modified for this new structure.

AppEngine project layout

src/com/cloud/demo/MY_APPENGINE_PROJECT.gwt.xml

AppEngine project layout

WEB-INF/web.xml

Configuration hell. Can be very tiresome to ensure all the parts are correct. It may be easier to import the code into a new base project to save the effort.

AppEngine project layout

war/MY_APPENGINE_PROJECT.html

Configuration hell. Can be very tiresome to ensure all the parts are correct. It may be easier to import the code into a new base project to save the effort.

Checking 3rd Party Libraries

Checking 3rd Party Libraries

Checking 3rd Party Libraries

Checking 3rd Party Libraries

The libraries

Works fine, no illegal code.

Jet S3 libraryhttps://jets3t.dev.java.net/

The libraries

Works fine, no illegal code.

Jet S3 libraryhttps://jets3t.dev.java.net/

...except you don't need it now!

SimpleDB => HardDB

Java Library for Amazon SimpleDB - Full featured library, if somewhat over engineered.- Creates all request strings - Uses Apache commons libraries.- developer: Elena@AWS [Used by my application] 'Simple' SimpleDB code in single Java file/class (240 lines) - Very simple - Assumes user creates request strings.- developer: ian schumacher

SimpleDB = HardDB

1. Java Library for Amazon SimpleDB - Full featured library, if somewhat over engineered.- Creates all request strings - Uses Apache commons libraries.- Elena@AWS [Used by my application] 2. 'Simple' SimpleDB code in single Java file/class (240 lines) - Very simple - Assumes user creates request strings.- ianschumacher

Both fail illegal code test. option 1 fails as Apache libraries uses socket connections that are called in code.

option 2 can be fixed with modification of base64 encoding

SimpleDB = HardDB

The SimpleDB library option was abandoned as there was no reasonable hope of rebuilding and modifying the Apache libraries to work.

In addition, my project used the older SimpleDB API which required threading for performance.

The 'simple' SimpleDB code was not used because it would require creating a new library around that core.

There are no other library solutions that can be used out of the box with AppEngineJava

SimpleDB = HardDB

Decision was made to go with Google DataStore

Google DataStore

A repository that stores data objects and that can be queried like a database.

A PersistanceManager handles the CRUD operations.

Very easy to implement.

Google DataStore

Limitations:

Similar to SimpleDBQuery options are even more limited than SimpleDB, but sufficient. (e.g. no logical NOT)

Summary:Check that your application can live with the AppEngine sandbox and timeout limitations

AppEngineJava != Java. AppEngineJava has language restrictions

Try to use OSS and import libraries

Create the GWT as a fresh project and import the old project, possibly renaming the entrypoint class.

Amazon S3 is fine - but do you need it?

Amazon SimpleDB - needs a AppEngineJava friendly library - seriously consider DataStore instead in this case.