DWR Call batching

To reduce load on my current project I had a look into reducing the number of requests fired at the application server. Many pages in the application trigger multiple DWR calls resulting in Tomcat generating heavy load on the servers.

One of the sollutions I came up with is batching DWR calls, which reduces the number of calls by combining multiple calls into single requests.

Simply start and end a batch and DWR handles it all! For example:

JavaScript:
  1. function batchThreeCalls(){
  2.     DWREngine.beginBatch();
  3.       testbean.getOne(doOne);
  4.       testbean.getTwo(doTwo);
  5.       testbean.getThree(doThree);
  6.     DWREngine.endBatch();
  7.   }

Results in a single call, and a single response which is routed to the correct callbacks by DWR:

request

JavaScript:
  1. callCount=3
  2. warningHandler=null
  3. httpSessionId=EA9C0891376DE06E977B26CD729E59C8
  4. scriptSessionId=B206674DE4A43F7E497882E9E3723F3D
  5. page=/JRubyController/dwrtest.html
  6. c0-scriptName=testbean
  7. c0-methodName=getOne
  8. c0-id=158_1156968086615
  9. c1-scriptName=testbean
  10. c1-methodName=getTwo
  11. c1-id=1425_1156968086615
  12. c2-scriptName=testbean
  13. c2-methodName=getThree
  14. c2-id=3057_1156968086615

response

JavaScript:
  1. //#DWR-START#
  2. DWREngine._handleResponse('158_1156968086615', "1");
  3. //#DWR-END#
  4. //#DWR-START#
  5. DWREngine._handleResponse('1425_1156968086615', "2");
  6. //#DWR-END#
  7. //#DWR-START#
  8. DWREngine._handleResponse('3057_1156968086615', "3");
  9. //#DWR-END#

More one batching can be found on the DWR site.


5 Responses to “DWR Call batching”

  1. 1 railsguru

    The site is dog slow :(
    I'm wondering if you guys didn't go (way) overboard with Ajaxy stuff? I tend to shy away from Ajax these days and only use it when it really really really makes a difference in user experience (and not simply because Rails makes it easy to (ab)use)

    -andy

  2. 2 peter

    At this point AJAX stuff didn't seem to have caused the problems. The outdated database statistics, misconfigured caches, proxies and filters which we fixed today seem to have improved the performance drastically!

  3. 3 erikvanoosten

    Did the DWR Call Batching reduce load as well?
    I can image it is still better to leave this in, it will reduce the number of connections, but can you actually see a performance gain?

  4. 4 peter

    Well, we haven't put the batching stuff into online yet... so, hard to say just now. If I have numbers I'll let you know!

  5. 5 railsguru

    bet0r! :)
    -andy

Leave a Reply





About

Welcome to the weblog of Peter Maas. Here you'll find various posts related to stuff I like (like my kids and espresso) and stuff I do (like developing software).

JavaOne 2008 Pictures


Stage being build in the nearby park Stretched Limo Moscone Center - JavaOne pub Greenland Okke en Rudie golden_gate_warning_sign Hotel room javaone 2008 goodybag Rudie Cable Car line sea_lion nearby hotel alcatraz Golden Gate Java + You on a cab Tim Bray introducing the (J)Ruby panel Acme Anvile at CommunityOne Keynote Community One Keynote javaone2008 keynote
View more photos >

Categories



Meld u aan voor PayPal en begin direct met het accepteren van creditcardbetalingen.