views:

54

answers:

3

Hi,

Our client-server product has the protocol between them as XML over HTTP. Here, the client asks a GET/POST query to the web server and the server responds with XML. The server is written using django. The server has to be on the web because there are many clients across the world using this.

The server code uses extensive memoization and also there is very less db queries - most queries dont have any db queries, some of them has max 1.

The biggest problem is the speed. Every query takes close to 5 seconds for the reply. The data replied is also very less - in the range of 4-6 Kb.

What are the mechanisms to improve speed of the web service? Is this the usual way of writing a client-server? Are there other technologies and are we missing out on it?

Thank you K

EDIT: I forgot to mention one thing - we are running it on the cloud. Another thing I found was that in a good network, it is quite fast - around 1-2 sec, so is it the setting up of TCP sessions which is taking time?

+1  A: 

A good first step would be to work out where your latency is coming from.

Try a tool like Wireshark to have a look at the timings of the HTTP traffic on the wire as a first step.

tomfanning
One problem here is that we are running it in the cloud. So, I dont have enough permissions for that. Another thing I found was that in a good network, it is quite fast - around 1-2 sec, so is it the setting up of TCP sessions which is taking time?
Koran
Contention for CPU / IO / bandwidth on the cloud-based server?
tomfanning
A: 

This is based on my experience with sql and c# based webservices. Not much sure about django. the major culprit on these performances will be the database retrieval part.Try isolating the db query to check the performance

balalakshmi
+1  A: 

I'm with tomfanning, it sounds like latency issues (assuming you are serving the django app in a sane way and the server isn't too loaded).

I would add ping to the list of things to try and just check your baseline network latency. Also check speeds when you query the service from the server machine itself just to make absolutely sure that it's network latency.

If it isn't network you might run the django development server under cProfile (python -m cProfile start_the_server.py), run a few queries, and Ctrl-C to get function-by-function profiling info.

One last thought, some of the common choices for XML serialization in python can be really slow. Use lxml. That shouldn't account for 5s response times for 4-6k though.

teepark