Speed Up Execution of Perl LWP Module

Posted on 2004-04-19
Medium Priority
Last Modified: 2012-08-13
I used to have a site on a shared server running Sun Solaris 5.8 and Perl 5.6.1. We have now moved to a dedicated Linux server running Red Hat Enterprise Linux V3, Cpanel/Web Host Manager (latest), and  Perl 5.8.1. I have a perl script that collects images from a site on the web and downloads them to our server. Typcially processing between 100 to 1000 at a time. I've noticed a slight performance decrease since moving to the new RHEL server. When processing 30 urls it takes about 10 seconds longer then before. Although this difference is minor, the lag really shows up when processing thousands of images at a time. What are potential causes of the noticeable descrease in my Perl scripts performance when utilizing the LWP module?

What steps can I take to improve this.
Question by:davef8
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 20

Expert Comment

ID: 10864686
Other people have reported on Perl 5.8 being considerably slower than Perl 5.6. You might try installing the latest version of the Perl 5.6 stream in parallel with your already-installed 5.8 and do a speed comparison.

(The evidence I've seen so far points to a heavier UTF-8 support in 5.8 vs 5.6 as one of the culprits in the slowdown. I don't know of an easy way to improve the performance while keeping the benefits of the newer version.)

The LWP module has a number of specialized features that may enable you to improve the performance (at the expense of simplicity). Using these, you may be able to reduce the number of times data is copied from memory to memory or disk to disk. Look at the options for the 'get' and 'request' methods and consider whether you can take control of the data earler in the download process, either in chunks as it comes in or by (a :content_cb) or by specifying the destination file in advance (with a :content_file).

Author Comment

ID: 10864718
Do you have any links to informaiton on this: "The LWP module has a number of specialized features that may enable you to improve the performance (at the expense of simplicity)."

I'll try using 5.6 as well.
LVL 20

Expert Comment

ID: 10865191
Sorry, it's in the LWP::UserAgent doc:


Under the heading REQUEST METHODS, see the descriptions for methods

$ua->get( $url )


$ua->request( $request )

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 20

Expert Comment

ID: 10865202
You might also want to check out whether using LWP::Parallel::UserAgent will help by overlapping the requests. If the requests are distributed across multiple servers, you may be able to decrease your overall run time by running the requests in parallel.



Author Comment

ID: 11086515
It turns out this issue had nothing to do with perl itself. The lag was a result of network traffic.

Accepted Solution

Netminder earned 0 total points
ID: 11317531
PAQed, with points refunded (500)

EE Admin

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question