NaviServer - programmable web server


[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_writer(n) 4.99.3 naviserver "NaviServer Built-in Commands"

Name

ns_writer - Manage files with writer thread

Table Of Contents

Synopsis

Description

This command allows to submit data or file to be returned to the client connection using writer thread instead of current connection thread. Writer thread processes multiple sockets using async socket operations which consumes less resources than returning multiple files to the slow clients in separate thread.

COMMANDS

ns_writer list

Returns list of all currently submitted files

ns_writer submit data

Submit arbitrary data to be returned via writer, data can be binary

ns_writer submitfile ?-headers? ?-offset offset? ?-size size? file

Submits file to be returned, optionally the following arguments can be used:

-headers Tells the writer to provide required HTTP headers, like content size, type and status.

-offset If specified, file will be returned starting with this offset

-size If not specified, the whole file will be retuned, otherwise only given part. Can be combined with -offset to return chunks of file

CONFIGURATION

Basic configuration options:

ns_section "ns/server/default/module/nssock"
ns_param writerthreads 1
ns_param writersize [expr 1024*1024]

writerthreads parameter specified how many writer threads will be used, multiple threads will be rotated to spread the load across all threads

writersize specifies minimal size of the file to be considered for writer thread, this parameter is used by connection thread when returning file and if size exceeds configured value, file will be returned via writer thread and connection thread will be released to handle other requests.

EXAMPLES

ns_writer submitfile /tmp/biglist.txt

See Also

nsd

Keywords

NaviServer