{"id":472,"date":"2009-10-05T23:11:20","date_gmt":"2009-10-05T22:11:20","guid":{"rendered":"http:\/\/wp.devco.net\/?p=472"},"modified":"2009-10-09T17:54:05","modified_gmt":"2009-10-09T16:54:05","slug":"ruby_pdns_version_05","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2009\/10\/05\/ruby_pdns_version_05.php","title":{"rendered":"Ruby PDNS Version 0.5"},"content":{"rendered":"
I just released version 0.5<\/a> of Ruby PDNS<\/a>. This mainly introduces a full statistics capability and fixes a minor bug or two.<\/p>\n I didn’t intend on releasing another version before 1.0 but it turns out the stats feature were quite a big job worthy of a release.<\/p>\n The stats is complicated by the fact that PDNS runs multiple instances of my code sharing the load between them, this makes keeping stats pretty hard because I have no shared memory space like you would in a multi threaded app. So I’d somehow need to dump per process stats and calculate totals. Everyone I asked suggested writing a log and summarizing the log data but this just never felt right to me – there would be issues with log rotation and knowing till when you last counted stats and so forth – so I kept looking for a solution.<\/p>\n I struggled to come up with a good approach for a long time, finally settling on each process writing a YAML file with it’s stats and a cron job to aggregate it regularly. This turned out to be quite elegant – much more so than processing logs for example – as the cron job cleans up files it already processed and also ignore too old ones etc. If the cron job keeps running it should be zero maintenance.<\/p>\n I added a script – pdns-get-stats.rb – to query the aggregated stats:<\/p>\n $ pdns-get-stats.rb –usec –record puppet $ pdns-get-stats.rb –usec –record ruby-pdns-totals The puppet record is using GeoIP so you’d expect it to be a bit slower than ones that just shuffle records and this is clear above, though I am quite pleased with the performance of the GeoIP code. Times are in microseconds.<\/p>\n
usagecount:896 totaltime:165844 averagetime:185<\/p>\n
usagecount:68705 totaltime:11056529 averagetime:160<\/p><\/blockquote>\n