Yeah, fsrs. Local caching is the right solution to this.

However, it's not just about DNS names, it's also about re-packing many
incoming message sources into one UDP "flow".
So, it's important that we re-use an ephemeral port for messages for a
"while".

@@destinations will re-grow, as the #build_fresh_sockets should be getting
called periodically from the daemon.


On Thu, Sep 12, 2013 at 1:13 AM, R. Tyler Croy <notifications@github.com>wrote:

> In lib/statsd/server.rb:
>
> > +      @@sockets = {}
> > +      @@destinations = []
> > +      def receive_data(msg)
> > +        # Send data to the normal, local Statsd instance.
> > +        Statsd::Server.receive_data(
> msg)
> > +        # And then also multicast the message to the forwarding destinations.
> > +        @@sockets.each do |destination, socket|
> > +          begin
> > +            socket.send(msg, 0)
> > +          rescue SocketError, Errno::ECONNREFUSED => e
> > +            puts "ERROR: Couldn't send message to #{destination}. Stopping this output.(#{e.inspect})"
> > +            @@sockets.delete(destination)
> > +          end
> > +        end
> > +      end
> > +      def self.build_fresh_sockets
>
> Obligatory "lrn 2 run dnsmasq" comment.
>
> With that out of the way, the logic may be slightly incorrect/unclear;
> this really should have tests around it, especially considering the error
> case. I can foresee a situation where an intermittent resolver issue which
> would result in a successively smaller set of @@destinations over time.
> Basically @@destinations is only ever going to get smaller over time,
> since destinations call fall out of the list, but never "come back" except
> with a process restart.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/lookout/statsd/pull/3/files#r6315779>
> .
>