grot

random walk through fields of musings

Wednesday, October 9, 2013

auto-generating IPv6 PTR DNS records with PowerDNS recursor in Lua

Pre-generating PTR records for dynamically-assigned SLAAC IPv6 is fairly unreasonable and silly because most of the time there won't be a match. However, if you do want to do that, and you runPowerDNS (which you should pick because it has working Lua scripting support to do this), you can generate them when the query hits quite easily:
function preresolve ( remoteip, domain, qtype )
  -- for a v6 only connected site, don't resolve A records
  if matchnetmask( remoteip, "2000::/3") then
    -- only rewrite PTR requests
    if (qtype == pdns.PTR) then
      -- and then only in our block(s)
      qv6 = string.find(domain, "d.f.8.6.8.a.8.3.0.0.2.ip6.arpa") 
      if not qv6 then return -1, {} end
      ret={}
      revdom="reverse-ip.mylab.tld.";
      rev= string.reverse( string.gsub( string.gsub(domain, "%.ip6%.arpa", ""), "%.", "") ) .. "." .. revdom;
      --  pdnslog("returning " .. rev .. " for " .. domain);
      ret[1]= {qtype=pdns.PTR, content=rev, ttl=86400}
      return 0, ret
    end
  end
end

Thursday, October 4, 2012

I give up. and so I get more done.

My kids won't listen. I get angry and yell. They still won't listen, but
now they feel I'm mean. I'm frustrated. So I give up. I can't make them
do anything.

I tell them they can do what they want and don't have to listen to me
and that they are responsible for themselves this evening.

Or they could make a deal to do what I ask and then I'd tell them what
to do -- no whining, no pouting, no argument even if you disagree.

That whiff of anarchy is all it took.

They both chose structure and that was that.

We made up, they went to sleep tired and calm.

We'll see what tomorrow brings.

Monday, August 15, 2011

so what do I do? teach him about congestion control?

I was walking home from my office staff picnic, when I prepared to be
solicited by a young, disheveled man selling some newspapers at the
corner. To my surprise he looked away and while I was starting to wonder
why, he muttered loud enough that I know it was intended for me, "Thank
you for coming to MY country and f**in it up." Not one to normally want
to pick on the down and out, I started to ignore it, but then felt
compelled to turn around and ask directly, "what was that?". I was
impressed by the fluid save, "I said Corporations are f**ing this
country up."

So I'm the wrong color? not knowing enough English to evesdrop?
spineless enough to not object? what? I wish I could read minds -- the
words are far too filtered to know what is really the case.

Friday, April 9, 2010

ahead of my time in Berkeley and Palo Alto, maybe A2 is the 3rd time charm?

I've wanted to build a community Internet exchange point ever since I knew how to technically do it (for over 10 years), but my efforts in Berkeley and then in Palo Alto ran into institutions that were pennywise and pound foolish or just waiting for the right time. Given Google's success in pointing out that that time is now, maybe I'll have more luck in A2 this time?

Thursday, April 1, 2010

more of the same: last.fm scrobbles to iCalendar format

This is getting to be a lame habit, but it makes me slightly happy, so here's another Yahoo! pipe that makes an iCalendar feed out of your last.fm scrobbles feed:
Pipes: last.fm scrobble

Wednesday, March 24, 2010

it's old-fashioned to swap to disk...

or not only is swapping to disk harmful, it's downright silly on webservers (conditions apply and exceptions are many).

Back when the OS on your webserver was 32-bit and 512MB was a lot, arguments like this might have been germane, but I'll just claim to have been a decade ahead of my time when I wanted my FreeBSD 2.1 webservers (behind a load-balancer with shared nothing) configured without swap so that they would just panic and reboot if they ran out of memory rather than suffer the slow death of context switches and disk IO (we'd end up rebooting them anyway).

Now with 64-bit OSes and less-than-expensive multi Gigabyte RAM, plus effective ways to cap memory usage of JVM and VMs, there is little use for disk swap on clusters of machines which are identical and data-less. Even on large DB servers with 30+ GB of RAM it is silly to consider swapping to be okay unless it's for long-running queries that can tolerate large latency. OLTP type DBs should just have the DB process restarted if it gets too big.

I'm sure there are lots of cases where you don't want to lose data and can tolerate the latency, but it certainly seems for all the low-latency "social web" sorts of applications, a load-balancer that sends new sessions to real servers based on least-response-time plus a quick reboot are going to be better remedies than the slow-death of disk swapping.

So unless you can come up with a compelling argument other than "it's always been done that way", I'm going to practice not recommending or building "clustered", web servers for interactive applications with disk swap until experience or overwhelming evidence suggests otherwise. So there.

Sunday, March 21, 2010

implementing high-volume queues cheaply

Implementing write-heavy queues is hard to do in a technically "inexpensive" way -- RDBMS' are typically read-optimized and too heavy for the task of a simple queue, dedicated queuing packages require frameworks to run in etc., so the most simple queue that is "web-writable" I could come up with, which is chronologically ordered is to simply use the webserver logs as a queue. Serving static files, as simple as a text file that contains a simple string such as "ok" and named "ok.txt", is efficient in most webservers, and a small file is easily cached, so physical disk IO would be limited to writing the webserver access logs. To add items to the queue you can just use query parameters that will get recorded in the weblogs and then can be parsed out, ie.:

http://my_example_server.com/some_path/ok.txt?key=addme&value=withThisVal&whereAmI=London&why=toTrack

and the query params won't be "interpreted" by the static file, just show up in the weblogs as long as GET query params are set to be logged.


Most webservers allow writing the timestamp in a format that is easily machine readable (milliseconds since the epoch in UTC is probably a good choice). Using spread to write the logfile in realtime to the network would reduce the disk IO on the local webserver but a spread listener would have to write it somewhere, though the ability to add multiple listeners could spread the load.