I have an API built with Flask and using Gunicorn with postgreSQL as database on linux (centOS)
When setting multiple workers using Gunicorn, if a user log to the API and get a token, the token won't be correct if he uses it to perform a request.
It works when there is only one worker and multiple threads but not with multiple workers. How should I handle the storage of the tokens so the different workers can retrieve the token from a unique source of data?
To generate the token we retrieve the secret key and create a json web token. Then we store this token and the username in a dictionary.
Also, the secret key is generated at each start of flask, maybe using the preload_app of gunicorn can help to have the same secret key on each worker.