[uWSGI] how to properly set nodes and udp in cache2 config

Lu Liu nudtlliu at gmail.com
Wed Oct 16 04:10:46 CEST 2013


Hi there,

I have two uwsgi servers (let me call them master and slave) that need
to sync some in-memory data via cache2. I wrote such config on the
master whose ip is 10.1.1.11:

[uwsgi]
vaccum = true
workers = 4
cpu-affinity = 1
master = true
need-app = true
manage-script-name = true
enable-threads = true
socket = /tmp/uwsgi0.sock
socket = /tmp/uwsgi1.sock
socket = /tmp/uwsgi2.sock
socket = /tmp/uwsgi3.sock
map-socket = 0:1
map-socket = 1:2
map-socket = 2:3
map-socket = 3:4
mount = /test=/home/lliu/test/test-wsgi.py
daemonize = /var/log/test/running.log
max-requests = 1024
listen = 1024
cache2 = name=test-conf-cache,items=8192,blocksize=2048,store=/shared_disk/test_cache2.dump,nodes=10.1.1.12:7171,udp=10.1.1.11:7171

on the slave server whose ip is 10.1.1.12:
[uwsgi]
vaccum = true
workers = 4
cpu-affinity = 1
master = true
need-app = true
manage-script-name = true
enable-threads = true
socket = /tmp/uwsgi0.sock
socket = /tmp/uwsgi1.sock
socket = /tmp/uwsgi2.sock
socket = /tmp/uwsgi3.sock
map-socket = 0:1
map-socket = 1:2
map-socket = 2:3
map-socket = 3:4
mount = /test=/home/lliu/test/test-wsgi.py
daemonize = /var/log/test/running.log
max-requests = 1024
listen = 1024
cache2 = name=test-conf-cache,items=8192,blocksize=2048,store=/shared_disk/test_cache2.dump

The dump file test_cache2.dump is stored on an NFS partition mounted
at /shared_disk accessible to both of the master and slave. However,
after I start up the two uwsgi services, the change of cache2 (e.g.
add a new item via cache_set api) on the master can not be propagated
to the slave. I actually tried other cache2 settings, like:

cache2 = name=test-conf-cache,items=8192,blocksize=2048,store=/shared_disk/test_cache2.dump,nodes=10.1.1.12:7171,udp=10.1.1.11:7171
cache2 = name=test-conf-cache,items=8192,blocksize=2048,store=/shared_disk/test_cache2.dump,nodes=127.0.0.1:7172,udp=127.0.0.1:7171
cache2 = name=test-conf-cache,items=8192,blocksize=2048,sync=10.1.1.11,nodes=127.0.0.1:7172,udp=127.0.0.1:7171

but none of those worked. The iptables service on both servers are stopped.

So how to properly config the udp sync in cache2? Is the syncing
action in real-time? Many thanks in advance!

best

lliu


More information about the uWSGI mailing list