Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use gconf keepalive_timeout for connection lifetime (Brady McCary)

Previously persistent connections were held open for a hard-coded 30
seconds, and if no request was received in that time, Yaws closed the
connection. Change this behavior to use the gconf keepalive_timeout
field to determine the amount of time the connection is held open
rather than using a hard-coded timeout. The default is still 30
seconds, but users can change the default by specifying a different
value for keepalive_timeout in their Yaws configuration.

Also, fix yaws.tex to document the keepalive_timeout setting as well
as other recent changes such as max_connections and keepalive_maxuses.
  • Loading branch information...
commit 17be95730f93b864ed1a091275914a310c44cc69 1 parent 9194d12
@vinoski vinoski authored
View
35 doc/yaws.tex
@@ -1633,11 +1633,11 @@ \section{All out/1 return values}
valid redirect status codes.
\item \verb+{redirect_local, Path}+
- Does a redirect to the same Scheme://Host:Port/Path
- as we currently are executing in. Path can be
- either be the path directly (equivalent to
- \verb+abs_path+), or one of \verb+{{abs_path, Path}+ or
- \verb+{{rel_path, RelativePath}}+
+ Does a redirect to the same Scheme://Host:Port/Path in
+ which we are currently executing. Path can be either be
+ the path directly (equivalent to \verb+abs_path+), or
+ one of \verb+{{abs_path, Path}+ or
+ \verb+{{rel_path, RelativePath}}+
\item \verb+{redirect_local, Path, Status}+
Same as \verb+redirect_local+ above with the additional
@@ -2072,10 +2072,10 @@ \section{Global Part}
\item \verb+max_size_cached_file = Integer+ -
This directive sets a maximum size on the files
- that are RAM cached by \Yaws\ . The default value i
+ that are RAM cached by \Yaws\ . The default value is
8000, 8 kBytes.
-\item \verb+cache_refresh_secs = Integer+
+\item \verb+cache_refresh_secs = Integer+ -
The RAM cache is used to serve pages that sit in
the cache. An entry sits in cache at most
cache\_refresh\_secs number of seconds. The default
@@ -2086,6 +2086,27 @@ \section{Global Part}
If the debug flag (-d) is passed to the \Yaws\ start
script, this value is automatically set to 0.
+\item \verb+max_connections = nolimit | Integer+ -
+ This value controls the maximum number of connections
+ from HTTP clients into the server. This is implemented
+ by closing the last socket if the threshold is reached.
+
+\item \verb+keepalive_maxuses = nolimit | Integer+ -
+ Normally, \Yaws\ does not restrict the number of times a
+ connection is kept alive using keepalive. Setting this
+ parameter to an integer \verb+X+ will ensure that
+ connections are closed once they have been used \verb+X+
+ times. This can be a useful to guard against
+ long-running connections collecting too much garbage in
+ the \Erlang\ VM.
+
+\item \verb+keepalive_timeout = Integer | infinity+ -
+ If the HTTP session will be kept alive (i.e., not
+ immediately closed) it will close after the specified
+ number of milliseconds unless a new request is received
+ in that time. The default value is 30000. The value
+ \verb+infinity+ is legal but not recommended.
+
\item \verb+trace = traffic | http+ -
This enables traffic or http tracing. Tracing is
also possible to enable with a command line flag to
View
3  include/yaws.hrl
@@ -73,7 +73,7 @@
logdir,
ebin_dir = [],
runmods = [], %% runmods for entire server
- keepalive_timeout = 15000,
+ keepalive_timeout = 30000,
keepalive_maxuses = nolimit, %% nolimit or non negative integer
max_num_cached_files = 400,
max_num_cached_bytes = 1000000, %% 1 MEG
@@ -301,7 +301,6 @@
--define(READ_TIMEOUT, 30000).
View
48 man/yaws.conf.5
@@ -102,27 +102,27 @@ new ssl implementation.
Enable or disable the auth log. Default is true.
.TP
-\fB max_connections = nolimit | <int>\fR
+\fB max_connections = nolimit | Integer\fR
Set this value to control the maximum number of connections
from HTTP clients into the server. This is implemented by closing
the last socket if the limit threshold is reached.
.TP
-\fB keepalive_maxuses = nolimit | <int>\fR
+\fB keepalive_maxuses = nolimit | Integer\fR
Normally, yaws does not restrict the number of times a connection is
kept alive using keepalive. Setting this parameter to an integer X
will ensure that connections are closed once they have been used X times.
This can be a useful to guard against long running connections
-collecting too much garbage in the erlang VM.
+collecting too much garbage in the Erlang VM.
.TP
\fB process_options = "[]" | "[{fullsweep_after, int()} | {min_heap_size, int()}]"\fR
-Override the garbage collection option parameters for processes
-which handle new connections. Useful for systems which expect long lived
-connections which handle a lot of data. The default value is erlangs
+Override the garbage collection option parameters for processes that
+handle new connections. Useful for systems that expect long-lived
+connections that handle a lot of data. The default value is Erlang's
default which does minimal garbage collection until the process dies.
-The value type is a quoted string which contains an erlang proplist.
-See erlangs erlang:spawn_opt/4 function for more details.
+The value type is a quoted string which contains an Erlang property
+list. See Erlang's \fIerlang:spawn_opt/4\fR function for more details.
.TP
\fB log_wrap_size = Integer\fR
@@ -200,11 +200,18 @@ whereas in testing/development scenarios it may be convenient to
set it to true. Default is true.
.TP
+\fB keepalive_timeout = TimeInMilliseconds | infinity \fR
+If the HTTP session will be kept alive (i.e., not immediately closed)
+it will close after keepalive_timeout milliseconds unless a new
+request is received in that time. The default value is 30000. The
+value \fIinfinity\fR is legal but not recommended.
+
+.TP
\fB use_fdsrv = true | false \fR
-This feature makes it possible to bind to ports < 1024 even when
-we're not running as root. It requires the Jungerl package called fd_server
-to be properly installed. The feature doesn't work with SSL. Default is false.
-The use of fdsrv is not encouraged, see
+This feature makes it possible to bind to ports < 1024 even when we're
+not running as root. It requires the Jungerl package called fd_server
+to be properly installed. The feature doesn't work with SSL. Default
+is false. The use of fdsrv is not encouraged, see
http://yaws.hyber.org/privbind.yaws
.TP
@@ -321,17 +328,17 @@ for files to ssi/yssi include.
\fBpartial_post_size = Integer | nolimit\fR
When a yaws file receives large POSTs, the amount of data received
in each chunk is determined by the this parameter.
-The deafult value is 10240.
+The default value is 10240.
.TP
\fBdav = true | false\fR
-Turns on the DAV protocol for this server. The dav support
-in yaws is highly limited. If dav is turned on, .yaws processing
-of .yaws pages is turned off. Default is false.
-Setting it to nolimit is potentially
-dangerous. There is a hardcoded timeout on POST reads at 30 seconds.
-If the read is not done within the timeout, the POST will fail.
+Turns on the DAV protocol for this server. The dav support in yaws is
+highly limited. If dav is turned on, .yaws processing of .yaws pages
+is turned off. Default is false. Setting it to nolimit is potentially
+dangerous. The socket read timeout is supplied by the
+keepalive_timeout setting. If the read is not done within the
+timeout, the POST will fail.
.TP
\fBtilde_expand = true|false \fR
@@ -840,3 +847,6 @@ Written by Claes Wikstrom
.BR yaws (1)
.BR erl (1)
+Comment] Local Variables:
+Comment] mode: nroff
+Comment] End:
View
5 scripts/yaws.conf.template
@@ -117,6 +117,11 @@ auth_log = true
pick_first_virthost_on_nomatch = true
+# If the HTTP client session is to be kept alive, wait this many
+# milliseconds for a new request before timing out the connection. Note
+# that infinity is a valid value but it's not recommended.
+
+keepalive_timeout = 30000
# All unices are broken since it's not possible to bind to
# a privileged port (< 1024) unless uid==0
View
5 src/yaws.erl
@@ -1764,11 +1764,10 @@ ensure_exist(Path) ->
%%
%%
-
do_recv(Sock, Num, nossl) ->
- gen_tcp:recv(Sock, Num, ?READ_TIMEOUT);
+ gen_tcp:recv(Sock, Num, (get(gc))#gconf.keepalive_timeout);
do_recv(Sock, Num, ssl) ->
- ssl:recv(Sock, Num, ?READ_TIMEOUT).
+ ssl:recv(Sock, Num, (get(gc))#gconf.keepalive_timeout).
cli_recv(S, Num, SslBool) ->
Res = do_recv(S, Num, SslBool),
Please sign in to comment.
Something went wrong with that request. Please try again.