News for hackers. Stuff that matters.
Re:Ask HN: Make makes nginx so fast ? by zepolen on Wednesday February 24, 2010 @06:56AM (#1147777)
Yes, being event based helps a lot, but the reason nginx is faster than other event based webservers is that it tries very very hard to add as little overhead as possible; For example not copying memory around unless absolutely neccessary.
Re:Ask HN: Make makes nginx so fast ? by lukatmyshu on Wednesday February 24, 2010 @07:54AM (#1147846)
(expanding on this) nginx uses a buffer-chain architecture internally. This means that if your data comes in chunks when you read it in (remember, nginx is event based) then it's stored internally in fragments that correspond to those reads. Almost all the operations on it work on those chains so often times the data never has to be copied until it's written (I believe using iovectors) back out. Memory is managed in request pools which minimize memory fragmentation, and are just faster/safer than calling malloc/free directly.