I have a python web application written using FastAPI (running via uvicorn). In my app I'm using the standard logging
module which uses TimedRotatingFileHandler
. Since I'm logging into a file I'm concerned about performance. Lets say I have 3 log messages in a function which is called with every call to a /test
endpoint. Now imagine 1000 clients requesting /test
at the same time - that is 3000 writes to the log file.
I'm concerned this will hinder the app's performance since IO tasks are time consuming. Should I use some form of asynchronous logging? Maybe open a new thread which will write into the file? I tried googling for answers but I found no standardized approach to it. So is it even needed? If yes, how should I approach this? Thanks!