Answer Question Around Python Flask Race Conditions
Budget: £36 – £0 GBP
Hello,
I'm working on a project where a machine learning model is being hosted by a Flask (waitress) API.
The API works in two ways,
1. classifies an input based on the dataset
2. adds a new entry to the dataset (in-memory)
The reason for number 2, is that the dataset has grown very rapidly, and fetching it from the database upon each request is no longer an option due to query times.
This has led to us utilizing a global object in the API, that number 2 inserts into, and number 1 reads from.
Now, I was wondering if this could lead to any race conditions due to the concurrency, as we need the 'state' of the global object to be the latest when a classification request is made (a couple hundred a minute).
After classification, a new dataset entry might be added depending on a few conditions.
I've been reading up on things like queues like RabbitMQ, caching layers like Redis, but I am unsure which of these, or both, fits my use case.
I was hoping someone could lead me to the right direction.
Thanks in advance.
I'm working on a project where a machine learning model is being hosted by a Flask (waitress) API.
The API works in two ways,
1. classifies an input based on the dataset
2. adds a new entry to the dataset (in-memory)
The reason for number 2, is that the dataset has grown very rapidly, and fetching it from the database upon each request is no longer an option due to query times.
This has led to us utilizing a global object in the API, that number 2 inserts into, and number 1 reads from.
Now, I was wondering if this could lead to any race conditions due to the concurrency, as we need the 'state' of the global object to be the latest when a classification request is made (a couple hundred a minute).
After classification, a new dataset entry might be added depending on a few conditions.
I've been reading up on things like queues like RabbitMQ, caching layers like Redis, but I am unsure which of these, or both, fits my use case.
I was hoping someone could lead me to the right direction.
Thanks in advance.