ironsmile / nedomi

Highly performant HTTP reverse proxy with efficient caching of big files
GNU General Public License v3.0
81 stars 9 forks source link

When reloading/restarting old request may hang out for a long time #221

Open mstoykov opened 8 years ago

mstoykov commented 8 years ago

When reloading the config all the handlers are replaced. Old ones will continue to be around until all requests that have been started with them are finished.

This might be a problem when the log file has been rotated and the reload was issued in order to change the log file. In that case old handlers will keep the log file open and write to it for as long as a request lasts. A request can last for hours. A file which is kept open in a unixy OS will be preserved even after it has been deleted from the file system. The problem is when this starts to happen often: the storage will be full of already deleted log files.

We could set a deadline for every request's context and so restrict how long a request can last. But maybe we do not want to stop requests that take long time all the time. Maybe only doing it when we are reloading or restarting. In that case canceling the whole application context after some time will be better. This would require that a new application context is made on reload which would not be hard.

Both of the solutions require that handlers would actually stop handling requests when the context is canceled or the deadline is reached. This is probably not the case for the majority of them.

ironsmile commented 8 years ago

I think that two configuration options will solve this specific issue and also give nedomi users much more control on how long-lived requests are handled. The two options may be:

Combinations between the two should be possible. If a request qualifies for both deadlines the shorter should be honoured.