Force index with active record find
A small useful tip:
Mysql’s query planner occasionally has trouble picking the right index. I’ve found that normally if you try variations long enough, eventually you find a way to do the right thing. Recently however I ran into one I couldn’t coax.
No big deal you say, after all, that’s what find_by_sql is for no? Only problem is, the query in question was inside a with_scope block, and I really didn’t want to have to find and hardcode sql finders for any variations used by callers. Thankfully, the :from option on find can rescue us: just go ahead and include the force index clause. It’s slightly gross imho, but it works, and might save you some manual sql building.
Should deployment be viral?
Reading about Storm recently, I had no idea how big it got before it’s decay. Estimates for how many hosts were in Storm at peak vary, but they’re all in the millions.
I was really struck by how sophisticated command and control for botnets has become, moving from simple IRC servers to peer to peer overlays. The authors are constantly deploying updated code: new attack approaches, email spam, blog comment spam, serving up http exploits… I imagine the application protocols themselves have to be written in such a way that different versions can co-exist in the wild without triggering faults in each other. Thanks to the p2p approach, they can do this simply and rapidly, despite the scale. Their administration mechanisms are even robust against both failure and active attempts to sever control.
Think about how different that is from the typical IT experience. Would your deployment methods still work if you had 50 million hosts to deploy to? Could your administration mechanisms withstand the determined hacking efforts of some of the internet’s smartest security practitioners? Certainly a worm is very different from a production application, but I think there’s a lot to be learned by how these crackers are their solving their problems. Why aren’t we using Name-Dropper protocols, co-existing versions and Epidemic code upgrade?


