buffer chains optimisation

François Battail fb at francois.battail.name
Fri Apr 25 22:31:11 MSD 2008

Chavelle Vincent <lists at ...> writes:

> I read the guide about the Nginx module development and I don't find any
> description about how buffer chains are processed. For example, I send a
> file line by line and I would like to know if it's optimized to create
> one buffer (ngx_buf_t) and one chain (ngx_chain_t) for each line or to
> concatenate entire document and send it with only one buffer/chain.

One buffer and one chain is OK. You can use a static string to setup a buffer
(without copying) or a dynamically allocated string (via the pool of memory
automagically freed when the request is done); that way you can mix buffers in a
chain with different kind of data. So in your case one buffer for the entire
document should be a good approach.

Best regards.

More information about the nginx mailing list