I Can't Decide
icantdeci.de
icantdeci.de
Someone in the thread mentioned that they're "not sure how you could screw up a web app this simple." I'm entirely sure how we screwed it up.
My friend came up with the idea, designed the layout, and I built it. It was a spare time thing, just for fun. When we launched we seeded the database with a couple hundred questions and put it out there. Somehow (thank you Twitter, Tumblr, etc), the site saw 10,000 uniques in its first day, which exposed the fact that I'd over-normalized the database to death, and the site could hardly function. We launched at 11am, and by 3pm I was on the phone with mediatemple to upgrade the server just so there'd be enough memory to allocate an ssh session.
I spent a sleepless 72 hours after that rebuilding the architecture to try and make it scale, which it did -- for a while.
But now we've got a database with 13 million votes in it, and the app must cross-reference those votes with a user guid so as to serve fresh content, and it's simply outgrown whatever fixes I was able to make during that marathon coding weekend.
I haven't done any work on it in months, yet every so often it pops up somewhere on the web and guilts me into thinking I should probably re-architect it once again...
So if I don't sleep or leave my apartment this weekend I've got you all to thank :)
And you're willing to take a MASSIVE performance hit to guarantee that, for all users.
OK, let me take a wild stab in the dark: you've got over 1,000 unique pairs in the database. You ask the overwhelming majority of users 5 questions. The chance of a user getting 5 unique questions, if you just pull them randomly out of the DB, is about 99%. And that would be Pretty Darn Fast to calculate.
Or, here's a cheap trick for you -- partition your table of questions into 5 groups. A really simple way is to take primary key mod 5, but if you want to do it better you just hash the input and then take mod 5, then store that in a group column. For the first question, choose randomly from group 1. For the second question, choose randomly from group two. etc. By construction, it is now impossible to ask the same user the same question twice.
Which means you don't have to store a user's prior votes at all. Just store counts.
There, enjoy your million-fold performance increase.
Sometimes I think this is the true reason the internet was created.
(additionally, you can substitute education with noun of choice)
so, on a choice with many votes, if it's 50-50 with an odd number of votes you can't tell which one wins.
Anyone know the url? I remember having a laugh reading some of them.
Might be what you're looking for.
:(
Less robo-defense and more features please!
I am not affiliated with that site but they seem fairly similar in concept. Not sure which I like better.
Worked well for me, though. Neat app.
2^10
or
((10*101)+(((2^3)*2)-2))
Ummm...Vert cool, like the design, layout, and how it works! :)
I got back a tie.
Oh well, I worked through to dinner anyway.....