Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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 )
Technology Partners: 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!

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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

618 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