Its genius really
The code for checking whether a username was taken was inefficient, so it was taking a huge amount of time to create a new account. The culprit was this line:
(some [is dcuser (downcase _)] (keys hpasswords*))
The reason the TechCrunch post slowed the site down so much was not the traffic per se but the number of those visitors who were creating new accounts. I pasted a fix into the repl, so the site should be faster now.Thanks to Rtm for narrowing the problem down to account creation.
The reason [the site was slow] was not the traffic...
but the number of visitors who were creating new accounts.
The only better startup problem than that is "the site was slow because so many people were trying to give us money that our credit card processor crashed".For that matter, you can get the same effect with the MySQL prompt and a shared-nothing PHP architecture.
I see how you could, say, drop a user from the users table using this; but how would you fix a login bug like the one under discussion?
EXPLAIN SELECT username FROM users WHERE username = $dc_user
Then look at the output, and either CREATE INDEX users_username ON users(username)
Or cache the result, or do something else to fix the performance problem...If you meant "How do you find out it was in the registration check?", that's what the slow query log and query profilers are for...
(Seriously, though, this should give pg and company some valuable benchmarking data for later on.)
But, yeah, if you're a hacker, hacker news is better yet.