Tag Archives: tech

Rails and mysql timeouts

Dear LazyWeb, I could use some help. I feel like I’m asking the wrong questions, and need some nudges in the right direction.

noodl has been very helpful, I think, but his suggestions appear to be answering the question I’m asking, rather than the one I mean. I think.

We have Mongrel + Rails + Apache + proxy_balancer on Server Q out in the DMZ. Mysql is running on Server Z, inside. There’s a firewall rule to allow Q to talk to Z on the mysql port. So far so good.

After N minutes, the firewall times out idle connections between Q and Z. N is configurable, of course, but that doesn’t fix anything, because people go home over the weekend, and N will eventually be reached. So increasing N postpones the problem, but doesn’t fix it.

The problem is thus. After the N minute timeout is reached, the connections to mysql drop. Subsequent requests to the Rails application do not result in the database connection being reestablished, as expected. (At least, it’s what I expected, but perhaps I need to adjust my expectations.) Requests to Rails after this point result in an extended wait period, followed eventually by a proxy timeout. The only way to reestablish the mysql connections (that we’ve found) is to restart the mongrel cluster.

Functions put in a before_filter to reconnect do not seem to be getting called. Indeed, the before_filter doesn’t even seem to be reached. It’s as though the hangup is happening in some stage before the before_filter – Rails is trying to contact the database, and is waiting indefinitely for a response.

Placing a reconnect in the before_filter works, and reconnects, as long as the mysql connection is up. (Not useful, but interesting.) However, after N minutes are allowed to expire, and the connections drop, that code does not appear to be getting invoked at all.

So it’s entirely possible that I’m asking the wrong questions, but my hope is that one of my knowledgeable readers will see this post and immediately say, Oh, sure, that’s the well-known problem that is solved like *this*, and *here* is the question you really should have been asking.

Please? 🙂

Site admin responsibilities

My ethical dilemma for today. I know, because I’m the site admin, that a particular user is posting things under multiple names, agreeing with himself to lend credibility to a position that nobody else holds.

So, the question is, when users have an expectation of anonymity, and one user is intentionally exploiting that anonymity to be cruel, can I “out” this user, because it’s my site?

I dunno, but he’s seriously making me angry, and I suppose I should just take the moral high ground and ignore him, but I’m finding that very hard to do.

More about the discussion forum

One of the features of my discussion forum that folks seemed to like was the fact that all the post titles could be seen in a hierarchical tree when you first load the site. The trouble with this is that the recursion necessary to generate this tree is very CPU-intensive. You can either select all the articles, and then recurse through the data structure in memory, or you can recursively select articles from the database until you have the tree that you want. Either one of them causes lots of problems, and this is probably why most discussion board stuff opts not to do the hierarchical tree view as the main view.

So, while my load has been overing around 1.2 for the last 9 months, it’s at 0.13 now, and has been less than 0.1 for most of the last couple days.

But, of course, folks aren’t happy about it. posting delightful messages like:

For An Open Source Guru, Rich Bowen Has Really Really Let Me Down. This Site Is Bloody Silly. Even Though White Men Cant Jump, This Is A Real Low For Even A Mzungu.. Rich Should Pull-up His Socks

What I’ve noticed fairly consistently, however, is that the folks that hate it the most are those who always post anonymously and don’t actually have anything to say. The ones that have consistently posted thoughtful articles over the years simply registered a new account on the board and resumed posting their thoughtful articles as though nothing had changed.

I really wish I could understand what it is that they dislike so passionately, but, with very few exceptions, none of them will tell me what exactly they dislike – merely that it is terrible and they want me to go back to the good old days.

Meanwhile, from an administration perspective, the new software is really making me happy, and I might just end up keeping it indefinitely.

Discussion forum

For years now, I have run a discussion forum at http://kenya.rcbowen.com/
It runs on Perl cgi code that I wrote back before the turn of the century, and I no longer understand. It is hugely inefficient, and every time someone hits index.cgi, it uses 70% of the CPU.

Well, this has been going on for more than 10 years, and recently the server that it’s running on has decided that it just can’t take the load any more.

So this morning I pulled the plug on the forum. I’ve got to find something more efficient to replace it with.

I’m technology-agnostic, but would prefer Perl or PHP. It doesn’t need a lot of bells and whistles. Standard threaded discussion board, allowing for anonymous participation, but perhaps supporting user accounts and a certain amount of voting/moderating, although this is optional.

Any suggestions, loyal reader?

Anything from Radio Shack


I received a flier from Radio Shack today, advertising Radio Shack as the ultimate toy store. As someone who grew up on electronic gizmos from Radio Shack, I find the recent decline, and inevitable demise, of Radio Shack, to be very sad.

When we were kids, my brother and I would put “Anything from Radio Shack” on our Christmas lists, and this meant electronics kits, soldering irons, resistors, capacitors, transistors, wire, breadboards, and other related electronics hobby items.

While RS still has this stuff, they de-emphasize it, and are pushing consumer electronics and toys – in other words, the very stuff that Walmart can undersell them on every time.

Now, I realize that the market for electronics kits is pretty small, and that computer “education” in schools doesn’t encourage kids to actually open up the computers and see what’s inside of them. I realize that Radio Shack is doomed. But for them to send me a flier rubbing my nose in this fact seems a little cruel.

Yes, I’d probably still be happy with anything from Radio Shack. But there’s very little at Radio Shack that I wouldn’t go somewhere else to buy.

Ironically, when I was looking for a radio, of all things, I went to Radio Shack. I couldn’t find one. (More specifically, a short-wave radio, not a consumer-grade boom box.) Apparently Radio Shack no longer carries radios. They could special order it, but they didn’t have any in stock, because people just don’t buy them any more.

Very, very sad.

Voting

I voted this morning. The line was about the same length as other years, but took probably 4 times as long. The voting machines were *significantly* harder to use than those we’ve had in previous years. Still fairly easy for folks used to computer UI widgets, but a lot harder than pressing squares on a ballot. And, what with the longer ballot, and the folks not deciding how they were going to vote until sat down in front of the ballot, it took folks FOREVER to get through voting.

The “new” voting machines had an RS232 port on the back labeled “Modem”. This doesn’t bode well.

Plazes

Plazes has become way cooler since the last time I looked at it. It includes one feature that I always wanted, but assumed was impossible – you can now pick up a marker on the map and drag it to its correct location, and this updates the coordinates. This way, you can put in approximate coordinates, and then fine tune them visually. Amazingly cool.

You should sign up and check it out. That way I’ll know exactly where you are, at all times. Mwuhahah!