While developing an web-application using AJAX and python, I found that in some cases the interface was slow. Debugging (using FF and firebug) showed that for one action three AJAX request were made. The response times in this specific situation were: user/group list: 130-150ms (each), getpermissions: 160-180ms.
This was on a local test-server, so there was almost no latency. Testing the same site when I was remote, the response times were around 600-800ms for each call (I don’t know the exact numbers now). Since each request has a certain startup-time, and since we are still using CGI instead of mod_python (for debugging purposes) it seems reasonable to assume that the startup-time is high, relative to executing time. That’s why I tried combining the three requests into one.
What I did is adding optional arguments to the getpermissions call. If these arguments are present, it also returns the corresponding list. Testing response times with this changed code resulted in the same response times. So far so good.
Testing the code with the combined call resulted in a 160-180ms response time. This is exactly the same for the getpermissions call without querying the lists! Apparently the CGI has a very high impact, and the list generating code very low impact.
All in all this resulted in a 260-300ms improvement, on my local testing network! This is noticeably faster. I’m glad :)