开发者

Increasing speed of webservice - howto

开发者 https://www.devze.com 2022-12-23 19:52 出处:网络
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开发者_如何学运维 writ

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?


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消