It would make sense to use async I/O for the RESTResource methods in most cases, with a timeout.
Detect RESTResource functions that return Task and run them async
Run non-async methods directly with timeout
Timeouts for max time spent, to handle hung read threads as much as possible
This would reduce server load and improve performance in worst-case scenarios. Slow or hung network connections would not eat threads, and hung-forever HTTP threads would at least eventually be abandoned (if not aborted, because we don't have that option.)
Might want to create a private TaskScheduler so we'll have our own threadpool, and won't eat the global thread pool in the worst case failure mode. Or maybe we can just use the right parameters to StartNew.
Note: the addition of timeouts to tekhedd.SocketHttpListener makes lost threads less of a problem. Use same timeout configuration for the Listener and our response-handler callbacks?
It would make sense to use async I/O for the RESTResource methods in most cases, with a timeout.
This would reduce server load and improve performance in worst-case scenarios. Slow or hung network connections would not eat threads, and hung-forever HTTP threads would at least eventually be abandoned (if not aborted, because we don't have that option.)
Might want to create a private TaskScheduler so we'll have our own threadpool, and won't eat the global thread pool in the worst case failure mode. Or maybe we can just use the right parameters to StartNew.