Which one is better?

I still wonder which one is better for performance

Pure nginx + php-fpm

Or

Nginx + apache2 + proxy_cache

Anybody knows about this?

On Tue, Apr 21, 2009 at 01:20:05PM +0700, Glen L. wrote:

I still wonder which one is better for performance

Pure nginx + php-fpm

Or

Nginx + apache2 + proxy_cache

Anybody knows about this?

Can not say about apache2 vs php-fpm, but you can use fastcgi_cache too.

Is there any help page regarding fastcgi_cache? Or it’s the same format
as
proxy_cache?

On Tue, Apr 21, 2009 at 03:10:31PM +0700, Glen L. wrote:

Is there any help page regarding fastcgi_cache? Or it’s the same format as
proxy_cache?

Yes, just s/proxy/fastcgi/.

The single difference is that fastcgi cache requires

  fastcgi_cache_key   localhost:9000$request_uri;

while proxy_cache may use default one, similar to this:

proxy_cache_key $scheme$proxy_host$uri$is_args$args;

I already tried this

Here’s the config

fastcgi_cache_path  /data/nginx/cache  levels=1:2 keys_zone=one:10m

inactive=7d max_size=200m;
fastcgi_temp_path /data/nginx/temp;

    location @joomla {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME 

/home/kompastv/web/index.php;
fastcgi_cache one;
fastcgi_cache_key 127.0.0.1:9000$request_uri;
fastcgi_cache_valid 200 1h;

/data/nginx/cache and /data/nginx/temp is still empty

root 28119 0.0 0.0 13940 496 ? Ss 15:41 0:00 nginx:
master process /etc/nginxnew/sbin/nginx -c /etc/nginx/nginx.conf
nginx 28120 1.3 0.2 17328 4408 ? R 15:41 0:01 nginx:
worker process
nginx 28122 1.6 0.2 17384 4540 ? S 15:41 0:01 nginx:
worker process
nginx 28123 0.0 0.0 14096 800 ? S 15:41 0:00 nginx:
cache manager process

is there somethink i’ve missed?

On Tue, Apr 21, 2009 at 03:44:28PM +0700, Glen L. wrote:

        fastcgi_param  SCRIPT_FILENAME  /home/kompastv/web/index.php;

nginx 28122 1.6 0.2 17384 4540 ? S 15:41 0:01 nginx:
worker process
nginx 28123 0.0 0.0 14096 800 ? S 15:41 0:00 nginx:
cache manager process

is there somethink i’ve missed?

Does fastcgi return Expires or Cache-Control headers which may forbid
caching ?

How do i check that? Becase i’m using default configuration

On Tue, Apr 21, 2009 at 04:02:57PM +0700, Glen L. wrote:

How do i check that? Becase i’m using default configuration

If you use Firefox:
http://livehttpheaders.mozdev.org

Could you create debug log ?

Please check http://pastebin.com/d448b8b03

I’ve uploaded the livehttpheaders

On Tue, Apr 21, 2009 at 05:49:24PM +0700, Glen L. wrote:

Please check http://pastebin.com/d448b8b03

I’ve uploaded the livehttpheaders

At least

http://www.kompas-tv.com/modules/mod_smo_ajax_shoutbox_css.php

should be cacheable. Probably it is handled by not @joomla, but by
something like location ~ “.php$”.

On Tue, Apr 21, 2009 at 05:51:57PM +0700, Glen L. wrote:

“/data/nginx/cache/c/94/179da50f035455138b0ac1070c64494c”

[root@mp-ws-06 nginx-0.7.52]# cd /data/nginx/cache/
[root@mp-ws-06 cache]# ls -al
total 8
drwx------ 2 kompastv root 4096 Apr 21 15:36 .
drwxr-xr-x 4 root root 4096 Apr 21 15:36 …

Could you run

egrep ‘cacheable|error|crit’ /var/log/nginx/error.log

?

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME
/home/myhome/web$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_cache one;
fastcgi_cache_key 127.0.0.1:9000$request_uri;
fastcgi_cache_valid 200 1h;
include /etc/nginx/fastcgi_params;
}

It seems that the /data/nginx/cache directory now have some files :smiley:

So that the location which is go to @joomla will be cached aswell?

[root@mp-ws-06 nginx-0.7.52]# tail -f /var/log/nginx/error.log | grep
data
2009/04/21 17:51:21 [debug] 30424#0: cache file:
“/data/nginx/cache/3/06/6fecda1e6dc4d639bbfabfe771b63063”
2009/04/21 17:51:21 [debug] 30424#0: cache file:
“/data/nginx/cache/8/00/7df93c5fa8eb0301382ec66dc9e54008”
2009/04/21 17:51:23 [debug] 30425#0: cache file:
“/data/nginx/cache/5/db/bc8df465ca5a5c053713a34370befdb5”
2009/04/21 17:51:24 [debug] 30424#0: cache file:
“/data/nginx/cache/5/db/bc8df465ca5a5c053713a34370befdb5”
2009/04/21 17:51:24 [debug] 30424#0: cache file:
“/data/nginx/cache/c/94/179da50f035455138b0ac1070c64494c”

[root@mp-ws-06 nginx-0.7.52]# cd /data/nginx/cache/
[root@mp-ws-06 cache]# ls -al
total 8
drwx------ 2 kompastv root 4096 Apr 21 15:36 .
drwxr-xr-x 4 root root 4096 Apr 21 15:36 …

http://pastebin.com/d45d76e4d

On Tue, Apr 21, 2009 at 06:41:31PM +0700, Glen L. wrote:

It seems that the /data/nginx/cache directory now have some files :smiley:

BTW, it will be cached till Expires header.

On Tue, Apr 21, 2009 at 06:41:31PM +0700, Glen L. wrote:

It seems that the /data/nginx/cache directory now have some files :smiley:

So that the location which is go to @joomla will be cached aswell?

Yes.

On Tue, Apr 21, 2009 at 02:49:33PM -0400, Jonathan V. wrote:

through php:

Anyone have a clue ?

Oh, and this is on nginx 0.6.34:

Build nginx with debug log, then grep the lines:

test location: “…”
test location: “…”
test location: “…”
test location: “…”
using configuration “…”

This command serves the right directories, and pipes them through php:

location /careers) {
    root /home/artwelove/_current/web/www.artwelove.com-news/news;

include /usr/local/nginx/_macros/php.conf;
index index.php index.html;
}

This command serves the right directories, but does not pipe them
through php:

location ~ /careers {
    root /home/artwelove/_current/web/www.artwelove.com-news/news;

include /usr/local/nginx/_macros/php.conf;
index index.php index.html;
}

I can’t figure this one out… This is a simplified example, but just
changing the location to a regex kills the php ability

Anyone have a clue ?

Oh, and this is on nginx 0.6.34:

// Jonathan V.

e. [email protected]
w. FindMeOn®.com : connect your online profiles
blog. http://destructuring.net

| - - - - - - - - - -
| Founder/CEO - FindMeOn, Inc.
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| - - - - - - - - - -
| CTO - ArtWeLove, LLC
| ArtWeLove.com - Explore Art On Your Own Terms
| - - - - - - - - - -
| Founder - SyndiClick
| RoadSound.com - Tools for Bands, Stuff for Fans
| - - - - - - - - - -

On Apr 21, 2009, at 4:31 PM, Igor S. wrote:

Build nginx with debug log, then grep the lines:

test location: “…”
test location: “…”
test location: “…”
test location: “…”
using configuration “…”

i get the text below ; it makes no sense to me while PHP gets ignored
from this.

2009/04/21 22:31:55 [debug] 20025#0: *48 using configuration “^/(rsvp|
pages|careers)/”
2009/04/21 22:31:55 [debug] 20025#0: *48 http cl:-1 max:1048576
2009/04/21 22:31:55 [debug] 20025#0: *48 generic phase: 3
2009/04/21 22:31:55 [debug] 20025#0: *48 http script value: “/home/
artwelove/_current/web/www.artwelove.com-downtime/-news”
2009/04/21 22:31:55 [debug] 20025#0: *48 http script file op
0000000000000000 “/home/artwelove/_current/web/www.artwelove.com-
downtime/-news”
2009/04/21 22:31:55 [debug] 20025#0: *48 add cleanup: 00000000006A7DA8
2009/04/21 22:31:55 [debug] 20025#0: *48 http script file op false
2009/04/21 22:31:55 [debug] 20025#0: *48 http script if
2009/04/21 22:31:55 [debug] 20025#0: *48 http script if: false
2009/04/21 22:31:55 [debug] 20025#0: *48 post rewrite phase: 4
2009/04/21 22:31:55 [debug] 20025#0: *48 generic phase: 5
2009/04/21 22:31:55 [debug] 20025#0: *48 generic phase: 6
2009/04/21 22:31:55 [debug] 20025#0: *48 access phase: 7
2009/04/21 22:31:55 [debug] 20025#0: *48 access phase: 8
2009/04/21 22:31:55 [debug] 20025#0: *48 post access phase: 9
2009/04/21 22:31:55 [debug] 20025#0: *48 content phase: 10
2009/04/21 22:31:55 [debug] 20025#0: *48 content phase: 11
2009/04/21 22:31:55 [debug] 20025#0: *48 content phase: 12
2009/04/21 22:31:55 [debug] 20025#0: *48 http filename: “/home/
artwelove/_current/web/www.artwelove.com-news/news/careers/intern-
technology-developer/index.php”
2009/04/21 22:31:55 [debug] 20025#0: *48 add cleanup: 00000000006A7E40
2009/04/21 22:31:55 [debug] 20025#0: *48 http static fd: 6
2009/04/21 22:31:55 [debug] 20025#0: *48 http set discard body
2009/04/21 22:31:55 [debug] 20025#0: *48 HTTP/1.1 200 OK
Server: nginx/0.6.36
Date: Tue, 21 Apr 2009 22:31:55 GMT
Content-Type: application/octet-stream
Content-Length: 15954
Last-Modified: Tue, 21 Apr 2009 19:20:50 GMT
Connection: keep-alive
Accept-Ranges: bytes

2009/04/21 22:31:55 [debug] 20025#0: *48 write new buf t:1 f:0
00000000006A7FD8, pos 00000000006A7FD8, size: 233 file: 0, size: 0
2009/04/21 22:31:55 [debug] 20025#0: *48 http write filter: l:0 f:0 s:
233
2009/04/21 22:31:55 [debug] 20025#0: *48 http output filter “/careers/
intern-technology-developer/index.php?”
2009/04/21 22:31:55 [debug] 20025#0: *48 copy filter: “/careers/intern-
technology-developer/index.php?”
2009/04/21 22:31:55 [debug] 20025#0: *48 malloc: 000000000069B780:4096
2009/04/21 22:31:55 [debug] 20025#0: *48 http postpone filter “/
careers/intern-technology-developer/index.php?” 00007FFF259EEA00
2009/04/21 22:31:55 [debug] 20025#0: *48 http postpone filter out “/
careers/intern-technology-developer/index.php?”
2009/04/21 22:31:55 [debug] 20025#0: *48 write old buf t:1 f:0
00000000006A7FD8, pos 00000000006A7FD8, size: 233 file: 0, size: 0
2009/04/21 22:31:55 [debug] 20025#0: *48 write new buf t:0 f:1
0000000000000000, pos 0000000000000000, size: 0 file: 0, size: 15954
2009/04/21 22:31:55 [debug] 20025#0: *48 http write filter: l:1 f:0 s:
16187
2009/04/21 22:31:55 [debug] 20025#0: *48 http write filter limit 0
2009/04/21 22:31:55 [debug] 20025#0: *48 writev: 233
2009/04/21 22:31:55 [debug] 20025#0: *48 sendfile: @0 15954
2009/04/21 22:31:55 [debug] 20025#0: *48 sendfile: 15954, @0 15954:15954
2009/04/21 22:31:55 [debug] 20025#0: *48 http write filter
0000000000000000
2009/04/21 22:31:55 [debug] 20025#0: *48 copy filter: 0 “/careers/
intern-technology-developer/index.php?”
2009/04/21 22:31:55 [debug] 20025#0: *48 http finalize request: 0, “/
careers/intern-technology-developer/index.php?”
2009/04/21 22:31:55 [debug] 20025#0: *48 set http keepalive handler
2009/04/21 22:31:55 [debug] 20025#0: *48 http close request
2009/04/21 22:31:55 [debug] 20025#0: *48 http log handler
2009/04/21 22:31:55 [debug] 20025#0: *48 run cleanup: 00000000006A7E40
2009/04/21 22:31:55 [debug] 20025#0: *48 file cleanup: fd:6
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 00000000006A7100,
unused: 16
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 000000000069B780,
unused: 3704
2009/04/21 22:31:55 [debug] 20025#0: *48 event timer add: 3:
65000:1240353180219
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 0000000000708FF0
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 00000000007368C0
2009/04/21 22:31:55 [debug] 20025#0: *48 hc free: 0000000000000000 0
2009/04/21 22:31:55 [debug] 20025#0: *48 hc busy: 0000000000000000 0
2009/04/21 22:31:55 [debug] 20025#0: *48 tcp_nodelay
2009/04/21 22:31:55 [debug] 20025#0: *48 post event 00000000006D24F0
2009/04/21 22:31:55 [debug] 20025#0: *48 delete posted event
00000000006D24F0
2009/04/21 22:31:55 [debug] 20025#0: *48 http keepalive handler
2009/04/21 22:31:55 [debug] 20025#0: *48 malloc: 0000000000708FF0:1024
2009/04/21 22:31:55 [debug] 20025#0: *48 recv: fd:3 -1 of 1024
2009/04/21 22:31:55 [debug] 20025#0: *48 recv() not ready (11:
Resource temporarily unavailable)
2009/04/21 22:31:55 [debug] 20025#0: *48 http keepalive handler
2009/04/21 22:31:55 [debug] 20025#0: *48 recv: fd:3 0 of 1024
2009/04/21 22:31:55 [info] 20025#0: *48 client 64.0.35.34 closed
keepalive connection
2009/04/21 22:31:55 [debug] 20025#0: *48 close http connection: 3
2009/04/21 22:31:55 [debug] 20025#0: *48 event timer del: 3:
1240353180219
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 0000000000708FF0
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 0000000000000000
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 0000000000000000
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 000000000069ADF0,
unused: 8
2009/04/21 22:31:55 [debug] 20025#0: *48 free: 00000000007094D0,
unused: 96

// Jonathan V.

e. [email protected]
w. FindMeOn®.com : connect your online profiles
blog. http://destructuring.net

| - - - - - - - - - -
| Founder/CEO - FindMeOn, Inc.
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| - - - - - - - - - -
| CTO - ArtWeLove, LLC
| ArtWeLove.com - Explore Art On Your Own Terms
| - - - - - - - - - -
| Founder - SyndiClick
| RoadSound.com - Tools for Bands, Stuff for Fans
| - - - - - - - - - -

you forgot to include what your php.conf or whatever it was says