It is actually slower to break 100 requests and batch messages every 5 times, waiting for them to complete until you send the next batch. You might be better off just sending 100 requests, remember that JavaScript is single-threaded, so it can only allow one response at a time at any time.
The best way is to configure a batch request service that accepts something like:
/ajax_batch?req1=/some/request.json&req2=/other/request.json
And so on. Basically you send multiple requests in a single HTTP request. The response of such a request will look like this:
[ {"reqName":"req1","data":{}}, {"reqName":"req2","data":{}} ]
Your ajax_batch service will resolve each request and return the results in the correct order. Customer, you track what you sent and what you expect so that you can match the results with the right queries. Downside, it requires quite some coding.
The speedup will be completely caused by the massive reduction in HTTP requests. There is a limit to the number of requests you send, as the length of the URL has an iirc limit.
DWR does exactly that afaik.
BGerrissen
source share