Lightweight webserver kepler/thttpd/shttpd simple contrast __web

Source: Internet
Author: User
Tags lua

Recently need a simple webserver, a few do the following simple comparison:

The selection principle is as follows: Support CGI: Need to use Cgilua to occupy less CPU resources and best support cross-platform

1:kepler/xavante

Advantages: Cross-platform, support Windows,linux and other mainstream operating systems. Because it is written in Lua itself, the framework supports LUA very well.

Disadvantage: Each request is a new LUA virtual machine, if the same file more than one request, you will see if the previously cached virtual machine is valid, if it is valid still use the virtual machine.

Although there is a recycling mechanism (I also changed the code to force recycling), but the memory does not see a noticeable drop, so memory usage will be more and more until you have all the files are accessed.

2:shttpd

Advantages: Cross-platform, support Windows,linux and other mainstream operating systems. Less code (only 3 k lines) internal support Perl,python, expected next version support LUA

Disadvantages: After the installation of Linux operation, directly startled me, with a 10M of memory, no need to look carefully, just throw it away

3:thttpd

Advantages: Less code, less memory footprint

Disadvantage: can only run on the class Linux operating system as long as a similar http://ip/cgi-bin/cgi/xxxx call, are directly to the CGI processing of all files are read at once, while caching. System calls that are not highly privileged, such as invoking the following command, will not succeed (changed code, logged in as root, unsuccessful)

Os.execute ("reboot")

Would have been most inclined to use Kepler/xavante, but the memory is not recycled, had to discard, and shttpd in the trial when the direct abandonment, then have to use THTTPD, look at the code, the process of the CGI changed, the file cache, temporarily do not deal with cache , static pages are generally not large), but consider other ways to system calls.

The result of the last modification is that the total amount of memory consumed is less than 1 m unless the file is uploaded.

Because the Web page is written with Cgilua, so in Windows directly with Xavante do webserver, embedded Linux under the switch to THTTPD

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.