Reverse Proxy-based Web Cache accelerates modern Server Management
Source: Internet
Author: User
Article Title: reverse proxy-based Web Cache accelerates modern server management. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Implementation of reverse proxy cache Acceleration Based on Apache mod_proxy Apache contains the mod_proxy module, which can be used to implement proxy servers and reverse acceleration for backend servers
Install apache 1.3.x during compilation:
-- Enable-shared = max -- enable-module = most
Note: In Apache 2.x, mod_proxy has been separated into mod_proxy and mod_cache. At the same time, mod_cache has different implementations based on files and memory.
Create/var/www/proxy and set writeable apache service users
Mod_proxy configuration example: reverse proxy cache + Cache
Set up the frontend www.example.com reverse proxy back-end www.backend.com port 8080 service.
Modify: httpd. conf
ServerName www.example.com
ServerAdmin admin@example.com
# Reverse proxy setting
ProxyPass/http://www.backend.com: 8080/
ProxyPassReverse/http://www.backend.com: 8080/
# Cache dir root
CacheRoot "/var/www/proxy"
# Max cache storage
CacheSize 50000000
# Hour: every 4 hour
CacheGcInterval 4
# Max page expire time: hour
CacheMaxExpire 240
# Expire time = (now-last_modified) * CacheLastModifiedFactor
CacheLastModifiedFactor 0.1
# Defalt expire tag: hour
CacheDefaultExpire 1
# Force complete after precent of content retrived: 60-90%
CacheForceCompletion 80
CustomLog/usr/local/apache/logs/dev_access_log combined
Implementation of reverse proxy Acceleration Based on Squid Squid is a dedicated proxy server with much higher performance and efficiency than Apache mod_proxy.
To patch logs in combined format:
Http://www.squid-cache.org/mail-archive/squid-dev/200301/0164.html
Squid Compilation:
. /Configure -- enable-useragent-log -- enable-referer-log -- enable-default-err-language = Simplify_Chinese -- enable-err-versions ages = "Simplify_Chinese English" -- disable-internal- dns
Make
# Make install
# Cd/usr/local/squid
Make dir cache
Chown squid. squid *
Vi/usr/local/squid/etc/squid. conf
Add internal DNS resolution to/etc/hosts, for example:
192.168.0.4 [url] www.chedong.com [/url]
192.168.0.4 news.chedong.com
192.168.0.3 bbs.chedong.com
--------------------- Cut here ----------------------------------
# Visible name
Visible_hostname cache.example.com
# Cache config: space use 1G and memory use 256 M
Cache_dir ufs/usr/local/squid/cache 1024 16 256
Cache_mem 256 MB
Cache_inclutive_user squid
Cache_paitive_group squid
Http_port 80
Httpd_accel_host virtual
Httpd_accel_single_host off
Httpd_accel_port 80
Httpd_accel_uses_host_header on
Httpd_accel_with_proxy on
# Accelerater my domain only
Acl acceleratedHostA dstdomain .example1.com
Acl acceleratedHostB dstdomain .example2.com
Acl acceleratedHostC dstdomain .example3.com
# Accelerater http protocol on port 80
Acl acceleratedProtocol protocol HTTP
Acl acceleratedPort port 80
# Access arc
Acl all src 0.0.0.0/0.0.0.0
# Allow requests when they are to the accelerated machine AND to
# Right port with right protocol
Http_access allow acceleratedProtocol acceleratedPort acceleratedHostA
Http_access allow acceleratedProtocol acceleratedPort acceleratedHostB
Http_access allow acceleratedProtocol acceleratedPort acceleratedHostC
# Logging
Emulate_httpd_log on
Cache_store_log none
# Manager
Acl manager proto cache_object
Http_access allow manager all
Cachemgr_passwd pass all
---------------------- Cut here ---------------------------------
Create cache directory:
/Usr/local/squid/sbin/squid-z
Start squid
/Usr/local/squid/sbin/squid
Stop squid:
/Usr/local/squid/sbin/squid-k shutdown
Enable new Configuration:
/Usr/local/squid/sbin/squid-k reconfig
Use crontab to truncate/round-robin logs at every day:
0 0 *** (/usr/local/squid/sbin/squid-k rotate)
Appendix: SQUID performance test PhpMan. php is a php-based man page server.
Page needs to call man commands in the background and many page formatting tools. The system load is high and the Cache is provided.
Friendly URL. The following lists the performance test materials for the same page:
Test environment: Redhat 8 on Cyrix 266/192 M Mem
Test Program: Use apache AB (apache benchmark ):
Test condition: 50 requests and 50 concurrent connections
Test Project: directly through apache 1.3 (port 80) vs squid 2.5 (Port 8000: Port 80 for acceleration)
Test 1: Dynamic Output of port 80 without CACHE:
AB-n 100-c 10 [url] http://www.chedong.com: 81/phpMan. php/man/kill/1 [/url]
This is apachetings, Version 1.3d <$ Revision: 1.2 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd,
[Url] http://www.zeustech.net/#/url]
Copyright (c) 1998-2001 The Apache Group, [url] http://www.apache.org/#/url]
Benchmarking localhost (be patient) ...... done
Server Software:
Apache/1.3.23
Server Hostname: localhost
Server
Port:
80
Concurrency Level: 5
Time taken for tests: 63.164 seconds
Complete requests: 50
Failed requests: 0
Broken pipe errors: 0
Total transferred: 245900 bytes
HTML transferred: 232750 bytes
Requests per secondd: 0.79 [#/sec] (mean)
Time per request: 6316.40 [MS]
(Mean)
Time per request: 1263.28 [MS]
(Mean, internal SS all concurrent requests)
Transfer rate:
3.89 [Kbytes/sec] committed ed
Connnection Times (MS)
Min mean [+/-sd] median max
Connect: 0
29 106.1 0 553
Processing: 2942 6016
1845.4 6227 10796
Waiting:
2941 5999 1850.7 6226 10795
Total:
2942 6045 1825.9 6227 10796
Percentage of the requests served within a certain time (MS)
50% 6227
66% 7069
75% 7190
80% 7474
90% 8195
95% 8898
98% 9721
99% 10796
100% 10796 (last request)
Test 2: SQUID cache output
/Home/apache/bin/AB-n50-c5
"Http: // localhost: 8000/phpMan. php/man/kill/1"
This is apachetings, Version 1.3d <$ Revision: 1.2 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd,
[Url] http://www.zeustech.net/#/url]
Copyright (c) 1998-2001 The Apache Group, [url] http://www.apache.org/#/url]
Benchmarking localhost (be patient) ...... done
Server Software:
Apache/1.3.23
Server Hostname: localhost
Server
Port:
8000
Concurrency Level: 5
Time taken for tests: 4.265 seconds
Complete requests: 50
Failed requests: 0
Broken pipe errors: 0
Total transferred: 248043 bytes
HTML transferred: 232750 bytes
Requests per secondd: 11.72 [#/sec] (mean)
Time per request: 426.50 [MS] (mean)
Time per request: 85.30 [MS] (mean,
Using SS all concurrent requests)
Transfer rate:
58.16 [Kbytes/sec] committed ed
Connnection Times (MS)
Min mean [+/-sd] median max
Connect:
0 1
9.5 0 68
Processing:
7 83 537.4
7 3808
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.