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

**URL:** <https://www.ruby-forum.com/t/map-module-multiple-memcached-servers-port-number-not-passed-to-upstream-module/144451>\
**Category:** NGINX\
**Created:** [July 29, 2008, 7:52pm UTC](https://www.ruby-forum.com/t/map-module-multiple-memcached-servers-port-number-not-passed-to-upstream-module/144451 "2008-07-29T19:52:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kon\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e99b99/32.png) [@Kon\_W](https://www.ruby-forum.com/u/Kon_W)\
**Post date:** [July 29, 2008, 7:52pm UTC](https://www.ruby-forum.com/t/map-module-multiple-memcached-servers-port-number-not-passed-to-upstream-module/144451/1 "2008-07-29T19:52:38Z")

</div>

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. 🙂

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 🙂

Cheers  
Kon
