srcache + mogilefs module

haad nginx-forum at nginx.us
Sat Apr 21 21:49:23 UTC 2012


agentzh Wrote:
-------------------------------------------------------
> On Sat, Apr 21, 2012 at 4:16 AM, haad
> <nginx-forum at nginx.us> wrote:
> > My problem is that it seems that even if I put
> files to memcache
> > manually and it srcache will find it (see log
> below), my file is still
> > served from mogilefs and not from memcached.
> >
> 
> What does the data you put into memcached look
> like? The ngx_srcache
> module requires the value to be the *whole*
> response, that is,
> including the status line and all those response
> headers.

It was simple string, so yes this was the problem.

> 
> Basically, you should rely on ngx_srcache's
> srcache_store to store the
> responses automatically for you, rather than
> inserting values into
> memcached yourself.

But from attached log or this new [1] dump it seems tat srcache_store is
never called.
I was not aware of this, it should be added to documentation :).

[1] https://gist.github.com/2439805


> 
> > 2012/04/20 21:28:21 [debug] 7385#0: *501
> memcached: "VALUE
> > /share/file.html 0 10" <---- WE got it
> 
> Yes, ngx_srcache got the value from memcached
> here.
> 
> > 2012/04/20 21:28:21 [error] 7385#0: *501
> srcache_fetch: cache sent
> > invalid status line while sending to client,
> client: 192.168.200.64,
> > server: ws01x.test.reality.sk, request: "GET
> /share/file.html HTTP/1.0",
> > subrequest: "/memc", upstream:
> "memcached://192.168.206.3:11211", host:
> > "192.168.200.64"
> 
> But here, ngx_srcache then found the value is
> invalid in that it does
> not have a valid HTTP status line at the
> beginning, so it immediately
> abandoned the cached value, and treated it as a
> cache miss.
> 
> >
> > From this log I can see why is file can't
> serverd from memcached, server
> > status 200.
> 
> Maybe I should make the debug log more verbose a
> bit here ;)
> 
> > Are srcache and mogilefs module somehow
> incompatible ?
> >
> 
> ngx_srcache is designed to be backend independent
> ;) If it's not, then
> there must be a bug somewhere ;)
> 
> In your case here, it seems to be the bad format
> of the data that you
> manually inserted into memcached.

I will try to add proper entry and try again, right now I would like to
know why
srcache_store do not work as expected. Here is config

	location = /memc {
 	   internal;
	   memc_connect_timeout 100ms;
	   memc_send_timeout 100ms;
	   memc_read_timeout 100ms;

	   set $memc_key $query_string;
	   set $memc_exptime 300;

	   memc_pass memcached_servers;
	}

	location /share/ {
	    set $key $uri;

	    srcache_fetch GET /memc $key;
	    srcache_store PUT /memc $key;
    	    srcache_store_statuses 200 301 302;
	    srcache_response_cache_control off;

      [snip]

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,225568,225597#msg-225597



More information about the nginx mailing list