Set generated PHP output to Memcached server by Nginx transparently

Hi,

I have set up for NginxHttpMemcachedModule and it works great reading
output that I have set to Memcached server through my OWN PHP code. But
that means I have to modify my PHP code to make it happens and sometimes
it is not easy if the code is third party. I really think it would be
more beneficial if the NginxHttpMemcachedModule could set the generated
PHP output into Memcached server. By doing so, I don’t have to modify
PHP code to make it happen and it offers much better maintenance, using
Nginx server as the Memcache (cluster) Proxy.

Basically I need to be able to read PHP output from Memcached server:

  1. If there is PHP output in the Memcached server given $uri, use it
  2. If not, use fallback to the fastcgi or PHP-FPM
  3. The generated PHP output of step 2 is set to the Memcached server BY
    NGINX TRANSPARENTLY (no PHP code change but just Nginx configuration) to
    the Memcached server so it can be read next time on step 1.

I notice that there is another module call NginxHttpMemcModule. It seems
that it could do the trick but I am not sure by looking at the
configuration example in the wiki.

Could someone provide some insight on this issue?

Thanks!
– Jin Kuang

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

This is like the Holy Grail. See my similar request here
http://forum.nginx.org/read.php?2,117833.

However, the answer I got was on the cryptic side with the only thing I
could make out being it is not a good idea with proxy which I use as at
yet so I gave up.

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

However, the answer I got was on the cryptic side with the only thing I
could make out being it is not a good idea with proxy which I use as at
yet so I gave up.

Cryptic?

The module http://github.com/agentzh/srcache-nginx-module has the
ability to
“cache” - store subrequest response in memcached backend (combined with
memc
or any other module).

rr

Dayo, thank you for the response. It seem that is what I am looking
for. I am going to try it out and see if it works.

Given the fact that this is still on the “bleeding edge” side of Nginx
usage, I am thinking it might be better off if I will just use a
“middleware” PHP to handle the update to the memcached server.

  1. If there is PHP output in the Memcached server cluster given $uri,
    use it (with header stuff set)

  2. If not, REWRITE the URL for
    http://mysite.com/memcached_update.php?location=the_original_url

This memcached_update.php will open up a output buffer, perform a url
get for the content of the original url, store the buffered content in
memcached server (unfortunately that means this PHP will need to perform
memcached server look up and cluster management in a clustered memcached
environment) and return the content

  1. Next time the same location is requested, we should have the content
    available in the memcached server cluster.

This should not have impact on the original application as the
“middleware” PHP is generic. But still it is a messy hack. It is not
“pretty”

I really hope NginxHttpMemcachedModule or NginxHttpMemcModule should
bundle this critical capability in the modules directly. It seems so
obviouos this job belongs to these two modules.

Thanks
– Jin Kuang

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs