Reverse Proxy-based Web Cache accelerates modern Server Management

Source: Internet
Author: User
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
<Virtualhost *>
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
</Virtualhost>
  
   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
  
Document path:
/Phpman. php/man/kill/1
Document length: 4655 bytes
  
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
  
Document path:
/Phpman. php/man/kill/1
Document length: 4655 bytes
  
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
  
Waiting:
5 81 529.1
6 3748
  
Total:
7 84 547.0
7 3876
  
Perce

 

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.