|
At a site, we are doing 5000-20000 EPS (Events Per Second) all udp/514 at each of 10 locations. At this time, we are required to do this all with a single server/indexer in each location. This week we made syslog-ng as the listening service (instead of Splunk) since it seemed to work better regarding the other log recipients (see below). Syslog-ng listens on udp/514 and then:
Splunk reads the file and seems to be performing well; however, the system reports many UDP errors indicating syslog-ng is not receiving it all. Tests with a traffic-generator (loggen bundled with syslog-ng) show that a fraction of what is sent gets processed by syslog-ng. A tcpdump at the same time shows the EXACT packet count that was sent was received, about 1/3 dropped by the kernel and about 1/3-1/2 of what was sent is what makes it the syslog-ng file. Applying the tuning tweaks below have reduced the number of drops substantially; however, they have not been eliminated. Maybe it isn't possible in this situation, but I think it should be. Questions
EnvironmentIndexer:
Data:
ERRORS
Udp:
3436531 packets received
1553 packets to unknown port received.
8402 packet receive errors
109202 packets sent
RcvbufErrors: 8402
Tuning Steps
options {
sync (5000);
time_reopen (10);
time_reap(5);
long_hostnames (off);
use_dns (no);
use_fqdn (no);
create_dirs (no);
keep_hostname (yes);
log_fifo_size (536870912);
stats_freq(60);
flush_lines(500);
flush_timeout(10000);
};
|
|
We have almost the same setup in our network. Here is the settings we finally ended up with that seem to work pretty well. We still get errors from time to time (fact of life with UDP) but it's a lot better then before.
1
btw - note that with these sysctl settings you are changing the default buffer sizes on sockets, meaning if you have other apps that open a ton of sockets you will burn up your kernel memory VERY quickly (8MB per hit).
(20 Sep '10, 00:21)
zscgeek
1
I would also say we are getting more in the range of 20k eps in this setup on much slower hardware. Dual L5410's (2.3Ghz), 8GB ram, dual (raid1) 10k rpm WD Raptor drives
(20 Sep '10, 00:26)
zscgeek
1
I didn't expect you could do that volume even with DNS res (I see you are using cache, but still). Thanks for this, I will check this out in the lab when I get back onsite tomorrow.
(20 Sep '10, 00:32)
sdwilkerson
|
|
This response doesn't offer exact answers to the questions posed in the original post. We didn't use syslog-ng. Instead, it shares our approach and experience with overcoming UDP Packet Drops. My understanding of the architecture when sending syslog messages directly to a Splunk UDP collector (source) is:
In our case, UDP drops occurred due to:
We resolved our UDP drops in 5 ways:
(1) Increasing Linux kernel network buffersIncrease the UDP receive buffer size from 128K to 32MB
Increase other memory management options which moderate how much memory UDP buffers use. E.g. default on system with 2GB:
Note, net.ipv4.udp_mem works in pages, so multiply values by PAGE_SIZE, where PAGE_SIZE = 4096 (4K). Max udp_mem is then 385152 * 4096 = 1,577,582,592 Increase the queue size for incoming packets. On Ubuntu, the default appeared to be 1000.
As pre the posts above, make the change persistent using sysctl.conf (2) Increasing Splunk's queue size for UDP sources & (3) Enabling splunk's persistent queue functionalityExample from inputs.conf
(4) Re-prioritising the Splunk collector processWe increase the processing and IO priorities for the 'collector' process, so that searches would not impact data collection. Typically, a high volume Splunk deployment would not have this issue as a separate search head would be used. Here's a little bash script I wrote to do the work:
(5) Apply a filter to the source to remove unwanted inputIn our case, we wanted to filter out specific info level messages, but not all info level messages - the administrator's were unable to selectively control which info level messages were sent. Our example is provided below. Specify a transform to enable filtering in props.conf
Specify the filter in transforms.conf
Monitoring for UDP errorsWe created a cron job to append the output of netstat to a file, every 5 minutes. netstat command:
We then indexed /tmp/udp_status.txt and created a view to graph the errors. The delta command came in handy to compare time intervals. To timechart the number of UDP packets received:
To timechart the number of UDP packets dropped due buffer errors (every 5 minutes):
To timechart the number of UDP packets discarded due to the application not taking them from the buffer:
To tabulate delta's for UDP stats:
I get the following error .... any insights ? terminator seems to be there ? Error in 'rex' command: Encountered the following error while compiling the regex '(?<p_rec>w+)spackets received': Regex: syntax error in subpattern name (missing terminator)
(11 Apr '12, 19:30)
nextgen
|
|
You probably don't want to hear this after putting in so much time, but drop syslog-NG and go with rsyslogd. SUSE has done this in their releases, and it is only a matter of time before rsyslogd becomes the de facto standard. Google can show you several performance comparisons that demonstrate rsyslogd outperforming syslog-NG in most relevant benchmarks. seconded. rsyslog is good stuff.
(21 Sep '10, 00:26)
jrodman ♦
syslog-ng and rsyslog performs on par, one is better in some scenarios, the other is better on others. And udp receive errors do happen if receive buffers are not adjusted. That's a fact and may not relate to the quality of the syslog server in question.
(17 Aug '12, 01:08)
bazsi77
|
|
I have been having the same issue. One of 2 log servers has been dropping UDP packets like crazy. However the other one was fine. While the changes that were mentioned in here did improve the situation, the drop rate was at a significant level where it was ridiculous. After banging my head over it for why one was dropping and the other one wasnt dropping, I realized a key difference in the log servers: The working server was having the logs write to an ext3 partition and the server dropping logs was writing to an ext4 filesystem. As a test, I moved the log destination to an ext3 filesystem with default settings and now its working fine. Now the question, what are the appropriate ext4 settings for receiving syslog-ng / rsyslog data? This is what I currently have setup (which is causing the UDP Droppage): /dev/mapper/ld0p1 /$my_log_dest ext4 noatime,data=writeback,defaults,acl 1 2 I suspect its possibly my journaling option "data=writeback" but I'm not for certain. Can someone give some insight on this? Thanks. Brian |
|
UDP is lossy, but can be tuned to a point to a "good enough" receipt rate. It is always best to use TCP if possible though. In general you'll need to size the input buffers according to the input rate of messages. You have to pick a volume in bytes/second (as the kernel accounts memory use in bytes, rather than packets), this can be found out by measuring the actual traffic, or by checking the average message size and multiplying it with the desired message rate. Once you have a number for your bytes/second rate, you'll have to pick a number how much time syslog-ng (or other syslog daemon) will spend on processing your messages (rather than receiving them). In normal cases, the round-trip-time between the reception of incoming messages is on the order of microseconds, sometimes a longer latency might happen. As described in one of the answers, this might be affected by the file system in use, or the processing applied to the incoming log stream. I generally tend to plan for 3-5 seconds latencies, which means that syslog-ng will spend this time elsewhere, in the worst case. Once these numbers are established we only need to make sure that our kernel based receive buffer can hold this amount of data. In my example, let's say we work with 50k messages per second, 300 bytes on average and syslog-ng may suffer 5 second latencies. To offset this, we need a 75MB receive buffer. Today's servers dedicated to syslog processing should be able to allocate this amount of kernel memory to the syslog subsystem and remember, that this is the worst case and not a static allocation. syslog-ng has a so-rcvbuf() option, but kernel limits also apply that prevent from increasing the receive buffer above a certain threshold. To increase the threshold you'll need to change 'sys.net.core.rmem_max' value:
And then use this option for your udp receiver in syslog-ng.conf:
If you want to be absolutely sure, you can check syslog-ng with strace to see if it really increased the socket buffer. In general version 3.3 of syslog-ng (released early 2011, currently at 3.3.6), should have no issue processing 100k messages per second from a single source. When processing messages from a large number of clients, this number can also be scaled to 1M msg/sec. That should be more than anyone needs, even though certainly this number depends on the configuration used for syslog-ng. |
|
We've run into the same problems with our syslog server. Adding to the puzzle is that (a) we're seeing the same sort of packet loss with both rsyslog and syslog-ng, and (b) we DON'T see the problem using, e.g., "awk {print} /inet/udp/514/0/0". On a quad-core 2.4Ghz system, we're not able to sustain much more than 50 msgs/sec (using the "loggen" program from syslog-ng) without errors. Attempting the modest rate of 1000 msgs/sec, we're seeing on the order of 70% loss. That's crazy! I'm going to take a look at the parameters suggested by @zxcgeek, but I'm astounded at such poor performance on a stock system. 2
This may sound dumb, but check to make sure that speed and duplex are manually set at both the switch port and the network adapter. If that fails to reveal anything, I would still recommend investigating the link layer on up, perhaps through a packet capture.
(16 Oct '10, 00:13)
araitz ♦
|
|
In the above answer from jpvriel, < and > got transposed into (ampersand)lt; and (ampersand)gt;. For example, here's what the first one should look like when you enter them in Splunk:
|