Hambone Blues Jam

Home Decoration Tips
Reddit Architecture – Web Development

Reddit Architecture – Web Development


The architecture originally looked something like this
–we basically had one machine that we were renting from this company–I’m not even
going to mention their name, they’re so bad. I’ll try to only mention companies I like. But we are renting one machine and let’s
basically ran this, and this is all of Reddit. We’re also running post quiz on this
machine and that was it. We didn’t have any fancy caching.
I just used in-memory hash tables. The database had a fairly guessable structure. We had a table for links, we had a table for votes,
and a table for users. That may have been it to begin with.
There wasn’t a whole lot to Reddit. We didn’t have any comments for a long while,
and the links and votes tables were basically kind of as I represented them in this lecture. These had things like score, title, URL.
Vote basically had a length ID, a direction. User had a name and a password. Notice I didn’t say password hash–
I actually stored the password and told you that story how I’d gotten
trouble as a result of doing that. We actually did a lot of joins–this lasted
probably about for 6 months or so. After 6 months, we hired a couple guys
–well, we kind of merged our company with another company called Infogami
and that brought us another engineer named Aaron Swartz and we hired Chris Slowe
who was doing a PHD at the time. So the four of us–me, Alexis, Aaron and Chris–
worked on Reddit then. And the first change that Aaron and I made together was we reroute Reddit from Lisp to Python. And then at about the same time, we pulled
the database out of that one machine and put it on the second machine,
and so now we had two machines with this hosting company–our app server and our DB. And the switch from Lisp to Python
was kind of performance agnostic. Lisp was a faster language but our
rewrite of Python was better, so the code actually run at about the same speed. Going from one machine to two machines gave us something on the order of 4x speed improvement. Remember how I talked in the last lecture about
separation of services–separating our app server from our database gave us a tremendous
speed improvement because these two pieces of software run totally different
–use computers in a totally different way. That was the first architecture change we made. I think we upgraded this machine once or twice
to like a more beefy machine. At the time we are still plagued by downtime,
whether it was our Lisp or a Python program, it would occasionally just crash and we’d have to get notified–more often I’d just get called. I would check the site or somebody would call me
to tell me the site was down and I’d bring it back up. There’s so many easy ways to avoid this scenario. It makes me cringe when I think about how much
time and stress I spent on not knowing whether our website was running. The way we do it now is we use a
piece of software called Supervise, which we integrated shortly thereafter. Basically what supervise does is that it watches a program. It runs a program, and if that program crashes,
it restarts it. And that’s really a nice setup to have, and we actually got to the point where we’d run two Python programs on one machine and
then we had a little mini load balancer kind of running on that machine as well that would
send traffic to both of these Pythons and if one of them died, Supervisor bring it back up. And so unless the whole machine died–luckily,
it never actually happened to us. On the website would stay running. At that time, we still
only had one database machine. We were very lucky, and we’re very lucky that
neither of these machines ever died Because if you lost this machine, the website would
have been down until we could get a new one, and our hosting provider was very slow–it would’ve
been very difficult. And if we had lost this one, our database machine,
we would’ve lost the data–like forever. We weren’t doing good backups back then and
it was really fortunate that Reddit turned into a popular thing, and it’s really cool that
we still have those archived as a result of luck that we didn’t lose those
because you will lose machines. Machines die all the time. This is kind of a fact of life. I mean you’re running these machines around
the clock, high load, hard disk can fell, memory can fell–there’s lots of things that can go wrong if you use a machine constantly on high load.

11 comments found

  1. Perhaps now he can focus on getting rid of hate subreddits including r/the_donald and abide by a better ethics model.

  2. Jesus the way he moves the pen without writing anything is driving me fucking crazy! I don't know why, but it is cracking my spine

  3. I don't understand how separating services onto different boxes increase speed, if anything I would think it would decrease because of the inter communication. Someone please explain to me. Does it have more to do with the benefits of keeping concerns separate?

Leave comment

Your email address will not be published. Required fields are marked with *.