Plone mit vorgeschaltetem Apache und Squid
Ronny Wilde <[email protected]>
| Newsgroups | gmane.comp.web.zope.german |
|---|---|
| Organization | Privat |
| Message-ID | <[email protected]> |
Folgendes Problem: beim Editieren der Webseiten wird nie der aktuelle Inhalt
zurückgegeben sondern nur der Cache-Inhalt. Ständig muß mit F5 aktualisiert
werden.
Aufruf der Seite im Browser: http://www.example1.org:81.
Setup
squid:81 ---> apache-vhost:84 ----> plone:8080
/etc/hosts
127.0.0.1 www.example1.org
Apache vhost-config
Listen 127.0.0.1:84
<VirtualHost www.example1.org:84>
ServerName www.example1.org
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite_log"
RewriteLogLevel 9
# serving icons from apache 2 server
RewriteRule ^/icons/ - [L]
RewriteRule ^/(.*) \
http://localhost:8080/VirtualHostBase/http/%{SERVER_NAME}:81/Plone/VirtualHostRoot/$1
[L,P]
</IfModule>
</VirtualHost>
Squid config:
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
acl our_sites dstdomain www.example1.org
acl PURGE method GET
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
http_access allow our_sites
cache_peer 127.0.0.1 parent 84 0 no-query originserver name=myAccel
cache_peer_access myAccel allow all
#cache_peer_access myAccel allow our_sites
#cache_peer_access myAccel deny all
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access allow PURGE
http_access deny all
# Squid normally listens to port 3128
#http_port 3128
http_port 81 defaultsite=www.example1.org
#cache_peer 127.0.0.1 parent 84 0 no-query originserver name=myAccel
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /usr/local/squid/var/cache 128 16 256
# Leave coredumps in the first cache dir
coredump_dir /usr/local/squid/var/cache
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
cache_effective_user squid
cache_effective_group nogroup
cache_mem 50 MB
#always_direct allow all
cache_store_log /usr/local/squid/var/logs/cache_store.log
Performancetests:
ab2 -n 1000 -c 150 http://www.example1.org:81/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.example1.org (be patient)
Finished 1000 requests
Server Software: Zope/(2.12.16,
Server Hostname: www.example1.org
Server Port: 81
Document Path: /test
Document Length: 16926 bytes
Concurrency Level: 150
Time taken for tests: 178.003 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 17246000 bytes
HTML transferred: 16926000 bytes
Requests per second: 5.62 [#/sec] (mean)
Time per request: 26700.494 [ms] (mean)
Time per request: 178.003 [ms] (mean, across all concurrent requests)
Transfer rate: 94.62 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 10 24.9 0 78
Processing: 432 24927 6572.6 26179 35647
Waiting: 421 24927 6572.7 26179 35647
Total: 484 24938 6562.3 26179 35705
Auszug aus squid access.log
1299866618.347 23717 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866618.616 23702 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866618.662 23731 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866618.916 23697 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866618.953 23723 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866619.208 23686 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866619.248 23703 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
1299866619.374 23552 127.0.0.1 TCP_MISS/200 17246 GET
http://www.example1.org/test - FIRST_UP_PARENT/myAccel text/html
Ursache für TCP MISS ist der HEADER von Plone, Expiration Date
wget -S --delete-after http://www.example1.org:81/Plone/test
--2011-03-11 18:54:41-- http://www.example1.org:81/Plone/test
Auflösen des Hostnamen »www.example1.org«.... 127.0.0.1
Verbindungsaufbau zu www.example1.org|127.0.0.1|:81... verbunden.
HTTP Anforderung gesendet, warte auf Antwort...
HTTP/1.0 200 OK
Date: Fri, 11 Mar 2011 17:54:41 GMT
Server: Zope/(2.12.16, python 2.6.6, linux2) ZServer/1.1
Content-Length: 16931
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Content-Type: text/html;charset=utf-8
Content-Language: de
X-Cache: MISS from notebook
Via: 1.0 notebook (squid/3.1.11)
Connection: keep-alive
Länge: 16931 (17K) [text/html]
In »test« speichern.
100%[================================================================================================>]
16.931 --.-K/s in 0s
2011-03-11 18:54:41 (177 MB/s) - »test« gespeichert [16931/16931]
Nach Einrichtung in Plone von caching_policy_manager
wget -S --delete-after http://www.example1.org:81/Plone/test
--2011-03-11 18:57:27-- http://www.example1.org:81/Plone/test
Auflösen des Hostnamen »www.example1.org«.... 127.0.0.1
Verbindungsaufbau zu www.example1.org|127.0.0.1|:81... verbunden.
HTTP Anforderung gesendet, warte auf Antwort...
HTTP/1.0 200 OK
Date: Fri, 11 Mar 2011 17:57:27 GMT
Server: Zope/(2.12.16, python 2.6.6, linux2) ZServer/1.1
Content-Length: 16931
Content-Language: de
X-Cache-Headers-Set-By: CachingPolicyManager: /Plone/caching_policy_manager
Expires: Fri, 11 Mar 2011 18:57:27 GMT
Last-Modified: Fri, 11 Mar 2011 16:04:30 GMT
Cache-Control: max-age=3600, s-maxage=7200, must-revalidate, proxy-
revalidate
Content-Type: text/html;charset=utf-8
X-Cache: MISS from notebook
Via: 1.0 notebook (squid/3.1.11)
Connection: keep-alive
Länge: 16931 (17K) [text/html]
In »test« speichern.
100%[================================================================================================>]
16.931 --.-K/s in 0s
2011-03-11 18:57:27 (139 MB/s) - »test« gespeichert [16931/16931]
Entferne »test«.
ab2 -n 1000 -c 150 http://www.example1.org:81/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.example1.org (be patient)
Finished 1000 requests
Server Software: Zope/(2.12.16,
Server Hostname: www.example1.org
Server Port: 81
Document Path: /test
Document Length: 31864 bytes
Concurrency Level: 150
Time taken for tests: 1.225 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 32396000 bytes
HTML transferred: 31864000 bytes
Requests per second: 816.47 [#/sec] (mean)
Time per request: 183.718 [ms] (mean)
Time per request: 1.225 [ms] (mean, across all concurrent requests)
Transfer rate: 25830.41 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 9.1 0 39
Processing: 31 171 38.5 169 765
Waiting: 15 75 33.6 81 649
Total: 58 175 35.1 169 765
Auszug aus dem squid access.log
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
1299867000.896 58 127.0.0.1 TCP_MEM_HIT/200 17456 GET
http://www.example1.org/test - NONE/- text/html
Jetzt klappt es auch mit der Performance und dem cachen.
Requests per second: 816.47 [#/sec] (mean) gegenüber
Requests per second: 5.62 [#/sec] (mean)
TCP_MEM_HIT/200 gegenüber TCP_MISS/200
Nun besteht aber obiges Problem. Was nun?
_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope