Syed Jahanzaib – Personal Blog to Share Knowledge !

March 22, 2012

Squid: Your cache is running out of filedescriptors Solution !

Filed under: Linux Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 9:50 AM

If you have large number of proxy users & you start to feel browsing is getting slower, and upon insecting squid cache log /var/log/squid/cache.log you see below error …

WARNING! Your cache is running out of filedescriptors

It means Squid proxy server is running out of file descriptors and cannot handle the extra requests sent by your client computers. therefore you need to increase descriptors value.

Use the following command to see the current descriptors value

squidclient -p 8080  mgr:info | grep 'file descri'



Result As showed in the image below . . .

As you can see current file descriptors are 1024. To increase this value, edit your squid.conf file by

nano /etc/squid/squid.conf

Now add this line

max_filedesc 4096

OR [depends on squid version you may need this]

max_filedescriptor

Save and exit editor.

Now restart your squid service to apply the changes you made by

service squid restart

Use following command to see the descriptors value

squidclient -p 8080  mgr:info | grep ‘file descri’

and this time you will notice that file descriptors have increased.
Result As showed in the image below . . .


Some Additional Tip!

nano /etc/sysctl.conf

Add following line in starting

fs.file-max = 65535

Save & Exit.

Now run following command to update

systcl -p

Regard’s
Syed Jahanzaib

14 Comments »

  1. As’slaam-o-Alaikum
    Shah gee can you please send me your Cell phone number for contact please

    Regards
    Muhammad Imran Khan
    cell # 03137633665
    imran_niazi_2004@hotmail.com

    Like

    Comment by Muhammad Imran Khan — March 22, 2012 @ 10:48 PM

    • You can email me for any discussion and advise you may need 🙂

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — March 24, 2012 @ 4:18 PM

      • Sir,
        I’m recently working on Internet providing through Cable and Wirless Wifi . I’m using Mikrotik 3.22 as router with 40 clients including 15 on WiFi.
        Sir,
        1:- my network’s basic load is (YOU-TUBE) more than 18 clients open (YOU-TUBE) for same video and downloads.
        that causes me more bandwidth download and increases my PTCL billing.
        I’v used one of your blog about squid proxy server config and LUSCA/Squid also and checked them both it works fine but after power failure it doesn’t.second I’m not able to connect Squid to Mikrotik to bypass Request coming from clients.
        2:- Can you please brief me about CC-PROXY server and how I can Redirect all request from Mikrotik to CC-PROXY in Transparent mode

        Can you please send me complete set-up Config to solve my problem

        Regard,

        Muhammad Imran Khan
        imran_niazi_2004@hotmail.com

        Like

        Comment by Muhammad Imran Khan — April 4, 2012 @ 10:12 PM

      • # If configuration is getting lost (Which I don’t know why its happening, as it never happened with me) , try to cache you-tube using SQUID method as follow:

        Youtube caching with SQUID 2.7 [using storeurl.pl]

        # I have no experience with CC proxy, as its not a standard solution.

        Like

        Comment by Syed Jahanzaib / Pinochio~:) — April 5, 2012 @ 8:55 AM

      • Thanks for Replying Sir,
        Sir can you tell about you residence and City
        Are you from Lahore

        Regards
        Muhammad Imran Khan
        0313-7633665

        Like

        Comment by Muhammad Imran Khan — April 14, 2012 @ 9:29 PM

  2. I have over 1500 concurrent user…..can you please let me know what hardware configuration will match these number of user if i want to use squid/ Lusca Youtube caching ?Can u advise me what number of file descriptors will use in this scenario ?
    Any suggestion will be very gladly appropriated .

    Like

    Comment by Ferdous hasan — March 24, 2012 @ 10:36 AM

  3. or…you can modified the init script into some kind like this
    #
    # Try to increase the # of filedescriptors we can open.
    #
    maxfds () {
    [ -n “$SQUID_MAXFD” ] || return
    [ -f /proc/sys/fs/file-max ] || return 0
    global_file_max=`cat /proc/sys/fs/file-max`
    minimal_file_max=$(($SQUID_MAXFD + 65536))
    if [ “$global_file_max” -lt $minimal_file_max ]
    then
    echo $minimal_file_max > /proc/sys/fs/file-max
    fi
    ulimit -n $SQUID_MAXFD
    }

    put it above start script….
    and change 65536 into some number that fit inb your networks

    regards from indonesia…

    Like

    Comment by Metromini KasKus — June 21, 2012 @ 1:46 PM

  4. Mr. Syed how are you
    I’m glade to contact you i like your page and your tutorials in mikrotik, I have a question: there is a program called HandyCache can work on windows when you use it with appserv program can you make a tutorial about it and how to connected it with a mikrotik in a network………… Regards from Iraq to your work and to you…. thank you

    Like

    Comment by osama ismail — July 5, 2014 @ 1:17 AM

    • I have not worked with handycache, but for sure every proxy runs on ip/port. Simply create a dst-nat rule on mikrotik that redirects port 80 request to handycache ip/port. simple is that. I have few guides on it on my blog, search dst-nat

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — July 6, 2014 @ 11:12 AM

  5. Dear Shah G,
    I have 2 squid proxy servers on RHEL 5.5, on one i am getting message you are running out of file descriptors. while running command ulimit -n, it shows 32768 and when running the command “squidclient -p 8080 mrg:info | grep ‘file descri’ it shows “maximum number of file descriptor: 1024” Please help me to set the descriptors to 32768.

    Thank you in advance.
    JazakAllah

    Like

    Comment by Sarfraz Aslam — June 15, 2016 @ 10:31 AM

  6. Hi, thanks for sharing this!
    Official Squid docs for 2.7 refer that option as “max_filedescriptors” instead of “max_filedesc” in your post.
    Maybe it is worth to point out that version difference.

    Like

    Comment by Marc Richter (@marc_richter) — June 1, 2017 @ 3:08 PM


RSS feed for comments on this post. TrackBack URI

Leave a reply to Syed Jahanzaib / Pinochio~:) Cancel reply