开发者

Using AJP to perform requests from Python to Java webserver

I have to implement a Python web application which operates on data available through web-services (API with GET requests and JSON responses).

The API server is implemented in Java. Preliminarily tests show significant overhead if API calls are made through urllib2 (connection is opened and closed for each request).

If I enable AJP in API server, which library should I use to perform requests using AJP protocol from Python? I googled Plup, but I can't find a clear way to request and consume data in Python, not just proxying it elsewhere.

Is using AJP a good solution? Obviously I have to maintain a connection开发者_JS百科 pool to perform AJP requests, but I can't find anything related in Plup.

Thank you.


I have no idea what's AJP is. Also you did not open what goes to "sigfinicant overhead", so I might be a poor person to answer to this question.

But if I were you I would first try to few tricks:

Enable HTTP 1.1 keep-alive on urllib2

(here is an example using another library Python urllib2 with keep alive )

HTTP 1.1 keep-alive connections do not close TCP/IP pipe for the subsequent requests.

Use Spawning / eventlets web server which does non-blocking IO patch for urllib / Python sockets.

http://pypi.python.org/pypi/Spawning/

This will make parallelization in Python much more robust, when the overhead in the application is input/output, not using CPU to process the requests. JSON decoding is rarely CPU bound.

With these two tricks we were able to consume 1000 request/sec in our Python web application from Microsoft IIS backed API server (farm).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜