memcached not caching
rhjheins
nginx-forum at nginx.us
Fri Dec 4 01:37:49 MSK 2009
Currently I am testing nginx as a reverse-proxy/load ballencer and the basic setup is working perfect. But memcached is not caching any content
System: Ubuntu 9.10 server with nginx (from ubuntu repository) and memcached (from ubuntu repository)
I have three backend server presumed named server1, server2, server 3 and the nginx server is called nginx_test
My nginx.conf:
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
server_tokens off;
upstream cluster {
server server1 ip addr weight=1
server server2 ip addr weight=1;
server server3 ip addr weight=1;
}
server {
listen nginxserver ip addr:80;
server_name nginx_test;
location / {
expires max;
set $memcached_key $uri;
default_type text/html;
memcached_pass localhost:11211;
error_page 404 502 = @cache_miss;
}
location @cache_miss {
proxy_pass http://cluster;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffers 8 32k;
}
# requesting nginx status
location /nginx_status {
stub_status on;
access_log off;
allow all;
}
}
#gzip
gzip on;
gzip_http_version 1.0;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_comp_level 5;
gzip_proxied any;
gzip_types text/plain text/css application/javascript text/javascript text/xml application/x-javascript;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}
restarting nginx gives no faults and when using the reverse_proxy everything works but the memcached part is not resulting in faster loading of the pages. when I telnet into memcached en give the command stats it shows no cached objects:
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 11415
STAT uptime 1725
STAT time 1259879709
STAT version 1.2.8
STAT pointer_size 32
STAT rusage_user 0.008000
STAT rusage_system 0.024001
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 5
STAT total_connections 217
STAT connection_structures 8
STAT cmd_flush 0
STAT cmd_get 210
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 210
STAT evictions 0
STAT bytes_read 5947
STAT bytes_written 1588
STAT limit_maxbytes 171966464
STAT threads 5
STAT accepting_conns 1
STAT listen_disabled_num 0
Anny suggestions???
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,27843,27843#msg-27843
More information about the nginx
mailing list