News for hackers. Stuff that matters.
Re:Optimizing Nginx for High Traffic Loads by morganpyne on Saturday April 30, 2011 @07:15PM (#2501839)
I would also recommend that you gzip any static assets and use http://wiki.nginx.org/HttpGzipStaticModule to serve these pre-gzipped files.

No point in re-compressing the same files over and over again. I normally gzip all static assets as part of the deployment process.

Re:Optimizing Nginx for High Traffic Loads by JshWright on Sunday May 01, 2011 @10:26AM (#2503056)
Perhaps even more importantly than not recompressing... If Nginx is reading gzipped files, rather than full size files, it reduces the pressure on filesystem cache. This increases the odds that the system won't have to go to the disk to find the requested resource.
Re:Optimizing Nginx for High Traffic Loads by jacques_chester on Saturday April 30, 2011 @10:46PM (#2502172)
Using this module and WP-supercache's gzipping feature has made a wordpress blog network I run astonishingly fast.
Re:Optimizing Nginx for High Traffic Loads by patio11 on Sunday May 01, 2011 @01:26AM (#2502436)
Note the absence of any particular setting which will cause it to crash if you get a link to your blog retweeted.

glares at Apache

Re:Optimizing Nginx for High Traffic Loads by not_chriscohoat on Saturday April 30, 2011 @10:20PM (#2502141)
Some useful Nginx optimizations, but I've always found that the bottlenecks are far worse elsewhere. Nginx is a champ at serving static files, and I have it proxy all requests upstream to Apache (and use mod_wsgi because the majority of what I work with are Django apps). Optimizing the DB schema and queries have had the most positive performance increases by far, followed by Apache tweaks, and then finally Nginx config changes. But I really love the setup I use for how easy it is to get a Django app spun up.
Re:Optimizing Nginx for High Traffic Loads by clemesha on Saturday April 30, 2011 @08:15PM (#2501939)
If your app uses a database, you've got bigger problems than optimizing Nginx for high traffic loads.

That said, I absolutely love Nginx because it's so damn lightweight, and easy to setup and maintain.

Re:Optimizing Nginx for High Traffic Loads by mfjordvald on Saturday April 30, 2011 @09:22PM (#2502043)
Even if your app does not use a database then you've still got bigger problems. Optimizing Nginx is often a bit of a joke as you don't really get a lot for your effort. I think reducing the IO impact of Nginx is probably the best thing you can do. CPU wise you're kinda stuck with the awesome stock performance.
Re:Optimizing Nginx for High Traffic Loads by peterb on Saturday April 30, 2011 @08:59PM (#2502005)
At scale, all components cause "bigger" problems: http server, app server, database/datastore, file system, load balancer, etc. Saying the database is a bigger problem is only true in specific situations.
Re:Optimizing Nginx for High Traffic Loads by brendoncrawford on Saturday April 30, 2011 @09:16PM (#2502032)
> The biggest optimization happened when you decided to use Nginx and ran that apt-get install...

I recommend against doing this on Ubuntu Lucid without first installing the unofficial nginx PPA, unless you want to get stuck with v0.7.65.

Re:Optimizing Nginx for High Traffic Loads by cullenking on Sunday May 01, 2011 @12:08PM (#2503233)
I actually use apt-get to install it at first, which gives me boot scripts. At least on Debian, you can apt-get remove it and the init scripts will still be there. Meaning, I don't have to go find one on the internet. Might not work outside of debian :)
Re:Optimizing Nginx for High Traffic Loads by hartror on Sunday May 01, 2011 @02:13AM (#2502509)
I should do that. I assume there are no issues uninstalling nginx and installing the PPA and then nginx right?
Re:Optimizing Nginx for High Traffic Loads by mfjordvald on Saturday April 30, 2011 @09:19PM (#2502038)
Thank you for pointing this out, I always tell people to do this so I should really take my own advice.
Re:Optimizing Nginx for High Traffic Loads by brendoncrawford on Saturday April 30, 2011 @09:29PM (#2502057)
Well, it doesn't negate your statement. apt-get is still a great way to install nginx.
Re:Optimizing Nginx for High Traffic Loads by justincormack on Sunday May 01, 2011 @06:21AM (#2502801)
I dont know, I compile from source the issue is that modules have to be compiled at runtime and everyone needs different sets, so there is rarely a PPA with what you want unless you build your own.

Its a build model that does not work so well with binary package managers, works better with say the Gentoo use flag model.

Oh and if you are not using any nginx modules you are missing out on a lot of its power, you should be able to move big chunks of your app like auth right into nginx, use redis and memcache directly, and so on.

Re:Optimizing Nginx for High Traffic Loads by originalgeek on Sunday May 01, 2011 @01:24AM (#2502428)
I think he's got a little math problem. Many browsers will open up to 4 connections (possibly more, if config tweaked) to overlap requests for content, so you might want to consider this when configuring your worker_connections.
Re:Optimizing Nginx for High Traffic Loads by thezilch on Sunday May 01, 2011 @06:10AM (#2502786)
This is not a math problem. It's a perception problem. In fact, even your assumption is wrong, on the number of connections a browser will open. Modern browsers will be found opening 6 to 8 connections, by default.

http://stevesouders.com/ua/report.php

Re:Optimizing Nginx for High Traffic Loads by rryan on Sunday May 01, 2011 @01:35AM (#2502454)
Each worker can handle many thousands of concurrent connections so this isn't really an issue. This is where nginx and Apache differ. Generally you want one worker per CPU core.
Re:Optimizing Nginx for High Traffic Loads by originalgeek on Sunday May 01, 2011 @03:59AM (#2502650)
I know how nginx works, I use it all the time. He is saying if you have 1024 woker_connections, at 2 per connections per user, you'll get 512 users per worker process. But the truth with most modern browsers is it is 4 connections per user, woker_connections = 1024, that is more like 256 users. So if you really want to service 512 users, you need to set woker_connections to 2048. This is the math problem I was highlighting, a simple division problem.

I believe you are talking about worker_processes

Re:Optimizing Nginx for High Traffic Loads by rryan on Sunday May 01, 2011 @02:16PM (#2503609)
Oops -- you're right I misread your comment. Sorry about that.
Re:Optimizing Nginx for High Traffic Loads by anto1ne on Sunday May 01, 2011 @05:22AM (#2502733)
too bad there's not so much said about optimizing latency, serving a lot of traffic is not that difficult, but getting the best latency to serve your files 50ms faster can make a big difference
Re:Optimizing Nginx for High Traffic Loads by mfjordvald on Sunday May 01, 2011 @05:34AM (#2502751)
This is kind of outside the scope of Nginx.
Re:Optimizing Nginx for High Traffic Loads by known on Sunday May 01, 2011 @07:46AM (#2502911)
Optimizing == Customizing as per your business needs