Google Cloud Datastore - Objectify vs. JPA DataNucleus (performance comparison)

Please see current performance test results: https://github.com/maciej-arkit/GAE-Datastore-Performance-Test/blob/master/results/Objectify_vs_JPA_-_performance_test_plan.ods

There is no clear winner regarding performance - both JPA and Objectify may perform better in some areas but none perform better in all tests.
Tests listed below cover only specific cases.

Practical experience shows that Objectify performs much better and it significantly boosts development efficiency over JPA, due to convenient documentation and general robustness.


If you are using JPA (DataNucleus) on top of Datastore, you may think about migrating your application to Objectify for following reasons:
  1. Objectify is easy to use (it has lightweight API)
  2. JPA is not recommended by Google to be used with Datastore (because it doesn't corresponds to non-relational nature of Datastore)
  3. DataNucleus JPA is not activelly supported for Datastore, and there is no such plan, which means that no bugfixes/enhancements will be applied (https://code.google.com/p/datanucleus-appengine/wiki/Compatibility)

PERFORMANCE TESTS


Test scenarios were conducted by sending 20 requests to simple Java servlets and measuring response time in milliseconds respectivelly for Objectify and JPA (response times include network overhead).
Corresponding data sets for JPA and Objectify were generated using same methods: https://github.com/maciej-arkit/GAE-Datastore-Performance-Test 


Test 1: Create, read and remove 100 "flat" entries

"Flat" means that objects doesn't have any relations (ex. OneToMany) 


COMMENT: Objectify has better API to support batch "saves"
– hence it performs much better when saving multiple objects

Test 2: Create, read and remove 100 "complex" entries

"Complex" means that each entry contains collection of 10 sub-entries (OneToMany relation)

 

COMMENT: Objectify has better API to support batch "saves"
– hence it performs much better when saving multiple objects



Test 3: Read 500 "flat" entries

JPA has better performance when reading bigger amount of simple objects.

 

 SUMMARY

  • Objectify and JPA are very similar when reading simple, non-hierarchical data structures (i.e. Without OneToMany relations)
  • Objectify is faster when reading hierarchical objects
  • Objectify has better API to support batch "saves" – hence it performs better when saving multiple objects
  • Objectify doesn't require class enhancement (JPA DataNucleus requires to run enhancer befor you can persist/read class instance)
  • JPA may have overhead for resource management – i.e. creating EntityManager and closing it, especially when transaction was spanning multiple entities.
  • JPA has better performance when reading large amounts of objects (ex. 500 or 1000 "flat" objects)

Migration from JPA to Objectify

Objectify and JPA are compatible on data level - it means that you can use Objectify to read data persisted using JPA and vice versa.
This fact is important, because it allows to migrate your application step by step, starting with most critical functionalities.

REFERENCES

Article about migration from JPA to Objectify: http://blog.publysher.nl/2012/02/improving-appengine-performance-from.html

Komentarze

Popularne posty z tego bloga

How to start developing Google App Engine applications

How to deploy Ruby on Rails application on Google Compute Engine

Geospatial Queries with Google Cloud Datastore (Java)