Map module & multiple memcached servers -port number not passed to upstream module

Hi folks,

First thanks for a great product, I’m migrating a cluster to a single
machine, replacing with nginx, and if the testing works out it will
serve 1 billion requests a month on average on what previously took a
good number of servers running lighty. :slight_smile:

I’m having an issue with the map module and using it to pass
parameters to the memcached module. I am running multiple memcached
servers and I want to distribute requests to them based on a fixed URL
(which maps to a backend application server).

Given the following map directive to distribute resources across
memcached servers:

map $uri $mcs {
default 127.0.0.1:11401;
/resource-1 127.0.0.1:11401;
/resource-2 127.0.0.1:11401;
/resource-3 127.0.0.1:11402;
/resource-4 127.0.0.1:11403;
}

The following when attempting to start nginx returns an error message
that the port is missing for upstream module (memcached_pass $mcs
directive is the fault):

location /resource-1
{
expires -1;
add_header Cache-Control no-cache;
set $memcached_key $uri;
memcached_pass $mcs;
break;
}

Right now I have just duplicated the resource-nnn multiple times, and
not used the map. But since I have 20+ resources across 6 memcached
servers this seems unoptimal when hitting the last resource as all the
previous directives need to be iterated.

Any advice appreciated :slight_smile:

Cheers
Kon

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