That's porn for database geeks: 100 million pageviews per day, 300k requests per second against Redis.
The way they use MySQL is also interesting IMHO: they populate a relational database in order to be able to build new indexes in the Redis side, using the relational DB for the stuff it is best at, generating new "views" of the data easily.
(Relational DBs are also good to do a zillion more things of course.)
I remember in the 90's having a conversation with my friend. We were discussing Linux vs Windows for web hosting. My friend said "tell me if you can find a single porn site that's hosted on Windows." He was right, I couldn't find any.
Reading tip for you: Prometheus Rising by Robert Anton Wilson. Especially the part about the first 4 primitive circuits of the mind which govern survival, dominance, sex, stuff like that. War is very centered on Circuit II: dominance, emotions and territorial thinking.
I assumed he was gesturing at the creation/destruction discord inherent in sex/war with war being the referent for obscene. Of course, a full account of sex more than kisses and pleasantries, it also involves competition.
The online porn industry were the first people to really deal with scalability (of managing and serving web content, anyway), the first people to deal with online payments, the first people to come under really heavy, sustained hacking attempts, etc. Don't underestimate how much of what you take for granted technologically in 2012, they pioneered in the mid-90s.
A friend of mine built a lot of porn sites in the late 90s using DB2 and Oracle. He says that Microsoft's SQL Server folks came to him to talk about what it would take to get him (and the porn sites) to use SQL Server.
He said that he was confident that DB2 and Oracle could handle the load. They responded that SQL Server was much more capable than he thought and asked him about the workload.
Their response to his answer was "we can't even simulate that, maybe we're not ready".
Indeed - I've heard it argued that the real reason that VHS won out over the technically superior Betamax format, was that Sony refused to license the Betamax technology to adult video vendors. Never dug into it, but it seems plausible.
We do the same thing, where we populate a mysql store as a secondary storage for business intelligence -- our Founder, PM, AdOps, etc know enough SQL to be dangerous if we build out more traditional, relational models.
It amused me that you were testing a porn site -- the homepage / potentially-misused zrange-issue.
There's 30 videos on the front page. Mousing over the image preview of a video displays a series of preview images.
There were 76 requests made as observed from the net tab in Firebug. The majority of these requests seemed to be for those video images. Note that I'm using an adblocker and refuse to check out the site without it.
Note also that they said 300k queries. There could be constantly-running background jobs doing conversion, pulling those preview frames, and crunching numbers on the metadata.
I'm doing something similar with Dirty Hot Productions (one of my clients). We use MySQL on a separate CMS Rails app to store everything, and all of the websites communicate with the CMS via an API. We use Redis to cache all of the API responses, so effectively everything except the first read (or the first "dirty" read) on a particular query is coming straight from Redis. It works amazingly well, and it doesn't use nearly the amount of RAM I thought it would.
For some reason I always imagine porn sites to be run by guys in cheap suits and lots of hair gel. Then I realize that in order to run a site with the kind of traffic that some of them have, you really need to have some decent engineers on staff.
You'd be surprised if you went to meetings with porn business companies in Japan. Stylish offices, elegant suits, great manners, no hint of actual porn anywhere. In fact, you could easily confuse the office with an investment bank.
I once had a surreal meeting with a hotel chain where they mentioned they had detailed management reports on stuff like the average time films are watched for and that they had a graph showing how long porn movies are watched for.
This was all being discussed in the context of a fairly formal business meeting.
Ok, I'm feeling rather naïve and waking up slowly this morning. Why do they care to know that? I mean, what about their business does that help them improve? Because, I think we can take it somewhat for granted that such information probably isn't something which the individuals involved, their customers in this situation, enjoy knowing is being collected about them. "Hey, you know that activity you probably consider rather private, we like to record everything about it we easily can, because umm... customer service."
If I kept track of the porn watching habits of my neighbors, that would be considered strange and maybe rather pervy. And I don't see how it makes a difference in that evaluation whether they are or aren't renting the tv they use from me.
It probably lets them know how long the movies they produce should be. If it's too long before any action is in there then people move on. If it's not long enough then the customer doesn't get what they want. Optimizing this means that they can take a single 8 hour shoot, that'll produce maybe an hour and a half of good footage (just pulling numbers out of my ass) and make more than one video of the right length to get the most profit out of it.
Ok, thanks, I'm restored to cynical now... and the business advantage to be found here is that they can go even further than just optimizing length to match what people want, they can make them just a bit shorter than more people would like, so people will buy two instead of just one.
It's probably an extra-cost service to the hotel guest. The hotel wants to know how much/how often the service is used so they can optimize it for their needs. No sense paying for more bandwidth than you need.
In any case, they probably have no need for individual statistics: the aggregated watching habits of guests is enough to provide useful information.
"For some reason I always imagine porn sites to be run by guys in cheap suits and lots of hair gel."
Pretty much the exact opposite actually. Porn industry guys tend to be 30 - 40 on average and super cool and laid back, though in an LA sort of way. I'm sure there's a lot of crap going on beneath the surface, but at least from the outside it seems like a much nicer work culture than silicon valley.
Some time ago I've read an IAmA on reddit with staff member of some big porn portal. It was quite interesting but I don't remember what porn site it was and don't want to blindly trying to google it as I'm at work. Writing this in case anyone knows and would post it here :)
First off, I am not saying that youporn guys are not decent but IMHO, people shouldn't get too excited about this.
Youporn is somewhat quite a simple site I'd imagine. It's just categorized videos with a bunch of stats (views, related video...), and users. There's almost no social interaction between users (i've just registered an account just to confirm that).
That's a very clear (and good) reason why 100% redis suits for this website, apart from the goodness of redis like sorted sets are perfect for the "top rated" or "being watched" sections
Imagine the site now wants to add a little bit of social interaction, like allowing users to post video, follow each others... I'd say 100% redis wouldn't work any more
I'm pretty sure i know what I'm looking for in a porn site. There's many things youporn can do to help me watch better stuff.
Say I'm a fan of a porn star XXX and I'd like to see a simple notification that there's recently a new video tagging her. Same thing if I like some particular user's taste for porn and would like to get noticed if he/she has posted a video. Basically if it gets more social, my wall or dashboard or whatever, would be more sorta relevant.
Sure, but the sharing is what makes it hard - as soon as your pages are per-user it gets interesting. For youporn, each video page is essentially static (maybe there are comments? Even if there are, I doubt they display a different set of comments to each /viewer/). So video pages are easy to cache, the database layout is simple, and sure there's some effort involved in scaling up but it's nowhere near as hard as e.g. tumblr's architecture that was featured recently (where every viewer sees a page with all the posts from everyone they're following, and so everyone's page is different)
I was just stating that building a site like that is not as trivial as you made it out to be. Yes you "only" have some videos, but you also have views of said videos, and comments and rankings. Building different views of videos based on those factors is hard if you have lots and lots of this data points. Not to mention that you then have to (somewhere) display just some user's videos sorted by how they ware ranked, or maybe just some user's videos from some category based on number of views (which is not a simple INT field in the db). Etc etc etc.
What I'm saying is that there is more than it meets the eye.
Nothing fancy actually. We have 3 dedicated storage servers (two in the same DC as our web server, one in germany), with lots and lots of disk space. We then SCP converted videos to them and serve them trough nginx (supports seeking).
Hey, thank you so much for the information. I hope you don't mind to share a little bit more (it's okay if you don't reply due to IP or whatnot, I'll understand).
How do you handle where to put the files on which disks? do you write custom software or there's some sort of off-the-shelf software to do this?
The reason I asked about this is because it looked like a few people I talked to seem to prefer to use Distributed File System such as HBase, GlusterFS or something else so that they don't have to write extra code.
And I'm guessing you back them all up on daily base as well?
We split files into two levels of folders. For instance if a video has a filename "somethingsomethingXY" it will go into "videos/y/x/" folder. Then it's up to our sys admins to mount those folders to whichever disk they want. So from the app's point of view it doesn't matter where the file actually is. And we backup everything every couple of hours.
Like I said, nothing fancy but it works without any issues (apart from a small delay when you have to copy the file to 2 or 3 different servers (redundancy) before it becomes available, but it's not a big problem but I have few ideas how to solve that if it becomes one :)).
I'm currently looking into redis for similar needs. I'd be using it from perl and wondered how will it would scale... (IIRC (from people I know who have worked there) youporn/pornhub runs on Catalyst, an MVC-based web framework written in perl.)
Probably a better question for the Redis group, but I'll throw it here anyway.
Can someone explain why there's no Ordered Map in Redis? Basically to achieve and ordered index, one has to use Sorted Set and a classic Hash Map, and pair these two when ordered data are needed, which is an extra level of indirection and wasted space. Am I missing something?