Monday, April 13, 2009

Towards a general theory of JVM dancing (GAE/J)

Following my previous blog post about JVM dancing in the Google App Engine/J environment I decided to do some small testing to see how often the described "JVM switching" occurs.

The test was conducted by sending one HTTP-request per second to the same GAE/J application during a period of roughly four hours (3.7 hours). All requests were sent from the same IP-address and supplied the same JSESSIONID cookie (emulating all requests being sent from the same user within the same session). The GAE/J app that received the requests did not have any traffic other than the traffic generated by the test.

A total of 13285 requests were successfully served during this period. The requests were served by three distinct JVM:s (as identified by Runtime.getRuntime().hashCode()):
  • JVM A served 9273 requests (69.8 % of all requests)
  • JVM B served 4004 requests (30.1 %)
  • JVM C served 8 requests (0.1 %)
During these four hours of testing the serving of the requests switched between the JVM:s as follows:
  • 160 successive requests served by JVM A
  • 2764 successive requests served by JVM B
  • 1 request served by JVM C
  • 1240 successive requests served by JVM B
  • 21 successive requests served by JVM A
  • 2 successive requests served by JVM C
  • 208 successive requests served by JVM A
  • 2 successive requests served by JVM C
  • 368 successive requests served by JVM A
  • 1 request served by JVM C
  • 5499 successive requests served by JVM A
  • 2 successive requests served by JVM C
  • 3017 successive requests served by JVM A
In total 12 JVM switches took place. Which in this test translates into one JVM switch per 1107 requests (switch probability of 0.09 %).

The shortest time before a JVM switch was one second - but please note that the granularity of the test was one second since one request was sent per second.

The longest time before a JVM switch was 1.5 hours (5499 seconds).

It is probably very safe to assume that the "JVM dancing" pattern is heavily dependent on a variety of factors, including traffic patterns, general load of the GAE/J system, etc. So please take the above testing as one data point from one test - NOT an attempt to provide the general theory of JVM dancing :-)

7 comments:

  1. Would be cool to have a standard to display JVM hashcode.
    I was thinking to have JVM#hashcode to embed in every GAE/J application at the right bottom of the html page.
    But a custom HTTP header would also be cool:
    jvm-hashcode: 892898239.

    ReplyDelete
  2. Hi Franck! That's a nice idea! Something along the lines of response.setHeader("X-JVM", "" + Runtime.getRuntime().hashCode()) maybe?

    ReplyDelete
  3. Really good site thank you so much for your time in writing the posts for all of us to learn about. It will be very useful for me.
    share market
    stock market
    Indian Stock Market Tips

    ReplyDelete
  4. This is a great post ! it was very informative. I look forward in reading more of your work.
    Intraday Nifty Future Tips
    Share market tips
    Share and Earn

    ReplyDelete
  5. I was very encouraged to find this site. I wanted to thank you for this special read.
    Commodity tips
    Stock Market
    Share Market
    Nse Tips
    Bse Tips

    ReplyDelete
  6. Hi there! I just would like to give a huge thumbs up for the nice info you will have right here on this post. I will likely be coming again to your weblog for extra soon.
    Buy Property
    Sell Property
    Invest in Property
    Find real estate agent

    ReplyDelete
  7. I am very much pleased with the contents you have mentioned. I enjoyed every little bit part of it. It contains truly information. I want to thank you for this informative read.
    Intraday Calls || Nifty Trading || Nifty Intraday Tips.

    ReplyDelete