i create api using fastapi framework and i have deployed on heroku, the main function of this api is i have to send (post method) element as query parameter every 5s and i store it in tinydb and get method to show all values stored.
a problem is if i send 10 post requests i didn't get all 10 request (i can't show all values sent by this requests.
i create function to increment value of variable every time when go into post methods and if i send 10 post requests i get variable = 6 or 7 or ... not 10, so i lost some requests.
but in local i have api run perfectly.
CodePudding user response:
TinyDB is not compatible with multiple processes writing data to it at the same time.
Why Not Use TinyDB?
You need advanced features like: access from multiple processes or threads,
As far as I can tell it has no native locking support, so you'll have to implement that yourself in that case. In this case, if multiple nodes are handling requests, the TinyDB file will also be local to that specific node that handled the request, making it impossible to have one source of truth.