3

I need to perform a large number of HTTP post requests, and ignore the response. I am currently doing this using LWP::UserAgent. It seems to run somewhat slow though I am not sure if it is waiting for a response or what, is there anyway to speed it up and possibly just ignore the responses?

4

2 回答 2

4

bigian 的答案可能是最好的,但另一种加快速度的方法是使用 LWP::ConnCache 允许 LWP 重用现有连接,而不是为每个请求建立新连接。

如果您只在一个站点上敲击,启用它就这么简单——

my $conn_cache = LWP::ConnCache->new;
$conn_cache->total_capacity([1]) ;
$ua->conn_cache($conn_cache) ;

我发现这可以使 http 站点上的某些操作的速度提高一倍,而对于 https 站点则提高一倍以上。

于 2011-09-05T05:04:29.130 回答
2

LWP::并行

http://metacpan.org/pod/LWP::Parallel

“介绍

ParallelUserAgent 是现有 libwww 模块的扩展。它允许您获取 URL 列表(它目前支持 HTTP、FTP 和 FILE URL。HTTPS 也可以工作)并并行连接到所有这些 URL ,然后等待结果出现。

太棒了,这对我来说创造了奇迹......

于 2010-08-19T08:00:03.223 回答