Multiple frequent appends to the same file descriptor

Viewed 9

I have a process that appends to a file many times per second. This is the only process that will write to the file.

I have another process that, occasionally and way less frequently, reads the whole file.

I'm unsure what's the best approach:

  • have the writer process keep a constant file descriptor for the file and keep appending to it, while the reader process can acquire a new file descriptor (through open()) whenever it wants to read the file
  • or, have the writer process constantly open the file, append its contents, and close every time it wants to append

The reason I'm asking is because I'm unsure what is cheapest for the server.

Many thanks in advance

0 Answers
Related