Disable memory buffer for file uploads

Francis Daly francis at daoine.org
Wed Mar 23 13:16:56 MSK 2011


On Wed, Mar 23, 2011 at 11:43:08AM +0800, Space Lee wrote:

Hi there,

> I have a question, will write to the disk much more slower than using memory? 

Usually, yes.

But the full sequence is more like "read from network", "write to buffer",
"read from buffer", "write to fastcgi server or http server or whatever
nginx sends the request to".

Will the write to disk (buffer) be much slower than the read from network?

If you have enough memory (and a good OS disk cache), the "read from
buffer" may effectively be "from memory" anyway.

> So my question is : 
> when users upload large files, should I use large memory for client_body_buffer_size or little memory.
> when users upload small files, should i use large memory for client_body_buffer_size or little memory.

How much time will it take for your user to complete the upload http
request, for nginx to buffer it, pass it on, and to have it processed
by whatever nginx passes it on to?

In that time, how many other user upload-requests will start? (= N)

And how much total real memory do you want to use for upload-request
buffers? (= M)

M/N is a rough guide to the size you want for client_body_buffer_size. You
don't want your upload-request buffers to push the memory use above the
real memory available.

> And in this situation, when he finishes uploading, will the content be remove when the memory for client_body_buffer_size is full, and so that new uploaded files could use the memory. 

The buffer will eventually be released. From a capacity point of view, expect
it not to be released until the http connection is closed by the server.

(Exactly when it is released is less important -- for capacity planning,
assume the worst :-)

All the best,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list