Since no one has mentioned it yet - Varnish-cache.org, written by a FreeBSD kernel hacker, has a very nice feature, in that it will put all overlapping concurrent requests for the same cacheable resource "on hold", only fetch that resource once from the backend, then serve the same copy to all. Nearly all the expensive content on HN would be cacheable by varnish. Then you can get it down to pretty close to "1 backend…
Reverse proxies won't work for HN, because requests for the same resource from multiple users can't use the same results. Not only are certain bits of info customized for the user (like your name/link at the top), but even things like the comments and links are custom per user. Things like users' showdead value, as well as whether the user is deaded, can drastically change the output of each page. Eg, comments by a d…
Why HN was slow and how Rtm fixed it
91–100 of 202 posts
Re: Why HN was slow and how Rtm fixed it
#92Earlier quoted context omitted.
flat files, no database
That's not the bottleneck. Essentially there's an in-memory database (known as hash tables). Stuff is lazily loaded off disk into memory, but most of the frequently needed stuff is loaded once at startup. The bottleneck is the amount of garbage created by generating pages. IIRC there is some horrible inefficiency involving UTF-8 characters.
Re: Why HN was slow and how Rtm fixed it
#931 thread per connection??? Not doing continual GC in a separate thread and instead taking 7 seconds and blocking everything? What is this the 1990s?
Feel free to fork MzScheme and replace the garbage collector with a new one that runs continuously.
I'd trust my life on the JVM, it's pretty battle tested, and the GC is simply awesome.
Re: Why HN was slow and how Rtm fixed it
#94YC ranks 2400 on Alexa, and I'm sure most of the traffic is HN. I bet you'd be hard-pressed to find a top 10k site written in Scheme. Does anyone know of one? http://www.alexa.com/siteinfo/ycombinator.com
Re: Why HN was slow and how Rtm fixed it
#951 thread per connection??? Not doing continual GC in a separate thread and instead taking 7 seconds and blocking everything? What is this the 1990s?
Feel free to fork MzScheme and replace the garbage collector with a new one that runs continuously.
Re: Why HN was slow and how Rtm fixed it
#96Earlier quoted context omitted.
Can't you only use varnish for mostly non-dynamic content? Like for example, wouldn't the fact that it displays my username and karma score at the top of the page make it so that you couldn't use varnish (or at least make it more difficult)?
Yes, you'd have to somehow separate the dynamic content from the static content so they could be fetched in different requests and then combined (probably via ajax). If it's just your username and karma then it's simple enough, but if the comments are displayed differently for different people then it could be bear.
I once posted a comment which was immediately invisible to everyone besides me - I'm guessing it was marked as spam for some reason, but left visible to me so I think I successfully posted it.
Re: Why HN was slow and how Rtm fixed it
#97I worked at a startup once that made a network card that did this type of buffering (wait for whole HTTP requests, then forward as a lump to the host, across a local fast bus). Pretty whizzy, definitely helped server scaling. We started shipping in 2001; the dot-com bust more or less canceled any interest in the product, and canceled the company, too . . .
Re: Why HN was slow and how Rtm fixed it
#98Earlier quoted context omitted.
Unless they built their server with nand gates, I don't see running nginx reverse proxy to be incoherent with their philosophy.
Right, they only re-invent wheels when they feel they can make a better one. I don't think they feel they can go through the effort of fabricating a better chip. Though I wouldn't put it past rtm to try. The philosophy "Don't reinvent the wheel" however, is definitely inconsistent with their philosophy. They will reinvent the wheel whenever they feel they can make a better one. Just because they haven't reinvented ev…
Re: Why HN was slow and how Rtm fixed it
#99I may have misunderstood but it sounds like you have MzScheme facing the open internet? Try putting nginx (or another epoll/kqueue based server) in front of MzScheme. It will handle the thousands of connections you have that are waiting for IO with very little incremental CPU load and with a single thread. Then when nginx reverse proxies to MzScheme each request happens very fast because it's local which means you need much fewer threads for your app server. That means less memory and less of the other overhead that you get with a high thread count.
An additional advantage is that you can enable keepalive again (right now you have it disabled it looks like) which makes things a faster for first-time visitors. It also makes it slightly faster for us regulars because the conditional gets we do for the gif's and css won't have to reestablish connections. Less connections established means you give your OS a break too with fewer syn/syn-ack/ack TCP handshakes.
Someone mentioned below that reverse proxies won't work for HN. They mean that caching won't work - but a reverse proxy like nginx that doesn't cache but handles high concurrency efficiently should give you a huge perf improvement.
PS: I'd love to help implement this free. I run a 600 req/sec site using nginx reverse proxying to apache.
Re: Why HN was slow and how Rtm fixed it
#100I understand if you are in tech you might not know figures in history or literature... but these guys?
Every time you login to a UNIX/Linux system you use the passwd file and related setup - authored at least in part by Rtm's father.
http://www.manpages.info/freebsd/passwd.1.html
Rtm has done lots in his own right as the wikipdia pages show.
But seriously - if you don't know who these people are you really should.
Read this: http://www.princeton.edu/~hos/Mahoney/unixhistory
and maybe ESR's writings and that online anthology of the early Apple days and old issues of 2600, etc, etc
I am sorry - but it is really irritating to me that someone would be on this site and really not be aware of the deeper history and culture. It is not that deep - 1950s to present (to cover Lisp).
As Jay-Z (whom you probably know) says - "Go read a book you illiterate son of a bitch and step up your vocab ..."