Logging to a File vs UDP
Well I learned a lot today, specifically that writing to UDP is on average faster than writing to a file on my local machine and on my servers.  My implementation on the UDP client was off.  

If you look at this code:

require 'socket'
s = UDPSocket.new
before_time = Time.now
100_000.times do |i|
  s.send("#{i}", 0, 'localhost', 1234)
end
puts "Time elapsed was #{Time.now - before_time}"


There's something sneaky in there that I didn't catch with this line:

s.send("#{i}", 0, 'localhost', 1234)


When you pass in host and port into the send method it DNS resolves before each send, which has major overhead.  If instead I change the code to connect ahead of time like so:

require 'socket'
s = UDPSocket.new
before_time = Time.now
s.connect('127.0.0.1', 1234)
100_000.times do |i|
  s.send("#{i}", 0)
end
puts "Time elapsed was #{Time.now - before_time}"


I get benchmarks that beat File IO.  Boom.