0 Replies Latest reply on Oct 29, 2002 12:34 PM by Hezekiel

    Benefits of entity cache (READ!)

    Hezekiel Newbie

      theserverside has a thread http://www2.theserverside.com/home/thread.jsp?thread_id=16149
      about the new PetStore benchmark done by the MiddleWare Company. I finally got tired of this EntityBean and J2EE bashing that I conducted a test with our J2EE app. Here's the same post that I posted to that forum
      ------------------------------------------------------------
      Don't believe this entitybeans are crap fud!
      I got so annoyed by this benchmark that I wrote a test to compare server dataobject 'gets' with entity layer and without entity layer on our J2EE app.

      The dataobjects are quite complex, they contain data from 7 database tables. This is a real world scenario, an application that needs to have both GUI and Web interface.

      All the entity beans are BMP, since that complex stuff doesn't scale to CMP or anything, and SQL code is easy to optimize (basic rule: many simple queries are much faster than one complex with lots of joins, if u don't believe, try..)

      All entity beans use DAO (data access objects) so this makes it really easy to test it without entity cache.

      The remote session facade has a method like this:
      List getDataObject(List ids);
      that fetches the dataobjects with given ids. Normally I iterate through ids and call findByPrimary() and then getData() to fill result array.

      To test entityless implementation I added method
      List getDataObjectsFast(List ids);
      in which I directly connect to the database (of course through the transaction handler) and call the DAO's load method for each id.

      The small test database contained 200000 records in several tables (yes, it's small - we normally have 10 000 000 + records) and these records 'translated' to approx 24000 dataobjects.

      So to read those dataobjects the database (tested with mysql 4.0.4 beta with JConnector beta 3) would have to perform 200000 reads and the server would need to construct 24000 entity beans in entity scenario.

      Here are the results (clocked at the server end)
      run entity [sek] entityless [sek]
      1.st 105 82
      2.nd 5,3 81
      3.rd 4,7 82
      4.th 4,7 81
      5.th 4,7 82

      So the 1.st time the entityless implementation is 28% faster
      than the entity implementation, but after the cache is fully utilized the entity implementation is 1700% faster. Over 17 times faster!!

      Without entity cache the server can do approx 2500 database ops / sek. Non optimized MySQL & non optimized JBoss running on my P4 1,6GHz laptop. Not bad, kudos to MySQL and well written JConnector beta! drivers..

      But with entity cache turned on the same hw delivers
      approx 43000 database ops / sek!!! Non optimized (both MySQL and JBoss 3.0.3 in default settings)

      And remember that for each antitybean read method I call first connect to datasource then do the read and then disconnect, whereas entityless implementation needs only one connect/disconnect pair.

      Can u get 43000 database ops / sek from your .NET server on off the shelf laptop?
      But that in your .NET pipe and smoke it!