I am using the following stack:
- nginx
- uwsgi
- Python (Flask)
I’ve set up a little app that utilizes redis as its main database. I only use GET, SET, EXISTS and EXPIRE in my code.
When trying the app in the terminal everything works fine. On every request it checks if the content is available (EXISTS). If it’s not the content gets loaded and saved for a while (SET, EXPIRE). After that, the content gets presented to the user (GET).
The problem is that as soon as I run the app via nginx/uwsgi, after some time the EXPIRE seems to be ignored. Instead of deleting the value and loading it fresh, the new content gets appended to the old one – as it seems not only one time, but like dozens of times, resulting in extremely large values and sometimes timeouts.
Strangest thing for me: The whole issue disappears as soon as I restart uwsgi.
Any Idea?
I’ve figured it out! The problem was that I “recycled” these two instances:
http://github.com/saibotd/hackerhub/blob/master/app.py -> lines 22, 23
I need to re-create these objects every request and it works as expected.