apache 2, mod_deflate, mod_fastcgi, zope 2.7: something's slow.
Hello, It seems that if I use mod_deflate to compress zope's responses, I take a major hit -- around 1.4 seconds without compression and around 16.4 seconds with. I can't figure out what I'm doing wrong here. I have zope 2.7.7 running with the fast-cgi ZServer enabled. Urls beginning with http://pkfinance.info/pkf-z1/ go to Zope. Here's what I see: a% /usr/bin/time curl -v -o /dev/null http://pkfinance.info/pkf-z1/news/index_html * About to connect() to pkfinance.info <http://pkfinance.info> port 80 * Trying 207.210.209.230... connected * Connected to pkfinance.info <http://pkfinance.info> (207.210.209.230<http://207.210.209.230>) port 80
GET /pkf-z1/news/index_html HTTP/1.1 User-Agent: curl/7.14.0 (i386-portbld-freebsd4.11) libcurl/7.14.0 OpenSSL/0.9.7d zlib/1.1.4 Host: pkfinance.info <http://pkfinance.info> Accept: */*
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0< HTTP/1.1 200 OK < Date: Wed, 17 Aug 2005 06:57:57 GMT < Server: Apache/2.0.54 (FreeBSD) DAV/2 PHP/4.3.11 mod_webkit2/0.5 mod_fastcgi/2.4.2 < X-Powered-By: Zope (www.zope.org <http://www.zope.org>), Python ( www.python.org <http://www.python.org>) < Content-Length: 65751 < Vary: Accept-Encoding,User-Agent < Content-Type: text/html; charset=ISO-8859-1 100 65751 100 65751 0 0 44744 0 0:00:01 0:00:01 --:--:-- 196k* Connection #0 to host pkfinance.info <http://pkfinance.info> left intact * Closing connection #0 1.48 real 0.00 user 0.00 sys a% a% /usr/bin/time curl --compressed -v -o /dev/null http://pkfinance.info/pkf-z1/news/index_html * About to connect() to pkfinance.info <http://pkfinance.info> port 80 * Trying 207.210.209.230... connected * Connected to pkfinance.info <http://pkfinance.info> (207.210.209.230<http://207.210.209.230>) port 80
GET /pkf-z1/news/index_html HTTP/1.1 User-Agent: curl/7.14.0 (i386-portbld-freebsd4.11) libcurl/7.14.0 OpenSSL/0.9.7d zlib/1.1.4 Host: pkfinance.info <http://pkfinance.info> Accept: */* Accept-Encoding: deflate, gzip
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0< HTTP/1.1 200 OK < Date: Wed, 17 Aug 2005 07:00:10 GMT < Server: Apache/2.0.54 (FreeBSD) DAV/2 PHP/4.3.11 mod_webkit2/0.5 mod_fastcgi/2.4.2 < X-Powered-By: Zope (www.zope.org <http://www.zope.org>), Python ( www.python.org <http://www.python.org>) < Content-Length: 65751 < Vary: Accept-Encoding,User-Agent < Content-Encoding: gzip < Content-Type: text/html; charset=ISO-8859-1 13 65751 13 8719 0 0 530 0 0:02:04 0:00:16 0:01:48 0transfer closed with 57032 bytes remaining to read 13 65751 13 8719 0 0 530 0 0:02:04 0:00:16 0:01:48 0* Closing connection #0 curl: (18) transfer closed with 57032 bytes remaining to read 16.46 real 0.01 user 0.01 sys a% The relevant bits of my httpd.conf: <IfModule mod_fastcgi.c> FastCgiExternalServer /home/pkf/www/docs/pkfinance.info/pkf-z1 -socket /home/pkf/pkf-z1/var/fcgi-socket -pass-header Authorization </IfModule> <VirtualHost *> ServerName pkfinance.info <http://pkfinance.info> ServerAlias www.pkfinance.info <http://www.pkfinance.info> ServerAdmin faried@gmail.com DocumentRoot /home/pkf/www/docs/pkfinance.info ErrorLog /home/pkf/www/logs/pkfinance.info/error.log CustomLog /home/pkf/www/logs/pkfinance.info/access.log combined # zope <IfModule mod_fastcgi.c> <Location /pkf-z1> SetHandler fastcgi-script SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary Header append Vary User-Agent env=!dont-vary </Location> DeflateFilterNote Input instream DeflateFilterNote Output outstream DeflateFilterNote Ratio ratio LogFormat '%t "%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate CustomLog /home/pkf/www/logs/pkfinance.info/deflate.log deflate </IfModule> </VirtualHost> In my deflate log I see stuff like [16/Aug/2005:11:40:03 -0500] "GET /pkf-z1/news/index_html HTTP/1.1" 8852/64328 (13%) Thanks, Faried.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Faried Nawaz wrote:
It seems that if I use mod_deflate to compress zope's responses, I take a major hit -- around 1.4 seconds without compression and around 16.4 seconds with. I can't figure out what I'm doing wrong here.
I have zope 2.7.7 running with the fast-cgi ZServer enabled. Urls beginning with http://pkfinance.info/pkf-z1/ go to Zope. Here's what I see:
You seem to be running Apache and Zope on the same host, and trying to use the same constrained resource (CPU) from each. You might be able to improve performance by running Apache on a separate box, where it won't "steal" CPU from Zope to do the compression. Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDA1NH+gerLs4ltQ4RAlmRAKC3QtsQFjbmGVyAsC4A0j/go/G1GQCfXhG5 KzpIFjJRnIwJJPoL19X0TvI= =BUsz -----END PGP SIGNATURE-----
I tried messing with it some more, and it seems that the fix was to place <tal:foo define="ret python: container.REQUEST.RESPONSE.enableHTTPCompression(container.REQUEST)" tal:omit-tag="" /> somewhere near the top of my template. I didn't realize I needed compression enabled in zope; I thought apache's mod_deflate would be sufficient. Someone should add this to the docs or wiki or someplace. Faried.
Faried Nawaz wrote at 2005-8-17 12:21 +0500:
It seems that if I use mod_deflate to compress zope's responses, I take a major hit -- around 1.4 seconds without compression and around 16.4 seconds with. I can't figure out what I'm doing wrong here.
Looks as if you should not use "mod_deflate". Zope can perform "gzip" compression by itself. -- Dieter
On 8/18/05, Dieter Maurer <dieter@handshake.de> wrote:
Looks as if you should not use "mod_deflate".
Zope can perform "gzip" compression by itself.
As you probably read in my previous email, I have rules defined in Apache to handle various browsers and proxies when dealing with possibly gzip'd content. How do I do the same in Zope? (Also, I have static content on the site that can benefit from mod_deflate.)
Faried Nawaz wrote at 2005-8-18 02:12 +0500:
On 8/18/05, Dieter Maurer <dieter@handshake.de> wrote:
Looks as if you should not use "mod_deflate".
Zope can perform "gzip" compression by itself.
As you probably read in my previous email, I have rules defined in Apache to handle various browsers and proxies when dealing with possibly gzip'd content. How do I do the same in Zope?
Zope's "gzip" support is enabled (for a single request) by calling "RESPONSE.enableHTTPCompression" in that request. You have all request headers and the full power of Python available to dertermine when you want to call it (this gives you more power than you have in Apache).
(Also, I have static content on the site that can benefit from mod_deflate.)
If "static content" means "File/Image" objects, then their so called "precondition" can get the "enableHTTPCompression". Check beforehand, whether compression really saves something. While I expect it for "bmp", I am not so sure for "jpg", e.g. -- Dieter
participants (3)
-
Dieter Maurer -
Faried Nawaz -
Tres Seaver