Syed Jahanzaib Personnel 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 , for example over 50 , and you start to feel browsing is getting slower, also you see the following error in /var/log/squid/cache.log

WARNING! Your cache is running out of filedescriptors

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

now save and exit.

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

service squid restart

Now again 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 . . .

 

==========================

Also do the following

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

About these ads

10 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

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

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

      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

        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:

        http://aacable.wordpress.com/2012/01/19/youtube-caching-with-squid-2-7-using-storeurl-pl/

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

        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

        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 .

    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…

    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

    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

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


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Silver is the New Black Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 2,361 other followers

%d bloggers like this: