How to find size of atomic write for nginx access log buffer?

Solution 1:

I was trying to find out size of an atomic write in Linux myself and the most helpful reading was from this Unix Stack Exchange answer

But in summary

This is from man 7 pipe.

POSIX.1-2001 says that write(2)s of less than PIPE_BUF bytes must be atomic: the output data is written to the pipe as a contiguous sequence. Writes of more than PIPE_BUF bytes may be nonatomic: the kernel may interleave the data with data written by other processes. POSIX.1-2001 requires PIPE_BUF to be at least 512 bytes. (On Linux, PIPE_BUF is 4096 bytes.)

So in Linux the size of an atomic write is 4096 bytes.

You can find a nice table of the PIPE_BUF size for different OS'es here http://ar.to/notes/posix#pipe-buf.