/
README.html
219 lines (172 loc) · 13.6 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<h1>ULib - C++ library</h1>
<p>ULib is a highly optimized class framework for writing C++ applications. I wrote this framework as my tool for writing applications in various contexts. It is a result of many years of work as C++ programmer. I think, in my opinion, that its strongest points are simplicity, efficiency and sophisticate debugging. This framework offers a class foundation that disables language features that consume memory or introduce runtime overhead, such as rtti and exception handling, and assumes one will mostly be linking applications with other pure C based libraries rather than using the overhead of the standard C++ library and other similar class frameworks. It include as application example a powerful search engine with relative web interface and a multi purpose server (plugin oriented) which results, out of <a href="http://john.freml.in/ulib-fast-io-framework">John Fremlin accurate investigations</a>, to be one of the faster web application frameworks for serving small dynamic webpages (and also make easier the usage of shell scripts for CGI application)</p>
<h2>Quickstart</h2>
<p>Take a look at:</p>
<pre><code>$ ./configure --help
</code></pre>
<ul>
<li>......</li>
<li>--enable-zip enable build of ZIP support - require libz <code>[default: use if present libz]</code></li>
<li>--with-libz use system LIBZ library - [will check /usr /usr/local] <code>[default=use if present]</code></li>
<li>--with-libuuid use system libuuid library - [will check /usr /usr/local] <code>[default=use if present]</code></li>
<li>--with-magic use system libmagic library - [will check /usr /usr/local] <code>[default=use if present]</code></li>
<li>--with-ssl use system SSL library - [will check /usr /usr/local] <code>[default=use if present]</code></li>
<li>--with-pcre use system PCRE library - [will check /usr /usr/local] <code>[default=use if present]</code></li>
<li>--with-expat use system EXPAT library - [will check /usr /usr/local] <code>[default=use if present]</code></li>
<li>--with-ssh use system SSH library - [will check /usr /usr/local]</li>
<li>--with-curl use system cURL library - [will check /usr /usr/local]</li>
<li>--with-ldap use system openLDAP library - [will check /usr /usr/local]</li>
<li>--with-mysql use system MySQL library - [will check /usr /usr/local]</li>
<li>--with-dbi use system DBI library - [will check /usr /usr/local]</li>
<li>--with-libevent use system libevent library - [will check /usr /usr/local]</li>
<li>--with-libxml2 use system libxml2 library - [will check /usr /usr/local]</li>
<li>--with-page-speed use google page-speed SDK - [will check /usr /usr/local]</li>
<li>--with-v8-javascript use V8 JavaScript Engine - [will check /usr /usr/local]</li>
</ul>
<p>if you desire wrapping of some system library installed.</p>
<h2>userver (<code>_tcp</code> | <code>_ssl</code> | <code>_ipc</code>) application server (<code>plugin oriented</code>)</h2>
<p>The current version offers the following features :</p>
<ul>
<li>HTTP/1.0 and 1.1 protocols supported.</li>
<li>Persistent connections for HTTP/1.1 and Keep-Alive support for HTTP/1.0.</li>
<li>Browser cache management (headers: If-Modified-Since/Last-modified).</li>
<li>Chunk-encoding transfers support.</li>
<li>HTTP multi-range request support.</li>
<li>Memory caching of document root for (small) static pages with smart deflate compression and CSS/JS reduction.</li>
<li>Support for automatic update of caching document root with inotify (on Linux).</li>
<li>Support for pipelining.</li>
<li>Support for virtual hosts (also with SSL).</li>
<li>Support for basic/digest authentication.</li>
<li>Support for directory listings via basic/digest authentication.</li>
<li>Support for uri protection.</li>
<li>Support for aliases/redirection.</li>
<li>Support for to switch the site to a maintenance page only.</li>
<li>Support for overriden of error messages by local document (ErrorDocument/40x|500.html).</li>
<li>Support for RewriteRule (lighttpd-like) that check for file existence as they do on Apache,
some CMS (SilverStripe) require it.</li>
<li>Support for <a href="http://json.org/JSONRequest.html">JSONRequest</a>.</li>
<li>Accept HTTP uploads up to 4 GB without increasing memory usage.</li>
<li>Support for upload progress via USP (ULib Servlet Page).</li>
<li>General <a href="http://it.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> support (run any CGI script) with automatic output compression (using deflate method).</li>
<li>CGI support for shell script processes (with automatic management of form and cookie).</li>
<li>CGI support for the X-Sendfile feature and also supports X-Accel-Redirect headers transparently.</li>
<li>Support for minify HTML CGI output with wrapping <a href="http://code.google.com/speed/page-speed/download.html#pagespeed-sdk">google page speed SDK</a>.</li>
<li>Support for running JavaScript code with wrapping <a href="http://code.google.com/apis/v8/intro.html">google V8 JavaScript Engine</a>.</li>
<li>Support for <a href="http://www.phpmotionwiz.com/what-is-pseudo-streaming">HTTP pseudo-streaming</a> for FLV video.</li>
<li>Support for <a href="https://developer.mozilla.org/en/Security/HTTP_Strict_Transport_Security">HTTP Strict Transport Security</a>.</li>
<li>Support for <a href="http://cleverlogic.net/articles/kochure">HTTP Session Hijacking mitigation</a>.</li>
<li><a href="http://bellard.org/tcc/">C Servlet Support</a> with libtcc (if available) as a backend for dynamic code generation (experimental).</li>
<li>Support for Windows (without preforking), precompiled binaries are available <a href="https://github.com/stefanocasazza/ULib/tree/master/win32">here</a>.</li>
<li>Requests cut in phases for modular architecture (apache-like).</li>
<li>Configuration file with dedicated section.</li>
<li>Built-in modules :
<ul>
<li><code>mod_echo</code> : echo features.</li>
<li><code>mod_rpc</code> : generic Remote Procedure Call.</li>
<li><code>mod_http</code> : core features, static file handler and dynamic page (ULib Servlet Page).</li>
<li><code>mod_ssi</code> : <a href="http://en.wikipedia.org/wiki/Server_Side_Include">Server Side Includes</a> support with enhanced #set, direct include and #exec servlet (C/ULib Servlet Page).</li>
<li><code>mod_nocat</code> : <a href="http://nocat.net/">captive portal</a> implementation.</li>
<li><code>mod_tsa</code> : server side <a href="http://www.opentsa.org">Time Stamp</a> support.</li>
<li><code>mod_soap</code> : generic <a href="http://java.sun.com/developer/technicalArticles/xml/webservices">SOAP</a> server services support.</li>
<li><code>mod_fcgi</code> : third-party applications support thru <a href="http://www.fastcgi.com/drupal">FastCGI</a> interface.</li>
<li><code>mod_scgi</code> : module that implements the client side of the <a href="http://www.mems-exchange.org/software/scgi">SCGI</a> protocol (experimental).</li>
<li><code>mod_shib</code> : <a href="http://shibboleth.internet2.edu">web single sign-on support</a> (experimental).</li>
<li><code>mod_proxy</code> : proxy support (experimental).</li>
<li><code>mod_geoip</code> : <a href="http://www.maxmind.com/geoip/api/c.shtml">geolocation support</a> (experimental).</li>
<li><code>mod_stream</code> : simple streaming support (experimental).</li>
<li><code>mod_socket</code> : <a href="http://dev.w3.org/html5/websockets">Web Socket</a> application framework (experimental).</li>
</ul></li>
</ul>
<h2>Benchmarking</h2>
<p>$ ./configure && make
$ cd tests/examples
$ ./benchmarking.sh (or hello_world.sh)</p>
<p>Use apachebench (ab)</p>
<pre><code>$ ab -n 100000 -c10 http://127.0.0.1/servlet/benchmarking?name=stefano (or)
$ ab -n 100000 -c10 http://127.0.0.1/servlet/hello_world
</code></pre>
<h2><a href="https://github.com/stefanocasazza/ULib/tree/master/doc/benchmark">Comparative Benchmarking</a></h2>
<p>I consider in this benchmark the performant server [G-WAN 2.8.21 (32 bit)] (http://www.gwan.ch/) and [NGINX 1.0.6 (stable)] (http://nginx.net/).</p>
<h2>gwan run with the follow options:</h2>
<pre><code>-b: enable the TCP_DEFER_ACCEPT option
-d: daemon mode (with an 'angel' process)
</code></pre>
<h2>nginx is configured in this way:</h2>
<pre><code>$ CFLAGS=-O3 &&
./configure --prefix=/usr/local --conf-path=/etc/local/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock
--http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body
--http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--with-ipv6 --without-http-cache --with-http_ssl_module --with-http_secure_link_module
--with-http_gzip_static_module --without-http_limit_zone_module --without-http_limit_req_module
--without-http_rewrite_module --without-http_charset_module --without-http_ssi_module
--without-http_userid_module --without-http_autoindex_module --without-http_geo_module
--without-http_map_module --without-http_split_clients_module --without-http_referer_module
--without-http_uwsgi_module --without-http_scgi_module --without-http_memcached_module
--without-http_empty_gif_module --without-http_browser_module --without-http_upstream_ip_hash_module
</code></pre>
<h2>nginx run with the follow configuration:</h2>
<pre><code>user apache;
worker_processes 2;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
error_log off;
access_log off;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
sendfile on;
keepalive_timeout 15;
gzip off;
server_tokens off;
tcp_nopush on;
tcp_nodelay on;
server {
listen 80;
server_name localhost;
access_log off;
location / {
root /usr/src/ULib-1.1.0/tests/examples/benchmark/docroot;
index index.html index.htm;
}
}
}
</code></pre>
<p>All tests are performed on an Intel Pentium 4 2.8 Ghz, Hard drive 5400 rpm, Memory: 2GB DDR2 800MHz running <code>Gentoo 64 bit (kernel 3.0.4)</code>.
Yes, this CPU is 11-year old (single-core) P4, but some test on more recent processor (dual-core AMD) give similar results.</p>
<p>For better comparison with gwan (32 bit) userver_tcp and nginx are compiled and run (as gwan) in chrooted environment: <code>Ubuntu 11.04 (iX86)</code></p>
<p>The client <a href="https://github.com/stefanocasazza/ULib/tree/master/doc/benchmark/bin/bench1.c">bench1.c</a>
relies on ApacheBench (ab) and it is a slightly modified version of <a href="http://gwan.ch/source/ab.c.txt">G-WAN client</a>.</p>
<p>I have considered two scenario for benchmarking:</p>
<p>The client as well as the web server tested are hosted on the same computer.
The client is running on different computer than the web server (networking is involved).</p>
<p>I had to increase the local port range on client (because of the TIME_WAIT status of the TCP ports).</p>
<ul>
<li>HTTP Keep-Alives: yes/no</li>
<li>Concurrency: from 0 to 1000, step 10</li>
<li>Requests: up to 1000000 - within a fixed total amount of time (1 sec)</li>
</ul>
<p>For serving static content I use 3 file of different size:</p>
<ul>
<li>100.html ( 100 byte) (only 'XXX...' without CR/LF)</li>
<li>1000.html (1000 byte) (only 'XXX...' without CR/LF)</li>
<li>WebSocketMain.swf (80K byte)</li>
</ul>
<p>For serving dynamic content I use a simple request: <code>Hello {name}</code></p>
<h2>userver_tcp is the winner of this benchmark for almost all level of concurrency.</h2>
<p>The raw data in csv format are <a href="https://github.com/stefanocasazza/ULib/tree/master/doc/benchmark/current">here</a>.</p>
<p><img src="https://github.com/stefanocasazza/ULib/blob/master/doc/benchmark/img/AB/net_keep_alive.png?raw=true" alt="Networking-KeepAlive-498-x-499" title="" />
<img src="https://github.com/stefanocasazza/ULib/blob/master/doc/benchmark/img/AB/net_no_keep_alive.png?raw=true" alt="Networking-NoKeepAlive-498-x-499" title="" />
<img src="https://github.com/stefanocasazza/ULib/blob/master/doc/benchmark/img/AB/localhost_keep_alive.png?raw=true" alt="Localhost-KeepAlive-498-x-499" title="" />
<img src="https://github.com/stefanocasazza/ULib/blob/master/doc/benchmark/img/AB/localhost_no_keep_alive.png?raw=true" alt="Localhost-NoKeepAlive-498-x-499" title="" /></p>
<h2>More info</h2>
<p>ULib is normally built and installed as a set of shared object libraries and header files. These libraries and headers are installed using directories selected through a "configure" script that has been prepared with automake and autoconf. As such, they should build and install similarly to and in a manner compatible and consistent with most other GNU software. ULib is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
<p>Comments and suggestions are welcome.</p>
<pre><code>stefano casazza <stefano.casazza@gmail.com>
</code></pre>