1

I have been reading this link: http://blog.martinfjordvald.com/2010/08/file-uploading-with-php-and-nginx/ (a blog whose posts are repeatedly linked from the official Nginx site) which says:

Each time Apache accepts an upload one of these processes is going to be busy for the duration of the upload.

Now I will admit I am a noob at Nginx but doesn't it also suffer the problem that one of its own workers will be used for the duration of the upload, OK, fair enough it isn't a PHP instance with the RAM/CPU problems that come with it but it is still limited (i.e. x number of connections), right?

I am not sure if the advantage of using Nginx here is quite explained.

The Nginx documentation itself is not, currently, very clear on exactly how it truly processes a request so if I have something incredibly wrong about how Nginx works then I hope someone will fix it instead of downvoting.

4
  • 1
    No, they didn't explain it, but this does. Dec 14, 2013 at 22:23
  • 2
    @MichaelHampton almost didn't see that the link color and text color are the exact same here, thanks!
    – Sammaye
    Dec 14, 2013 at 22:25
  • @MichaelHampton: wouldn't the link along with an excerpt regarding this question be a good answer? Either way thanks for pointing to these books. Dec 15, 2013 at 1:08
  • Basically it comes down to asynchronous IO in nginx allowing it to handle other things while reading and writing the data. Also points for reading the post and thinking further on things instead of just blinding accepting everything I've written! Dec 15, 2013 at 4:34

1 Answer 1

1

Ok so from @MichealHampton's link ( http://www.aosabook.org/en/nginx.html#fig.nginx.arch ) I am basically going to sum it up.

The first thing to note is that Apache 2.4 also brings in (as the link says) some interesting changes, namely the event MPM: http://httpd.apache.org/docs/trunk/mod/event.html which is more of a non-blocking version of: http://httpd.apache.org/docs/trunk/mod/worker.html designed to create as little friction as possible when it comes to IO usage by devolving work to other threads leaving the main thread free to continue its work.

This of course does not overcome the fundamental problem with Apache, which is its memory and CPU usage (it is after all a generic set of tools) but it is a step in the right direction and means that Apache does not have to be blocking anymore but can be more asynchronous.

This instantly means that Nginx can of course handle a lot more than Apache even with Apache 2.4s changes, since it uses less.

The main point about Nginx when it comes to uploads is its workers abilities to be able to not be tied to a single task despite being single threaded. Using event notifications with a tight loop to process asynchronous IO allowing a single worker to be able to take multiple (maybe 1,000s) of uploads a time even on a single worker.

This is still in contrast to Apaches non-event model, and even though Apache is going the same route as Nginx slowly it is still not quite there, however, I should reiterate that Apaches ability to run "events" continually on supporting threads while keeping the main thread free is kinda kool. The one single problem is that this still creates the blocking effect where Apache says: "This connection is running, I won't drop its blocking until it is done", so its name is not really true "event-mpm" as Apache can still suffer from the scenario laid out in the link near the following lines:

It can be merely a fraction of a second to generate or retrieve this page, but it takes 10 seconds to transmit it to a client with a bandwidth of 80 kbps (10 KB/s).

Really Apaches problems with uploading depends on what you are uploading. Since my uploads are large and could reach in the GBs Apache could pose a problem, but if you were to upload images and not much else there is a high chance that the changes in Apache could work.

That's pretty much summed up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .