简体   繁体   中英

Is it possible to run multiple instances of the same application with a single memcached server?

I'm with a problem on dockerized applications and Memcached, to store some values, apparently, when a start a new Docker instance, that runs a Spymemcached client, all the data stored in the cache are invalidate, so If I previously stored some values on cache at Node 1 and then I start Node 2, theses values are cleaned from the Memcached server, and finally if a store the same values again on Node 1 and query it on Node 2 they will be shared beyond both nodes without clean the data. Is it the expected behavior? Should I use a Memcached server for each client instance? Or is it possible to share the same Memcached server instance to multiples client without lost the stored data?

You can share the same memcached instance with multiple clients.

You just need to create different docker containers for Node1, Node2 and memcached.

Create them on same container network. a sample docker-compose.yml .

version: '2'
services:
   node1:
     image: <your-image>:latest
     network:
       main:
          aliases:
             - node1
  node2:
     image: <your-image>:latest
     network:
       main:
          aliases:
             - node2
  memcached:
     image: memcached:latest
     network:
       main:
          aliases:
             - memcached
network:
   main:

I migrated the Memcached client library to Folsom from Spotify and solved my problem. A curiosity about Spymencached, the problem I mentioned occurrs only when clients are running on Windows machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM