agentzh
June 17, 2012 10:12AM
Hello!

On Sun, Jun 17, 2012 at 8:06 PM, amodpandey <nginx-forum@nginx.us> wrote:
> I have a memcache cluster (multiple
> nodes). So I defined an
>
> upstream memcached_pass_stream {
>  server node1:11211;
>  server node2:11211;
>  server node3:11211;
>  server node4:11211;
> }
>
> And I pass it
> memcached_pass $scheme://memcached_pass_stream/;
>
> I am using memcached cluster (AWS ElastiCache)
>
> Q1 I hope this is the right way to integrate with multiple nodes.
>

No, unless all your memcached nodes are read-only and contain exactly
the same data copy.

> Q2 If yes, what logic nginx follows to pick the nodes? I should use
> similar logic to set data else there might be many misses.
>

By default, round-robin is used to pick up nodes. You can do key
modulo hashing by means of the set_hashed_upstream directive provided
by the ngx_set_misc module:

http://wiki.nginx.org/HttpSetMiscModule#set_hashed_upstream

Alternatively, you can just use some Lua code to calculate the backend
upstream name in arbitrary way that you like for each individual
request. See ngx_lua for details. And here's an example that
determines a backend for proxy_pass on-the-fly by querying a redis
backend via a little Lua code:

http://openresty.org/#DynamicRoutingBasedOnRedis

The basic idea is essentially the same.

Regards,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to set html files into memcache

amodpandey June 16, 2012 06:11PM

Re: How to set html files into memcache

agentzh June 17, 2012 03:04AM

Re: How to set html files into memcache

amodpandey June 17, 2012 08:06AM

Re: How to set html files into memcache

agentzh June 17, 2012 10:12AM

Re: How to set html files into memcache

amodpandey June 17, 2012 06:20PM

Re: How to set html files into memcache

amodpandey June 19, 2012 10:00PM

Re: How to set html files into memcache

agentzh June 17, 2012 11:44PM

Re: How to set html files into memcache

agentzh June 20, 2012 02:26AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 129
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready