Inside my web service, I open a filestream to a file on local disk. I keep this around for the lifetime of the service. For every query that comes in, I use the filestream to read the disk.
I do this to avoid having to reopen the filestream on every query. Latency of this path is critical (should less than few ms). I use SSD to keep disk IO time to 0.1ms or less.
Can the filestream ‘go bad’ (become invalid) over long periods of time (days). Is it safer to just reopen the filestream on every query? If I have to reopen, what’s the overhead of constantly reopening a filestream several times a second?
It is safe to keep files open as long as you need.
Is it good for your case or not – you need to decide yourself. Re-opening file should not be slow (even on regular drive), but you need to try and measure yourself as no one but you know your exact performance goals.