Skip Menu |

This queue is for tickets about the Amazon-SQS-Simple CPAN distribution.

Report information
The Basics
Id: 113583
Status: new
Priority: 0/
Queue: Amazon-SQS-Simple

People
Owner: Nobody in particular
Requestors: slobodan [...] miskovic.ca
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: UserAgent and keep_alive
Hi Mike, Is there any particular reason that ::Simple instantiates a new LWP::UserAgent for every request? I've been testing a small change that caches UA instance on creation and also sets keep_alive so that we don't have to pay the connection handshake on every request. Anecdotally, it feels faster, but also `netstat -a | grep TIME_WAIT | wc -l` doesn't go out of control when doing mass message sends etc. Without this patch TIME_WAIT needs to be lowered via OS parameters to not cause a bottleneck.
Subject: Amazon-SQS-Simple-keep-alive.patch
diff --git a/perl/local/lib/perl5/Amazon/SQS/Simple/Base.pm b/perl/local/lib/perl5/Amazon/SQS/Simple/Base.pm index 001871f..60c994f 100755 --- a/perl/local/lib/perl5/Amazon/SQS/Simple/Base.pm +++ b/perl/local/lib/perl5/Amazon/SQS/Simple/Base.pm @@ -37,6 +37,7 @@ sub new { Endpoint => +BASE_ENDPOINT, SignatureVersion => 2, Version => $DEFAULT_SQS_VERSION, + ua => LWP::UserAgent->new( keep_alive => 6 ), @_, }; @@ -67,7 +68,7 @@ sub _dispatch { my $self = shift; my $params = shift || {}; my $force_array = shift || []; - my $ua = LWP::UserAgent->new(); + my $ua = $self->{ua}; my $url = $self->{Endpoint}; my $response; my $post_body;
From: slobodan [...] miskovic.ca
I forgot to say, another benefit of the patch is that it lets users supply their own UA, for say testing purposes.