[uWSGI] Issue with uwsgi caching

Pinakee BIswas pinakee at waltzz.com
Thu Mar 17 11:14:38 CET 2016


Hi,

I have been trying to configure uwsgi cache on my production system but 
it's not working properly. If I browse a url for more than 2 times (to 
check if the cache is working), the response is garbage (seems like the 
cache is getting corrupted).

Following is the uwsgi configuration:

[uwsgi]
chdir=/home/path/to/django project
wsgi-file = django project/wsgi.py
master=True
socket=:7090
max-requests=5000
processes = 4
threads = 2
daemonize=/var/log/uwsgi-emperor.log
enable-threads = true
single-interpreter = true
#harakiri = 30
stats = 127.0.0.1:9191

; create a cache with 5000 items (default size per-item is 64k)
cache2 = name=jivaanacache,items=5000,purge_lru=1,expires=300

route-if = empty:${cookie[COOKIE1]} goto:not_logged_in
route-if-not = empty:${cookie[COOKIE1]} goto:logged_in
route-run = continue:


route-label = not_logged_in
route = ^(/basket|/checkout|/accounts|/dashboard) continue:
route = ^/(.*) cache:key=${REQUEST_URI}_${cookie[COOKIE2]},name=jivaanacache
; store each successful request (200 http status code) for '/'
route = ^/(.*) 
cachestore:key=${REQUEST_URI}_${cookie[COOKIE2]},name=jivaanacache

; the following rules are executed only if the jivaana_user cookie is 
defined
route-label = logged_in
route = ^(/basket|/checkout|/accounts|/dashboard) continue:
route = ^/(.*) 
cache:key=${REQUEST_URI}_${cookie[country]}_${cookie[COOKIE1]},name=jivaanacache
; store each successful request (200 http status code) for '/'
route = ^/(.*) 
cachestore:key=${REQUEST_URI}_${cookie[country]}_${cookie[COOKIE1]},name=jivaanacache

OS is Linux 2.6.32-504.30.3.el6.x86_64

Architecture:          x86_64

uwsgi is being used with Django Python framework.


Following is the memory configuration (free -m):

              total       used       free     shared    buffers cached
Mem:          7870       7020        850          4        217 3796
-/+ buffers/cache:       3006       4864
Swap:         3071          3       3068


Would really appreciate if anyone could help with the above and also, 
guide me to a good tutorial or documentation on uwsgi caching.

Thanks,
Pinakee


More information about the uWSGI mailing list