Squid3 web Server Acceleration

Source: Internet
Author: User
Test environment: Operating System: centos5.0Web server: apache2 + tomcat5.5Jdk: j2se1.5.51.download squid-3.0.stable9.tar.gz (the latest version during the test ). Www.squid-cache.orgVersionsv33.0squid-3.0.STABLE9.tar.gz 2. Add users and groups # useraddsquid-M

Test environment: OS: centos5.0 Web server: apache2 + tomcat 5.5 Jdk: j2se 1.5.5 1. Download The squid-3.0.STABLE9.tar.gz (the latest version when testing ). Http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE9.tar.gz 2. Add users and groups # useradd squid-M

Test environment:

Operating System: centos5.0

WebServer: Apache2 + tomcat 5.5

Jdk: j2se 1.5.5

1. Download squid-3.0.stable9.tar.gz (the latest version during testing ).

Http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE9.tar.gz

2. Add users and groups

# Useradd squid-M-c "Squid user"-d/dev/null-s/sbin/nologin

3. decompress and compile and install

Tar squid-3.0.STABLE9.tar.gz

Cd squid-3.0.STABLE9

. /Configure -- prefix =/data/squid3 -- disable-carp -- with-aufs-threads = 32 -- with-pthreads -- enable-storeio = 'ufs, aufs, null' -- enable-disk-io = 'aio, blocking' -- enable-removal-policies = 'heap, lru' -- disable-wccp -- enable-kill-parent-hack -- disable-snmp -- disable-poll -- disable-select -- enable-auth = basic -- with-aio -- disable-ident -lookup -- with-filedescriptors = 65536

Compilation parameters are not described in detail. Please refer to relevant documents.

Make

Makeinstall

Installation is complete.

4. Configuration

You may need to create some files which must be called in the configuration file (note the owner and permissions of the file)

1) [root @ www ~] # Cd/data/squid3/var/logs/

2) [root @ www ~] # Touch cache. log

3) [root @ www ~] # Chmod 755 cache. log

4) [root @ www ~] # Chown squid: squid cache. log

5) [root @ www ~] # Touch page_zs_access_log

6) [root @ www ~] # Chmod 755 page_zs_access_log

7) [root @ www ~] # Chown squid: squid page_zs_access_log

8) [root @ www ~] # Cd/data/squid3/etc/

9) configure the squid configuration file squid. conf

[Root @ www ~] # Vi squid. conf (192.168.3.11 isServerIP address)

Visible_hostnamewww.test.com

Http_port80 vhost vport

Cache_mem512 MB

Maximum_object_size_in_memory2048 KB

Memory_replacement_policylru

Cache_dirufs/tmp 512 16 256

Max_open_disk_fds0

Minimum_object_size0 KB

Maximum_object_size32768 KB

Logformatcombined %> a % ui % un [% tl] "% rm % ru HTTP/% rv" % Hs % H "" % {User-Agent}> h "% Ss: % Sh

Access_log/data/squid3/var/logs/page_zs_access_log combined

Pid_filename/data/squid3/var/logs/squid. pid

Cache_store_lognone

Cache_peer192.168.3.11 parent 81 0 no-query no-digest originserver name = www

Cache_peer_domainwww www.test.com

Cache_peer_accesswww allow all

Http_accessallow all

AclQUERY urlpath_regex cgi-bin. php. cgi. avi. wmv. rm. ram. mpg. mpeg. zip. exe

Cachedeny QUERY

Cache_effective_usersquid

Cache_effective_groupsquid

10) [root @ www ~] #/Data/squid3/sbin/squid-k parse

You can use this test command to verify the syntax and configuration of squid. conf (the following is OK. If it is not OK, a corresponding prompt will be prompted to modify the configuration file as prompted)

2008/10/1421: 14: 56 | Processing Configuration File:/data/squid3/etc/squid. conf (depth 0)

11) [root @ www ~] #/Data/squid3/sbin/squid-z

Used to create a cache directory

12) vi a squid. sh STARTUP script is as follows: grant executable permissions

[Root @ www ~] # Vi squid. sh

#! /Bin/sh

#

Ulimit-HSn 15000

# This script starts and stops Squid

Echo15000>/proc/sys/fs/file-max

Case "$1" in

Start)

/Data/squid3/sbin/squid-s

Echo-n 'squid'

;;

Stop)

/Data/squid3/sbin/squid-k shutdown

;;

Esac

# Chmod + x squid. sh

5. Start squid

[Root @ www ~] #./Squid. sh start to start squid.

Check whether startup is available.

[Root @ www ~] # Ps fax | grep squid

13750 pts/3 S + \ _ grepsquid

30474? Ss 0: 00/data/squid3/sbin/squid-s

30476? S 0: 01 \ _ (squid)-s

Run the lsof-I: 80 command to check who occupies port 80.

View squid access logs.

[Root @ www ~] # Tail-f/data/squid3/var/logs/page_zs_access_log

View hit rate and other related information

[Root @ www ~] #/Data/squid3/bin/squidclient-p 80-hlocalhost mgr: info

HTTP/1.0 200 OK

Server: squid/3.0.STABLE9

Mime-type: 1.0

Date: Tue, 14 Oct 2008 13:22:40 GMT

Content-Type: text/plain

Expires: Tue, 14 Oct 2008 13:22:40 GMT

Last-Modified: Tue, 14 Oct 2008 13:22:40 GMT

X-Cache: MISS from www.6558855.com

Via: 1.0 www.6558855.com (squid/3.0.STABLE9)

Connection: close

Squid Object Cache: Version 3.0.STABLE9

Start Time: Tue, 14 Oct 2008 11:25:50 GMT

Current Time: Tue, 14 Oct 2008 13:22:40 GMT

Connection information for squid:

Number ofclients accessing cache: 2

Number ofHTTP requests received ed: 772

Number ofICP messages received ed: 0

Number ofICP messages sent: 0

Number ofqueued ICP replies: 0

Number ofHTCP messages received ed: 0

Number ofHTCP messages sent: 0

Requestfailure ratio: 0.00

Average HTTP requests per minute sincestart: 6.6

Average ICPmessages per minute since start: 0.0

Select loopcalled: 7081542 times, 0.990 MS avg

Cache information for squid:

Hits as % of all requests: 5 min: 0.0%, 60 min: 89.7%

Hits as % of bytes sent: 5 min:-0.0%, 60 min:-0.0%

Memory hitsas % of hit requests: 5 min: 0.0%, 60 min: 0.0%

Disk hitsas % of hit requests: 5 min: 0.0%, 60 min: 0.0%

StorageSwap size: 104 KB

Storage Swap capacity: 0.0% used, 100.0% free

Storage apsaradb for Memsize: 228 KB

Storage Memcapacity: 0.0% used, 100.0% free

Mean ObjectSize: 10.40 KB

Requestsgiven to unlinkd: 68

Median Service Times (seconds) 5 min 60 min:

HTTPRequests (All): 0.00000 0.00000

Cacemisses: 0.00000 0.00000

CacheHits: 0.00000 0.00000

NearHits: 0.00000 0.00000

Not-Modified Replies: 0.00000 0.00000

DNSLookups: 0.00000 0.00000

ICPQueries: 0.00000 0.00000

Resource usage for squid:

UPTime: 7009.125 seconds

CPUTime: 0.948 seconds

CPUUsage: 0.01%

CPU Usage, 5 minute avg: 0.00%

CPU Usage, 60 minute avg: 0.01%

ProcessData Segment Size via sbrk (): 2968 KB

MaximumResident Size: 0 KB

Page faultswith physical I/o: 2

Memory usage for squid via mallinfo ():

Total spacein arena: 3240 KB

Ordinaryblocks: 3194 KB 17 blks

Smallblocks: 0 KB 0 blks

Holdingblocks: 11472 KB 17 blks

Free Smallblocks: 0 KB

FreeOrdinary blocks: 45 KB

Total inuse: 14666 KB 100%

Totalfree: 45 KB 0%

Totalsize: 14712 KB

Memory accounted:

Totalaccounted: 3001 KB 20%

Mempoolaccountant: 3001 KB 20%

Mempoolunaccountant: 11710 KB 80%

MemPoolAlloc CILS: 147106

Mempoolfreecils: 145713

File descriptor usage for squid:

Maximumnumber of file descriptors: 15000

Largestfile desc currently in use: 14

Number offile desc currently in use: 8

Filesqueued for open: 0

Availablenumber of file descriptors: 14992

Reservednumber of file descriptors: 100

Store Diskfiles open: 0

Internal Data Structures:

45 StoreEntries

41 StoreEntries with MemObjects

40 HotObject Cache Items

10on-disk objects

6. About dynamic page cache.

For example, jsp page.

Use the Header as jspServerDecompression

Add the following program to the JSPs involved in the cache to set "Last-Modified" and "Expires;

<% @ Page import = "java. io. *" %>

<%

Longfile_lmodified = new File ("/tmp/catchmodified". lastModified ();

Response. setBufferSize (16 );

Response. setDateHeader ("Last-Modified", file_lmodified );

Response. setDateHeader ("Expires", System. currentTimeMillis ()/1000*1000 + 300000 );

Response. flushBuffer ();

%>

7. Add automatic update mode

[Root @ www ~] # Vi refreshCatch. sh

#/Bin/sh

/Bin/echo>/tmp/catchmodified

Chmod + x refreshCatch. sh

Then write a sentence in crontab.

*/5 */data/squid3/refreshCatch. sh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.