2 ms·
While I agree with you on the whole, one minor point about UDP/datagrams: they are not reliable even on localhost under some circumstances. The point of datagra
by IgorPartola 12y ago
While I agree with you on the whole, one minor point about UDP/datagrams: they are not reliable even on localhost under some circumstances. The point of datagrams is that they are allowed to be lost without a trace if the consumer (syslog) is not consuming fast enough. For example, if process A starts spewing 10,000 log records (UPD or datagram UNIX socket packets) a second at syslog, and syslog can only handle 5,000, then the other 5,000 records will be lost. Any other process will also get its records lost as they will not be guaranteed to be processed. The rate of loss will be controlled by how large a datagram buffer the consumer's kernel has. Moreover, the processing will not be uniform: the buffer is LIFO, so older records will be processed while newer ones will be lost.
On the other hand if you use stream sockets, the producer will either block or be told that the consumer is not ready to read any more data (beauty of TCP). In either case, TCP produces enough overhead compared to UDP to slow down the actual useful part of your application, which is often not desirable.
Neither one of these is a good solution as either your consumer or your producer needs to keep their own very large buffers to accommodate spikes in traffic. Ideally, you do this anyways to ensure that you hold onto all the packets you received.
Having said that, I don't know exactly what rsyslog does so I cannot say if this would actually be a problem for it.
- noselasd 12y agoWhile it's certainly true that UDP is unreliable even on localhost, unix datagram sockets arn't, they have flow control.
- IgorPartola 12y agoI have never seen a reference to this. Can you link a source?
- lobster_johnson 12y agoAF_UNIX with SOCK_STREAM will behave like TCP, in that a "full" stream will block. See http://stackoverflow.com/questions/1478975/unix-domain-socket-is-there-such-a-thing-as-a-busy-signal http://stackoverflow.com/questions/1478975/unix-domain-socke..., for example.