I have created a machine learning algorithm in Python that is served through a REST API and would like to implement it on Google Cloud / Amazon EC2 to make real-time predictions. Before I do this, I would like to create a 'log' of every request/prediction that comes in/out of the model - this seems like good practice to me and may also help with creating unique prediction identifiers. Just a simple 1 or 0 stored in a database with a datetime stamp and unique ID.
How should I send this data to the database without impacting the run time of the model? An INSERT INTO statement in the API? A seperate API altogether?
Thank you very much for your help!
It depends on the latency of the results. If you want it to persist data in the db instantly then an API has to be made instantly when you have received the request. As these will be log files by nature my recommendation would be to store locally and insert the logs once in a day to reduce the network congestion over the time. If your existing API is already connected to db and then I do not see a point of creating a new API altogether for a simple post call
How to connect machine learning algorithm to database