Friday, February 4, 2011

5x performance - switching from LWP to Furl & Net::DNS::Lite

Recently I rewrote some of our code that used LWP::UserAgent to use Furl instead, and have been observing more than 5x increase in performance (the CPU time spent for each HTTP request in average has dropped 82%).

The fact clearly shows that if you are having performance issues with LWP::UserAgent it is a good idea to switch to Furl.  And here are my recommendations when doing so:

use the low-level interface (Furl::HTTP)

The OO-interface provided by Furl.pm is not as fast as the low level interface, though it is still about twice as fast as LWP::UserAgent.

use Net::DNS::Lite for accurate timeouts

The timeout parameter of LWP::UserAgent is not accurate.  The module may wait longer than the specified timeout while looking up hostnames.  Furl provides a callback to use non-default hostname lookup functions with support for timeouts, and Net::DNS::Lite can be used for the purpose.

use Cache::LRU to cache DNS queries

In general DNS queries are lightweight but caching the responses can still have positive effect (if the cache is very fast).  Cache::LRU is suitable for such an usecase.

The below code snippet illustrates how to setup a Furl::HTTP object with the described configuration.
use Cache::LRU;
use Furl;
use Net::DNS::Lite;

# setup cache for Net::DNS::Lite
$Net::DNS::Lite::CACHE = Cache::LRU->new(
    size => 256,
);

# create HTTP object...
my $furl = Furl::HTTP->new(
    inet_aton => \&Net::DNS::Lite::inet_aton,
    timeout   => $timeout_in_seconds,
    ...

18 comments:

  1. Nice work, you might want to label this entry as English also

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Showbox for PC Windows 10, 8.1, 8, 7, XP & Mac OS X Computer here
    Hulu for PC Stream TV and Movies Live and Online link
    Xender for PC Windows 10, 8.1, 8, 7, XP & Mac OS X Computer website

    ReplyDelete
  4. It sounds good, but it is true. It is a direct link between employee health and higher productivity to get a better handle on this, we talked with Bodmer Berg manager of employee health and wellness of paycheck FLex Login.

    ReplyDelete


  5. flipkart emi,
    flipkart debit card emi,
    flipkart emi for debit card,
    flipkart emi on debit card,
    flipkart emi with debit card,
    flipkart emi sbi debit card,
    flipkart no emi cost,
    flipkart emi,
    flipkart with emi,
    flipkart email id,
    flipkart emi mobile,
    flipkart emi without credit card,
    flipkart mobile emi on debit card,
    flipkart emi options,
    flipkart emi card,
    flipkart emi using debit card,
    flipkart emi bajaj finserv
    zestmoney flipkart emi,
    flipkart emi laptop,
    flipkart emi process,
    flipkart emi phone,
    flipkart no cost emi laptops,
    flipkart emi in debit card,
    flipkart emi debit card icici,
    flipkart emi on credit card,
    flipkart emi credit card,
    flipkart emi policy,
    flipkart emi rules,
    flipkart emi cancellation,
    flipkart 0 emi,
    flipkart emi eligibility check,
    flipkart easy emi on debit card,
    flipkart zero emi,
    flipkart emi procedure,
    flipkart emi pay,
    flipkart emi eligibility check sms,
    flipkart emi calculator,
    flipkart emi customer care number,
    flipkart emi process debit card,,
    flipkart give emi on debit card,
    flipkart emi sms,
    flipkart emi icici debit card,,
    flipkart no emi cost ,
    flipkart emi app,
    flipkart emi shopping,
    flipkart no cost emi led tv,
    flipkart easy emi option,
    flipkart emi loan,
    flipkart emi for mobile,
    flipkart emi service,
    flipkart emi with credit card,
    flipkart in emi,
    flipkart debit card emi laptop,
    flipkart cardless emi link,
    flipkart free emi,
    flipkart emi hdfc,
    flipkart emi credit,,
    flipkart emi hdfc debit card,
    flipkart emi message,
    flipkart emi information,
    flipkart emi contact number,
    flipkart emi msg,
    flipkart new emi scheme,
    flipkart emi on debit card hdfc,
    flipkart emi number,
    flipkart debit card emi kaise kare,
    flipkart emi on debit card axis bank,
    flipkart emi registration,
    flipkart emi on icici debit card,
    flipkart emi on debit card quora,
    flipkart emi on axis debit card,
    flipkart debit card emi eligibility icici,
    flipkart debit card emi yes bank,
    flipkart emi on debit card sms,
    flipkart emi bank list,
    flipkart emi process in hindi,
    flipkart emi return policy
    flipkart debit card emi youtube,
    flipkart pay later emi,
    flipkart hdfc emi offer,
    flipkart emi how to pay,
    flipkart hdfc debit card emi eligibility,
    flipkart debit card emi eligibility sbi,
    flipkart debit card emi 2018,
    flipkart emi sbi,
    flipkart emi conditions,
    flipkart emi review,
    flipkart emi payment date,
    flipkart emi helpline number,
    flipkart emi how it works,
    flipkart se emi kaise kare,
    flipkart emi quora,
    flipkart debit card emi quora,
    flipkart emi faq,
    flipkart emi interest rate,
    flipkart emi 60000,,
    flipkart emi without interest,
    flipkart no cost emi quora

    ,

    ReplyDelete
  6. 8-نقل الأجهزة الكهربائية: من الأجود أن يتم نقل الأجهزة الكهربائية في الكراتين المخصصة بها ولكن إن لم تبقى الكراتين الأصلية، من الممكن أن تقومي بوضع كل جهاز كهربائي في كرتونة داخل كرتونة أخرى بهدف حمايتها.
    شركة نقل عفش
    شركة نقل اثاث من الرياض الى قطر
    شركة نقل عفش من الرياض الى قطر
    شركة نقل عفش بالاحساء

    ReplyDelete

  7. Flipkart CashBack Offers,telugu bloggers ,telugu websites

    Flipkart CashBack Offers - SBI, HDFC, ICICI, Citibank Cards,flipkart sbi debit card emi,flipkart upcoming offers on mobiles,flipkart credit card,flipkart cashback phonepe,flipkart credit card generator,flipkart cashback offer phonepe,flipkart american express,india fake debit card generator,flipkart american express gift card,sbi credit card offers on flipkart today,sbi flipkart offer,sbi debit card offers cash back,sbi flipkart offer 2018,,telugu bloggers ,telugu websites


    Offers.Flipkart .

    flipkart bank offers,flipkart cash back coupons, flipkart offers,flipkart cashback offers ,flipkart cashback offers,flipkart cash back offers,flipkart cashback coupons,flipkart cashback,Flipkart Cashback Offers,Flipkart Bank Offers, flipkart upcoming offers on mobiles, flipkart hdfc offer, flipkart icici offer,sbi credit card offers on flipkart today,sbi flipkart offer, hdfc credit card offers on flipkart, flipkart upcoming offers on mobiles, flipkart offers


    flipkart today deal offer,flipkart todays deal,flipkart best offer today,flipkart cashback offer today,flipkart mobile app offers today,flipkart mobile deals today

    "Flipkart Cashback Offers || Flipkart Bank Offers || Flipkart Deals 2018 ||" "flipkart upcoming offers on mobiles, hdfc credit card offers on flipkart 2018, sbi credit card offers on flipkart today, flipkart hdfc offer terms and conditions, sbi flipkart offer 2018, flipkart cashback phonepe, flipkart hdfc offer august 2018, flipkart icici offers

    Flipkart CashBack Offers July 2018 - SBI, HDFC, ICICI, Citibank Cards,Cashback Offers Coupons,

    Today Special deals offers


    Flipkart CashBack Offers June 2018 - SBI, HDFC, ICICI, Citibank Cards

    Best of Home Furnishing min 40% off:

    flipkart Mobile Accessories,flipkart Storage devices,flipkart Brands at best prices,flipkart Top Offers,flipkart Fashion for Travel Lovers,FLIPKART Great Offers On Furniture,FLIPKART Discounts for You,flipkart Deals of the Day


    flipkart axis cashback offer,

    flipkart discount coupon codes, flipkartcashbackoffers,

    ReplyDelete
  8. flipkart credit
    flipkart cardless credit
    flipkart credit card offers
    flipkart offer credit card
    flipkart offer for credit card
    flipkart offers with credit cards
    flipkart hdfc credit card offer
    flipkart credit card
    flipkart cardless credit registration
    flipkart sbi credit card offer
    flipkart icici credit card offer
    flipkart credit card emi
    flipkart credit card generator
    flipkart cardless credit not showing
    flipkart emi credit card
    flipkart credit limit
    flipkart 60000 credit limit
    flipkart instant credit
    flipkart credit line
    flipkart hsbc credit card offers
    flipkart refund policy for credit card
    flipkart gst credit
    flipkart credit 60000
    flipkart cardless credit payment
    flipkart credit account
    flipkart cardless credit registration link
    flipkart cardless credit launch date
    flipkart axis bank credit card offer
    flipkart cashless credit apply
    flipkart without credit card emi
    flipkart credit card emi process
    how flipkart credit card emi works
    flipkart cardless credit how to apply
    flipkart credit offers
    flipkart cardless credit offer
    flipkart cardless credit quora
    flipkart refund to credit card
    flipkart sbi credit card
    flipkart credit card holder
    flipkart credit card offers today
    flipkart mobile credit card offers
    flipkart us credit card
    flipkart purchase without credit card
    flipkart credit scheme
    emi in flipkart using credit card
    flipkart emi with credit card
    flipkart credit card emi scheme
    flipkart no cost emi credit card
    flipkart discount credit card
    flipkart 5000 credit
    flipkart axis credit card offer
    flipkart home credit
    flipkart credit facility
    flipkart credit line sign up
    flipkart hdfc credit card emi
    flipkart credit card offers 2018
    flipkart accepted credit cards
    flipkart credit balance
    flipkart credit card payment
    flipkart free credit
    flipkart credit emi
    flipkart hdfc bank credit card offers
    flipkart cardless credit terms and conditions
    flipkart cardless credit option not showing
    flipkart credit card refund
    flipkart american express credit card
    flipkart cardless credit faq
    flipkart cardless credit hindi
    flipkart cardless credit starting date
    flipkart cash on delivery credit card
    flipkart credit card cash back offer
    flipkart credit less
    flipkart credit rating
    flipkart credit system
    flipkart credit upto 60000
    flipkart hdfc credit card cash back offer
    flipkart input tax credit
    flipkart international credit card
    flipkart kotak credit card offer

    ReplyDelete

  9. flipkart debit
    flipkart debit card emi
    flipkart emi for debit card
    flipkart emi debit card sbi
    flipkart sbi debit card emi
    flipkart icici debit card emi
    flipkart debit card offers
    flipkart offer debit card
    flipkart emi debit card mobile
    flipkart debit card emi icici
    flipkart sbi debit card offer
    flipkart hdfc debit card emi
    flipkart emi on debit card sbi
    flipkart axis debit card emi
    flipkart icici debit card offer
    flipkart hdfc debit card offer
    flipkart debit card emi message
    flipkart emi debit card icici
    flipkart sbi debit card emi offer
    flipkart hdfc debit card emi offer
    flipkart emi debit card axis bank
    flipkart par debit card se emi
    flipkart axis bank debit card emi
    flipkart debit card emi terms and conditions
    flipkart sbi debit card emi eligibility check
    flipkart accept debit card for emi
    flipkart debit card emi bank of baroda
    flipkart debit card emi bob
    flipkart hdfc debit card emi eligibility
    flipkart refund to debit card
    flipkart emi on debit card quora
    flipkart debit card emi indian bank
    flipkart debit card emi banks
    flipkart debit card no cost emi
    flipkart debit card emi rules
    flipkart debit card emi tamil
    flipkart debit card emi kaise kare
    flipkart debit card emi union bank
    flipkart debit card emi number
    flipkart debit card payment
    flipkart debit card emi purchase
    flipkart debit card emi products list
    flipkart debit card loan
    flipkart sbi debit card emi eligibility check sms
    flipkart axis bank debit card offer
    flipkart debit card emi in hindi
    flipkart pe debit card emi kaise banaye
    flipkart icici bank debit card emi
    flipkart debit card emi sbi in hindi
    flipkart hdfc debit card emi products
    flipkart debit card emi video
    flipkart emi without debit card
    flipkart debit card emi telugu
    flipkart debit card emi iob
    flipkart debit card emi indusind bank
    flipkart debit card emi yes bank
    flipkart debit card emi hdfc sms
    flipkart debit card emi hindi
    flipkart debit card emi not eligible
    flipkart debit card emi option hdfc
    flipkart debit card emi youtube
    flipkart pnb debit card offer
    flipkart axis debit card offer
    flipkart axis bank debit card
    flipkart debit card payment offers
    flipkart hdfc bank debit card emi
    flipkart debit card emi quora
    flipkart debit card ad
    flipkart debit card emi 2018
    flipkart debit card emi news

    ReplyDelete
  10. Extraordinary article! I need individuals to know exactly how great this data is in your article. Your perspectives are much similar to my own concerning this subject. I will visit day by day your blog since I know. By the way Choose Globtier to get Android App Development services for your business grow.

    android application development company in New Jersey USA

    android app development in New Jersey USA

    android development company in New Jersey USA

    android application development company in New Jersey USA

    android app development in New Jersey USA

    android development company in New Jersey USA

    ReplyDelete

Note: Only a member of this blog may post a comment.