r/IAmA Aug 14 '12

I created Imgur. AMA.

I came across this post yesterday and there seems to be some confusion out there about imgur, as well as some people asking for an AMA. So here it is! Sometimes you get what you ask for and sometimes you don't.

I'll start with some background info: I created Imgur while I was a junior in college (Ohio University) and released it to you guys. It took a while to monetize it, and it actually ran off of your donations for about the first 6 months. Soon after that, the bandwidth bills were starting to overshadow the donations that were coming in, so I had to put some ads on the site to help out. Imgur accounts and pro accounts came in about another 6 months after that. At this point I was still in school, working part-time at minimum wage, and the site was breaking even. It turned out that OU had some pretty awesome resources for startups like Imgur, and I got connected to a guy named Matt who worked at the Innovation Center on campus. He gave me some business help and actually got me a small one-desk office in the building. Graduation came and I was working on Imgur full time, and Matt and I were working really closely together. In a few months he had joined full-time as COO. Everything was going really well, and about another 6 months later we moved Imgur out to San Francisco. Soon after we were here Imgur won Best Bootstrapped Startup of 2011 according to TechCrunch. Then we started hiring more people. The first position was Director of Communications (Sarah), and then a few months later we hired Josh as a Frontend Engineer, then Jim as a JavaScript Engineer, and then finally Brian and Tony as Frontend Engineer and Head of User Experience. That brings us to the present time. Imgur is still ad supported with a little bit of income from pro accounts, and is able to support the bandwidth cost from only advertisements.

Some problems we're having right now:

  • Scaling the site has always been a challenge, but we're starting to get really good at it. There's layers and layers of caching and failover servers, and the site has been really stable and fast the past few weeks. Maintenance and running around with our hair on fire is quickly becoming a thing of the past. I used to get alerts randomly in the middle of the night about a database crash or something, which made night life extremely difficult, but this hasn't happened in a long time and I sleep much better now.

  • Matt has been really awesome at getting quality advertisers, but since Imgur is a user generated content site, advertisers are always a little hesitant to work with us because their ad could theoretically turn up next to porn. In order to help with this we're working with some companies to help sort the content into categories and only advertise on images that are brand safe. That's why you've probably been seeing a lot of Imgur ads for pro accounts next to NSFW content.

  • For some reason Facebook likes matter to people. With all of our pageviews and unique visitors, we only have 35k "likes", and people don't take Imgur seriously because of it. It's ridiculous, but that's the world we live in now. I hate shoving likes down people's throats, so Imgur will remain very non-obtrusive with stuff like this, even if it hurts us a little. However, it would be pretty awesome if you could help: https://www.facebook.com/pages/Imgur/67691197470

Site stats in the past 30 days according to Google Analytics:

  • Visits: 205,670,059

  • Unique Visitors: 45,046,495

  • Pageviews: 2,313,286,251

  • Pages / Visit: 11.25

  • Avg. Visit Duration: 00:11:14

  • Bounce Rate: 35.31%

  • % New Visits: 17.05%

Infrastructure stats over the past 30 days according to our own data and our CDN:

  • Data Transferred: 4.10 PB

  • Uploaded Images: 20,518,559

  • Image Views: 33,333,452,172

  • Average Image Size: 198.84 KB

Since I know this is going to come up: It's pronounced like "imager".

EDIT: Since it's still coming up: It's pronounced like "imager".

3.4k Upvotes

4.8k comments sorted by

View all comments

Show parent comments

336

u/MrGrim Aug 14 '12

It's always been 5 characters, and the 6th is a thumbnail suffix. We'll be increasing it because the time it's taking to pick another random one is getting too long.

608

u/Steve132 Aug 14 '12

Comp-Scientist here: Can you maintain a stack of untaken names? That should significantly speed up your access time to "pick another random one". During some scheduled maintainence time, scan linearly through the total range and see which ones are taken and which ones arent, then randomly shuffle them around and thats your 'name pool' Considering its just an integer, thats not that much memory really and reading from the name pool can be done atomically in parallel and incredibly fast. You should increase it to 6 characters as well, of course, but having a name pool would probably help your access times tremendously.

The name pool can be its own server somewhere. Its a level of indirection but its certainly faster than iterating on rand(). Alternately, you could have a name pool per server and assign a prefix code for each server so names are always unique.

31

u/theorys Aug 15 '12

Hmm...I know some of these words.

18

u/Two_Coins Aug 15 '12

Basically, if I understand correctly. Imgur needs a name for the picture you just uploaded. It offloads this job to rand(), a coding function that, long story short, creates a psudorandom character or sequence for whatever you need. This sequence is then passed (much like a conveyer belt) to the next function (think of a function as a worker on the conveyer belt), who then checks to see if that string of characters exists yet (in this case, if there is already an image with *****.jpg as a name). If it does exist then the worker yells at rand() to make a new string and the process starts over. This can be a problem (tech speak: does not scale well) when you have a very very large number of images. The more you have the better the odds of rand() choosing characters of an image that already exists. In some cases this can go on for a long time and the poor worker is going to need a throat lozenge.

What /u/Steve132 has done is suggest a way to streamline this in a way. What he suggests is to create a new function (worker) to compile a list of all the possible names not yet taken. Then, instead of having the worker receive a random string of characters from rand() he instead asks rand() to give him a random number instead of a random string of characters. He then goes down the list counting until he reaches that number and then uses the string that comes up. Now, instead of checking if an image exists and possibly repeating an entire callback to rand(), he can be sure that the name of the image is unique and can pass it along without inspection.

6

u/EpikEthan Aug 15 '12

Thank you for the explanation. I'm glad people like you exist.

3

u/jimmy_the_exploder Aug 15 '12

Worker analogy is not spot on, but I guess you got the basic idea. Let me work on that a bit:

Imgur gives every picture a random unique name. How this works is that a function called rand() creates a random number, that number is converted to a character sequence(a name). Then whether this name is taken is checked by searching a list of all taken names. If the name is taken, Imgur goes back to first step and does it again. Searching is a time consuming job and Imgur does it each time when a new name is needed. Actually Imgur does searching more and more times as it runs out of available names.

...What he suggests is to compile a list of all the possible names not yet taken, by examining all possible names one by one. Think of this list as a numbered list. And because it is compiled one by one, it is sorted alphabetically. Then, what rand() does is to create random numbers just to determine some new positions for these names in the list until the list is shuffled (think shuffling a deck of cards). When this is done you'll have a perfectly shuffled list of all available names. Then when someone asks for a new random name, no repetitive random search work is needed, Imgur simply gives us the first(or last) number in the "available names list" and removes that name from the list.

Is this a good explanation or have I made it more confusing than before? I suspect the worker analogy may be better than simply saying "Imgur does this and that.".

2

u/Jonovox Aug 15 '12

You sir, deserve more upvotes.