30
From EC2 to AppEngineJava @ Alex Tolley [email protected] June 2nd, 2009

From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley [email protected] June

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

From EC2 to AppEngineJava

@ Alex [email protected] June 2nd, 2009

Page 2: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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

Why Port to AppEngine?

Page 3: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

2. Cheaper vs EC2 costsWhy Port to AppEngine?

Basic EC2 instance: ~ $60/month

AppEngineJava: low usage is FREE

Page 4: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

3. Simpler development cycle

Just upload code and go!

Why Port to AppEngine?

Page 5: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Amazon feels like this....

Why Port to AppEngine?

Page 6: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Google is like this...

Toaster with wall socket

Why Port to AppEngine?

Page 7: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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.

Page 8: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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

Page 9: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

AppEngine Limitations

AppEngineJava != Java

Page 10: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Components

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

GWT (Google Web Toolkit) - Eclipse plugin

Page 11: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Standard GWT project layout

Page 12: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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)");

Page 13: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

AppEngine project layout

Page 14: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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.

Page 15: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

AppEngine project layout

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

Page 16: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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.

Page 17: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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.

Page 18: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Checking 3rd Party Libraries

Page 19: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Checking 3rd Party Libraries

Page 20: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Checking 3rd Party Libraries

Page 21: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Checking 3rd Party Libraries

Page 22: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

The libraries

Works fine, no illegal code.

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

Page 23: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

The libraries

Works fine, no illegal code.

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

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

Page 24: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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

Page 25: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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

Page 26: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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

Page 27: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

SimpleDB = HardDB

Decision was made to go with Google DataStore

Page 28: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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.

Page 29: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

Google DataStore

Limitations:

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

Page 30: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June

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.