Choose the size for your worst burst, use ring buffers for bounded memory, and monitor fill level to catch pressure.
Buffers that behave
Size for the worst burst
A 1 KB buffer for a 10 Gbit/s network drops packets. Size to the peak, not the average.
Ring buffers for bounded memory
A fixed-size circular buffer never grows: when full, oldest data is overwritten or the producer blocks.
Monitor fill level
A buffer at 90% is a buffer that will overflow soon. Alert before it does.
Flush on shutdown
A buffer that loses its data on shutdown is a data-loss bug waiting for a disk fill.
Bounded is safer than unbounded
An unbounded buffer is a memory leak that grows on backpressure.