1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

web server micro-tuning

* module/web/server/http.scm (http-open): Allow up to 128 pending
  connections -- the default value for somaxconn on a number of
  machines. This is from the HOP paper.
  (http-read): Set the send buffer to 12 KB, also from the HOP paper.
This commit is contained in:
Andy Wingo 2010-12-03 16:30:52 +01:00
parent 0baead3f6e
commit e6ae317306

View file

@ -56,7 +56,7 @@
INADDR_LOOPBACK)) INADDR_LOOPBACK))
(port 8080) (port 8080)
(socket (make-default-socket family addr port))) (socket (make-default-socket family addr port)))
(listen socket 5) (listen socket 128)
(sigaction SIGPIPE SIG_IGN) (sigaction SIGPIPE SIG_IGN)
(let ((poll-set (make-empty-poll-set))) (let ((poll-set (make-empty-poll-set)))
(poll-set-add! poll-set socket *events*) (poll-set-add! poll-set socket *events*)
@ -85,6 +85,8 @@
(let ((client (accept (poll-set-port poll-set idx)))) (let ((client (accept (poll-set-port poll-set idx))))
;; Set line buffering while reading the request. ;; Set line buffering while reading the request.
(setvbuf (car client) _IOLBF) (setvbuf (car client) _IOLBF)
;; From "HOP, A Fast Server for the Diffuse Web", Serrano.
(setsockopt (car client) SOL_SOCKET SO_SNDBUF (* 12 1024))
(poll-set-add! poll-set (car client) *events*) (poll-set-add! poll-set (car client) *events*)
(poll poll-set) (poll poll-set)
(lp (1- (poll-set-nfds poll-set))))))) (lp (1- (poll-set-nfds poll-set)))))))