Embedded lightweight WebServer ---- lighttpd, thttpd, shttpd Mongoose introduction

1. Instructions from others
https://blog.csdn.net/21aspnet/article/details/6707199

Introduction to three lightweight WebServers--lighttpd, thttpd, shttpd

The vast majority of domestic web servers are either IIS or Apache. In terms of market share, I think Apache is a big winner, at least half of the country.

But in addition to IIS/Apache, we actually have many options. For high-load/large-concurrent websites, a high-performance, lightweight web server is a good medicine. Recently, the load of the server on hand was too high, and the swap was eaten up, causing the machine to be very slow. Later, after checking, it turned out that Apache was consuming almost all resources. At that time, there were 9XX apache processes.

So replace apache with a lightweight web server and enter the schedule. Here is an introduction to these optional objects by the way:

lighttpd | thttpd | shttpd

lighttpd

Official homepage: www.lighttpd.net

Lighttpd is a German-led open source software. Its fundamental purpose is to provide a secure, fast, compatible and flexible web server environment for high-performance websites. It has very low memory overhead, low cpu occupancy rate, good performance, and abundant modules.

lighttpd is an excellent one among many OpenSource lightweight web servers. It supports FastCGI, CGI, Auth, output compression (output compress), URL rewriting, Alias ​​and other important functions. The reason why Apache is popular is largely because of its rich functions. Many functions have been implemented on lighttpd. Point is very important for apache users, because migrating to lighttpd must face these problems.

I searched it on Google, and there are almost no articles about lighttpd in simplified Chinese, most of which are Big5 content from Taiwan compatriots. So in the next time, I want to write an article introducing lighttpd and a simple benchmark.

In practical terms, lighttpd is indeed very good. The apache overload problem mentioned above can be completely solved with lighttpd. The main problem of apache is intensive concurrency, constant fork() and switching, and high (relative to lighttpd) memory usage, which makes the system resources almost exhausted. And lighttpd uses Multiplex technology, the code is optimized, the size is very small, the resource usage is very low, and the response speed is quite fast.

Using Apache's rewrite technology, the heavy cgi/fastcgi tasks were handed over to lighttpd to complete, taking full advantage of the advantages of both, now the load of that server has dropped by an order of magnitude, and the response speed has increased by one or even two orders of magnitude!

thttpd

Official website: http://www.acme.com/software/thttpd/

thttpd is a very small and lightweight web server. It is very, very simple. It only provides HTTP/1.1 and simple CGI support. There is a comparison chart with other web servers (such as Apache, Zeus, etc.) on its official website. +Benchmark, you can refer to it. In addition, thttpd is also similar to lighttpd. For concurrent requests, fork() is not used to derive sub-processes, but multiplex technology is used to implement it. So the performance is very good.

Thttpd supports multiple platforms, such as FreeBSD, SunOS, Solaris, BSD, Linux, OSF, etc. For small web servers, fast speed seems to be synonymous. Through the Benchmark provided by the official website, it can be considered that thttpd is at least as fast as mainstream web servers and faster under high load because of its small resource footprint.

Thttpd also has a more eye-catching feature: URL-based file flow restriction, which is very convenient for download flow control. Like Apache, it must be implemented using plug-ins, which is less efficient than thttpd.

shttpd

Official website: http://sourceforge.net/projects/shttpd/

Shttpd is another lightweight web server with richer features than thttpd, supports CGI, SSL, cookie, MD5 authentication, and can be embedded into existing software. The most interesting thing is that no configuration files are required! Since shttpd can be embedded in other software, it is very easy to develop the web server of the embedded system. The official website says that if shttpd uses uclibc/dielibc (a simplified subset of libc), the overhead will be very, very low. The following are its characteristics:

Stand-alone server, or embeddable into existing C/C++ program
GET, POST, PUT, DELETE methods
CGI
SSL
Digest (MD5) authorization
Multiple (and user defineable) index files
Directory listing
Standard logging
Cookies
inetd mode
User-defineable mime types
No configuration files
No external dependencies

Since shttpd can be easily embedded in other programs, shttpd is an ideal prototype for web server development, and developers can develop their own webserver based on shttpd!

One of the projects uses ACU
Mongoose Web Server, which is an easy-to-use web server that can be embedded in other applications to provide a web interface for it.

Main features:

Cross-platform, supports Windows, OS X and Linux

Support CGI, SSL, SSI, Digest (MD5) authentication, WebSocket and WebDAV

Support resumable upload and URL rewriting

IP-based ACL, support Windows service, support GET, POST, HEAD, PUT, DELETE methods

Excluding files from serving by URI pattern

Download speed limit, based on client subnet and URI pattern

Small size, the executable file is only about 40k

It can be embedded and provides a simple API (mongoose.h). Only one source file mongoose.c is required

Embedded examples: hello.c, post.c, upload.c, websocket.c

Provide Python and C# versions

Adopt MIT license agreement

Guess you like

Origin blog.csdn.net/wowocpp/article/details/115301841