xmlprclib / server不重用连接 [英] xmlprclib/server not reusing connections

查看:70
本文介绍了xmlprclib / server不重用连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎xmlrpclib和/或SimpleXMLRPCServer始终为每个请求使用新的

连接。我一直试图让它们

重用现有的连接,但找不到位置。是否有任何

特殊原因他们会花很多时间来调用关闭/关闭/完成

以及在xmlrpclib中创建新的连接对象?


我实际上正在使用M2Crypto,因此连接最终结束了SSL内部的
。为每个单独的

请求建立新连接是疯狂的,特别是因为我的大部分请求都是轻量级的。

我希望客户端和服务器处于较低带宽连接

,通常在美国的两端。


我到目前为止试图重复使用的尝试导致了一个曲折的迷宫

深度继承层次结构和交织的传输,连接

和请求处理程序硬编码彼此的类。没有多少

调试和评论关闭/关闭/完成阻止使用新的

连接。


Roger

解决方案



Roger>似乎xmlrpclib和/或SimpleXMLRPCServer总是使用

Roger>每个请求的新连接。我一直在尝试制作

Roger>他们重用现有的连接但无法找到。是

Roger>有什么特别的原因,他们会花很多时间来打电话给他们。
Roger>关闭/关闭/完成以及制作新的连接对象

Roger> xmlrpclib?


我认为连接重用将在较低的级别完成。看看

httplib模块。以另一种方式看看xmlrpclib的MultiCall类

以在某些情况下提高性能。


Skip


>我认为连接重用将在较低的级别完成。看一下

httplib模块。另请参阅xmlrpclib的MultiCall类,以便在某些情况下提高性能。



multicall对我没用,因为我的后续请求取决于结果

之前的那些。 SSL非常重要,因为流量通过开放的互联网流量为
。我需要进行一些证书验证,这对于Python 2.3库没有任何设施来支付。


在服务器端,事情也没有希望。由于在开放的互联网上收听,并且不得不在Windows以及Linux和Mac上工作,因此线程服务器最初看起来很吸引人,但是

遗憾的是它没有限制产生的线程数的设施。

它还为每个请求创建一个新线程,而不是更正常的

设计有一个线程池来处理请求/连接。


xmlrpclib被编码为使用Python 1.5兼容的名称(缺少

HTTP / 1.1和持久性连接)。 SimpleXMLRPCRequestHandler是

硬编码,在一次请求后关闭连接(参见
do_POST的最后一行)。添加SSL的M2Crypto代码继承了这两种实现和设计。


基本上现有的xmlrpclib和SimpleXMLRPCServer是硬编码的

(和恕我直言,他们会一路走来)每个连接都要做一个请求,然后将b $ b关闭。投入我需要在两端进行SSL,使用

HTTP身份验证,以及一些轻量级身份验证。防火墙为了防止DOS攻击,我不得不花几天时间将各个班级和M2Crypto一起捣碎各个班级




你可以在这里看到结果:

http://cvs.sf.net/viewcvs.py/bitpim/...py?view=markup


Roger


2004年2月23日星期一03:55:08 PM -0800,Roger Binns写道:

[...] < blockquote class =post_quotes>
基本上现有的xmlrpclib和SimpleXMLRPCServer是硬编码的(并且恕我直言)每个连接做一个请求,然后关闭。投入我需要在两端进行SSL,使用HTTP身份验证和一些轻量级。防火墙为了防止DOS攻击,我不得不花几天时间将各个类和M2Crypto一起捣碎。


你可能会有更好的运气使用Twisted< http://twistedmatrix.com/> ;.


XML-RPC服务器支持在Twisted中确实支持SSL,并且HTTP / 1.1

持久连接,并且它非常易于使用:

http://twistedmatrix.com/documents/examples/xmlrpc.py


我对Twisted'的XML-RPC客户端没有任何经验(尽管你可以看看

的例子 http://twistedmatrix.com/documents/e...lrpcclient.py) ,但是看了一眼

在代码中它不支持

框中的HTTP / 1.1持久连接...但你可以相对容易地添加它。

你可以在这里看到结果:

http://cvs.sf.net/viewcvs.py/bitpim/...py?view=markup




看了一下,看起来好像使用Twisted来实现它会更轻松,更简单。

-Andrew。


It appears that xmlrpclib and/or SimpleXMLRPCServer always use new
connections for each request. I have been trying to make them
reuse the existing connection but can''t find where. Is there any
particular reason they go to such great lengths to call shutdown/close/finish
as well as making new connection objects in xmlrpclib?

I am actually using M2Crypto so the connection ultimately ends up
inside SSL. Having a new connection established for every single
request is insane, especially as most of my requests will be lightweight.
I expect the clients and servers to be on lower bandwidth connections
and usually on opposite ends of the US.

My attempts so far to make reuse happen have led to a twisty maze
of deep inheritance hierarchies and intertwined transports, connections
and request handlers hard coding each others classes. No amount of
debugging and commenting out shutdown/close/finish prevents new
connections from being used.

Roger

解决方案


Roger> It appears that xmlrpclib and/or SimpleXMLRPCServer always use
Roger> new connections for each request. I have been trying to make
Roger> them reuse the existing connection but can''t find where. Is
Roger> there any particular reason they go to such great lengths to call
Roger> shutdown/close/finish as well as making new connection objects in
Roger> xmlrpclib?

Connection reuse would be done at a lower level I think. Take a look at the
httplib module. Take a look at xmlrpclib''s MultiCall class for another way
to improve performance in some situations.

Skip


> Connection reuse would be done at a lower level I think. Take a look at the

httplib module. Take a look at xmlrpclib''s MultiCall class for another way
to improve performance in some situations.


multicall is of no use to me because my following requests depend on the results
of the preceding ones. SSL is really important since the traffic is going
over the open Internet. I needed to do some certificate validation which
the Python 2.3 library has no facilities for.

On the server side, things were hopeless as well. Since it would be
listening on the open Internet, and had to work on Windows as well as
Linux and Mac, the threading server initially seemed appealing, but
sadly it has no facilities for limiting the number of threads spawned.
It also makes a new thread per request, rather than the more normal
design of having a thread pool to deal with requests/connections.

xmlrpclib is coded to use the Python 1.5 compatible names (and lack of
HTTP/1.1 and persistent connections). SimpleXMLRPCRequestHandler is
hard-coded to close connections after one request (see last line of
do_POST). The M2Crypto code that added SSL to both inherited those
implementations and design.

Basically the existing xmlrpclib and SimpleXMLRPCServer are hard coded
(and IMHO go out of their way) to do one request per connection, and
then shut things down. Throw in that I needed to do SSL on both ends, with
HTTP authentication, and some "light" firewalling in order to prevent
DOS attacks, I had to spend several days mashing the various classes
together with M2Crypto together.

You can see the results here:

http://cvs.sf.net/viewcvs.py/bitpim/...py?view=markup

Roger


On Mon, Feb 23, 2004 at 03:55:08PM -0800, Roger Binns wrote:
[...]


Basically the existing xmlrpclib and SimpleXMLRPCServer are hard coded
(and IMHO go out of their way) to do one request per connection, and
then shut things down. Throw in that I needed to do SSL on both ends, with
HTTP authentication, and some "light" firewalling in order to prevent
DOS attacks, I had to spend several days mashing the various classes
together with M2Crypto together.
You might have better luck with Twisted <http://twistedmatrix.com/>.

The XML-RPC server support in Twisted does support SSL, and HTTP/1.1
persistent connections, and it''s pretty easy to use:

http://twistedmatrix.com/documents/examples/xmlrpc.py

I don''t have any experience with Twisted''s XML-RPC client (although you can
see an example at
http://twistedmatrix.com/documents/e...lrpcclient.py), but glancing
at the code it doesn''t support HTTP/1.1 persistent connections out of the
box... you could probably add that in relatively easily, though.
You can see the results here:

http://cvs.sf.net/viewcvs.py/bitpim/...py?view=markup



Glancing at that, it looks like using Twisted to implement that would be a
lot easier, and shorter.

-Andrew.


这篇关于xmlprclib / server不重用连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆