I have a large data file that gets constantly (and synchronously) appended-to by measurement devices out in the field. I need to isochronously deliver the most recent data to this file to an online dashboard. I say isochronous because the “dashboard” doesn’t care about displaying a stream of data (high latency situation), it just cares about the very last few data points in the file that get sent to it. I cannot guarantee that the rate of file growth is less than my effective outbound throughput.
So I have one ever-appending file but I have multiple processes that need to regularly send the very last block of information out of it. A loose pub-sub of sorts, I guess.
I can:
- Poll the file to see if there is growth, then seek back from the EOF for the last block(s) of data,
- select()-style and be notified of said change, but then don’t I have to seek to the last bit of data anyway?
- Have a process shove the last bit of data into shared memory for reading, but would I not then have the same issue I need solving in #1 and #2 because the shared memory writer will behave the same.
Any other suggestions or recommendations?
If I’ve understood you correctly, you just want to have a dashboard periodically updated with the last (current) block. Then, an easy option would be:
On Linux, you can use inotify to be notified when a file changes. This way you can avoid the unnecessary wakeups of the previous approach. So this option would be:
This last one may look something like: