LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 06-16-2009, 10:02 AM   #1
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 51
optimize squid


hi

According to this webpage:

http://www.linux-faqs.com/squid.php

I'd like to optimize my squid 2.6.STABLE5 installed on Debian Etch (P4, 2GHz, 2GB RAM) for about 150 users.

I should put the following two lines:
Code:
ulimit -HSn 8192 echo 1024 32768 > /proc/sys/net/ipv4/ip_local_port_range
in /etc/init.d/squid, but I don't know where exactly.

my /etc/init.d/squid:
Code:
#! /bin/sh
#
# squid      Startup script for the SQUID HTTP proxy-cache.
#
# Version:   @(#)squid.rc  2.20  01-Oct-2001  miquels@cistron.nl
#
### BEGIN INIT INFO
# Provides:          squid
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Should-Start:      $named
# Should-Stop:       $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Squid HTTP Proxy
### END INIT INFO

NAME=squid
DAEMON=/usr/sbin/squid
LIB=/usr/lib/squid
PIDFILE=/var/run/$NAME.pid
SQUID_ARGS="-D -sYC"

[ ! -f /etc/default/squid ] || . /etc/default/squid

. /lib/lsb/init-functions

PATH=/bin:/usr/bin:/sbin:/usr/sbin

[ -x $DAEMON ] || exit 0

grepconf () {
  w="    " # space tab
  sq=/etc/squid/squid.conf
  # sed is cool.
  res=`sed -ne '
     s/^'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
     t end;
     d;
     :end q' < $sq`
  [ -n "$res" ] || res=$2
  echo "$res"
}

grepconf2 () {
  w="    " # space tab
  sq=/etc/squid/$NAME.conf
  # sed is cool.
  res=`sed -ne '
     s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
     t end;
     d;
     :end q' < $sq`
  [ -n "$res" ] || res=$2
  echo "$res"
}

#
#   Try to increase the # of filedescriptors we can open.
#
maxfds () {
  [ -n "$SQUID_MAXFD" ] || return
  [ -f /proc/sys/fs/file-max ] || return 0
  [ $SQUID_MAXFD -le 4096 ] || SQUID_MAXFD=4096
  global_file_max=`cat /proc/sys/fs/file-max`
  minimal_file_max=$(($SQUID_MAXFD + 4096))
  if [ "$global_file_max" -lt $minimal_file_max ]
  then
     echo $minimal_file_max > /proc/sys/fs/file-max
  fi
  ulimit -n $SQUID_MAXFD
}

start () {
  cdr=`grepconf2 cache_dir /var/spool/$NAME`

  case "$cdr" in
     [0-9]*)
        log_failure_msg "squid: squid.conf contains 2.2.5 syntax -
not starting!"
        log_end_msg 1
        exit 1
        ;;
  esac

  #
   # Create spool dirs if they don't exist.
   #
  if [ -d "$cdr" -a ! -d "$cdr/00" ]
  then
     log_warning_msg "Creating squid spool directory structure"
     $DAEMON -z
  fi

  if [ "$CHUID" = "" ]; then
     CHUID=root
  fi

  maxfds
  umask 027
  cd $cdr
  start-stop-daemon --quiet --start \
     --pidfile $PIDFILE \
     --chuid $CHUID \
     --exec $DAEMON -- $SQUID_ARGS < /dev/null
  return $?
}

stop () {
  PID=`cat $PIDFILE 2>/dev/null`
  start-stop-daemon --stop --quiet --pidfile $PIDFILE --name squid
  #
  #   Now we have to wait until squid has _really_ stopped.
  #
  sleep 2
  if test -n "$PID" && kill -0 $PID 2>/dev/null
  then
     log_action_begin_msg " Waiting"
     cnt=0
     while kill -0 $PID 2>/dev/null
     do
        cnt=`expr $cnt + 1`
        if [ $cnt -gt 24 ]
        then
           log_action_end_msg 1
           return 1
        fi
        sleep 5
        log_action_cont_msg ""
     done
     log_action_end_msg 0
     return 0
  else
     return 0
  fi
}

case "$1" in
   start)
  log_daemon_msg "Starting Squid HTTP proxy" "squid"
  if start ; then
     log_end_msg $?
  else
     log_end_msg $?
  fi
  ;;
   stop)
  log_daemon_msg "Stopping Squid HTTP proxy" "squid"
  if stop ; then
     log_end_msg $?
  else
     log_end_msg $?
  fi
  ;;
   reload|force-reload)
  log_action_msg "Reloading Squid configuration files"
  start-stop-daemon --stop --signal 1 \
     --pidfile $PIDFILE --quiet --exec $DAEMON
  log_action_end_msg 0
  ;;
   restart)
  log_daemon_msg "Restarting Squid HTTP proxy" "squid"
  stop
  if start ; then
     log_end_msg $?
  else
     log_end_msg $?
  fi
  ;;
   *)
  echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart}"
  exit 3
  ;;
esac

exit 0

Last edited by cccc; 06-17-2009 at 02:35 AM.
 
Old 06-16-2009, 10:07 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
you can put it after
Quote:
### END INIT INFO
 
Old 06-17-2009, 02:37 AM   #3
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
thx, but what ulimit exactly means and what are the risks in my case?

Last edited by cccc; 06-17-2009 at 02:43 AM.
 
Old 06-17-2009, 04:03 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
http://wiki.linuxquestions.org/wiki/Ulimit
 
Old 06-17-2009, 04:36 AM   #5
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
thx, but should squid crash when ulimit reached or what happens?
 
Old 06-17-2009, 07:56 AM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by cccc View Post

I should put the following two lines:
Code:
ulimit -HSn 8192 echo 1024 32768 > /proc/sys/net/ipv4/ip_local_port_range
Two lines? That looks like one.

Quote:
According to this webpage:

http://www.linux-faqs.com/squid.php
That's a pretty old article. Although I couldn't see a direct statement of the date,
Quote:
This requires two steps in recent 2.2.x series kernels.
seemed like a bit of a giveaway, as did the mention of a K6-2 as a high performance processor. So, it is quite possible that some of the config details of an up-to-date squid have moved on since then.

Quote:
thx, but what ulimit exactly means and what are the risks in my case?
IMHO, until you know what ulimit means, you shouldn't be reconfiguring it. Why did you want to set it to some particular value, if you don't know what its about?

Maybe you could have a look at this article http://linux.com/archive/feature/153221, which is a bit more recent.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
optimize spamassasin alaios Linux - Networking 1 11-14-2006 02:01 AM
can I optimize this kushalkoolwal Programming 5 10-21-2005 09:05 PM
How to optimize the partitions of a HD dabenavidesd Linux - General 1 09-02-2005 11:40 PM
Optimize/Prefix rogk Linux - Software 1 07-25-2004 05:04 AM
how could I optimize bittorrent? rcerrillo General 0 07-04-2004 06:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 01:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration