Shttp

This software has been built using and depends on ServerKit.

Overview

Shttp is a partial implementation of HTTP/1.1. It does not strictly follow the RFC but works well enough to serve static content for personal/experimental/educational use. The module consists of just over 1000 LoC making it an excellent example of what can be done with ServerKit with little effort and a great learning tool for those getting started with ServerKit programming.

In addition to being very simple and an excellent module for learning ServerKit development, shttp is fast and scalable. ServerKits excellent design and implementation shine through in shttp benchmarks which place it above apache1, and apache2 in terms of speed for both small and large scales of concurrency. Shttp even outperforms other so-called "lightweight" or "high performance" http servers, like thttpd, boa, and nginx.

Click here for apache bench results comparing shttp 0.0.2 to apache1, apache2, thttpd, boa, and nginx. 0.0.3 has not shown to be significantly different in the same benchmarks.

You can also access this page and the entire serverkit.org site through shttp right now, click here for shttp on port 8080.


Usage

It is advised that you read the ServerKit documentation before trying to use this module, as most of the basic usage is simply using ServerKit, nothing specific to this module.

Due to the simple nature of this module it does not include a personality template and it is not expected that you would use it under daemontools.

Instead, the module sources include a simple startup script to run it "in-tree" without installing it in the system. There is still a c11n file included which gets used "in-tree" as well. See below for the configuration options.


Configuration

The following configuration options are supported:
NameTypeDescription
min_sessions integer Minimum number of sessions to allocate.
max_sessions integer Maximum number of sessions to allocate.
min_threads integer Minimum number of worker threads to create.
max_threads integer Maximum number of worker threads to create.
backlog integer Size of kernel-level connection backlog, passed to listen() as-is.
address string Internet address to listen on; as of 0.0.10 specifying an absolute filesystem path here causes shttp to bind to the specified path with a UNIX domain socket for accepting socket descriptors passed from httpx instead and port will be ignored.
port string Port to bind to
doc_root string The path to use as the "Document root" for files to serve via HTTP
default_index string The filename to open when a URI resolves to a directory
mime_types string Path to the mime types file to use (/etc/mime.types from mime-support package usually)
enable_user_dirs boolean Toggles wether http://foo/~unix_user maps to the ~/${unix_user}/${user_dir}/ directory. A similar feature is provided in Apache by mod_userdir
user_dir string Specifies the directory name to use within user home directories when servicing a user dir (http://foo/~unix_user) request. A common setting here is "public_html"
enable_user_dirs must be true for this to apply.
server_name string Domain name of the server. Used for composing redirects if there is no Host: header in the request.
auto_index boolean Toggles wether shttp should auto-generate "directory indexes" when the URI maps to a directory and there is no default_index file found.

You can query the module for its supported configuration options by simply running it like a normal executable program. This is the preferred method of keeping informed on what configuration values are supported and what the defaults are.

Here is some sample output of running the module:
swivel@volatile:~/src/shttp-0.0.3$ ./shttp.so
ServerKit bundled module inspector

- Summary -
Name: shttp
Description: A smart www service module
Version: 0.0.3
Authors: Yingyuan.Cheng <yingyuan@st**NOSPAM**>, Vito Caputo <vcaputo@p**NOSPAM**>

- Supported configuration options & defaults -
min_sessions = 128
max_sessions = 32768
max_threads = 4000
min_threads = 100
backlog = 32
port = 8080
# address = ""
# doc_root = ""
# default_index = ""
# mime_types = ""
enable_user_dirs = false
# user_dir = ""
swivel@volatile:~/src/shttp-0.0.3$ 
    


Source archives

Release date Tar.gz MD5 checksum
10-13-2008 shttp-0.0.11.tar.gz c07809f90daccd37fa7d268407e7ad7d
09-21-2008 shttp-0.0.10.tar.gz 0428a1ea9f7596c127d0778a7309bd23
08-17-2008 shttp-0.0.9.tar.gz 78b73770cc6acff3bbada7d36ffdd8f2
12-04-2007 shttp-0.0.8.tar.gz df8004a5a9011df207258a63031c71f4
11-29-2007 shttp-0.0.7.tar.gz 60f471f3b1068547aa287c0b4fc302e6

License

Shttp is released under the GPLv2.

Contribute

I accept patches or feature requests, simply email me at the email address contained within the ServerKit source tree.

© 2008 Vito Caputo