Use KHTTPD in Linux to accelerate Web Services

Source: Internet
Author: User
Article Title: Use the kernel KHTTPD in Linux to accelerate Web Services. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

I. Introduction

From linux2.4.13, an EXPERIMENTAL option-'[] Kernel httpd acceleration (EXPERIMENTAL)' appeared in Networking options. What is kHTTPd? It is a web server in a Linux environment. The difference between kHTTPd and other web servers is that it runs in the Linux kernel as part of the kernel (which can be considered as a device driver ).

KHTTPd only processes static (based on static files) web pages, and transmits all requests for non-static content to normal web servers running in the user space for processing, such as apache and Zeus, and the web servers running in the user space do not need to be modified.

The processing of http requests on static web pages is not a very complicated process, but it is a very important part of web Services, because at least most of the websites are static, there are also many static html files. A conventional web server is very easy to process http requests for static pages. It is just a simple operation to copy 'files to network. If these operations are completed in the kernel, they will become very efficient. For example, NFS servers that have completed similar functions are also running in the kernel.

By accelerating web request processing in the kernel, web servers such as apache can focus on processing those dynamic web requests.

Note: Apache refers to any web server.

Ii. Quick Start

1) Compile and load the module.

2) If necessary, configure the module through/proc/sys/net/khttpd.

3) echo 1>/proc/sys/net/khttpd/start.

Uninstall:

       
            echo 1 > /proc/sys/net/khttpd/stop  echo 1 > /proc/sys/net/khttpd/unload   rmmod khttpd 
       
 

Iii. Configuration

1. Operation Mode

There are two recommended operation modes:

1) 'apache' is the master web server and kHTTPd is the auxiliary web server.

       
            clientport -> 80  serverport -> 8080 (or whatever) 
       
 

2) kHTTPd is the master web server and 'apache' is the auxiliary web server.

 

       
           clientport -> 8080 (or whatever)  serverport -> 80 
       

2. Configure kHTTPd

Before starting kHTTPd, you must configure it. This is done through the/proc file system, so you can implement automatic configuration in the script. Most parameters can only be set before kHTTPd is started.

You can configure the following parameters:

1) service request port listened by kHTTPd;

2) The 'apache' listening port (in the 'localhost' Interface );

3) web document root directory (documentroot );

4) The string (optional) contained in the request for dynamic content [including "cgi-bin"] by default.

The specified documentroot must be consistent with the documentroot of the web server running in the user space, because kHTTPd may redirect any requests to the web server of the user space for processing.

A typical script (the first operation mode ):

       
            #!/bin/sh  modprobe khttpd  echo 80 > /proc/sys/net/khttpd/clientport  echo 8080 > /proc/sys/net/khttpd/serverport  echo /var/www > /proc/sys/net/khttpd/documentroot  echo php3 > /proc/sys/net/khttpd/dynamic  echo shtml > /proc/sys/net/khttpd/dynamic  echo 1 > /proc/sys/net/khttpd/start
       
  

For the second operation mode, the typical script is as follows:

       
            #!/bin/sh  modprobe khttpd  echo 8080 > /proc/sys/net/khttpd/clientport  echo 80 > /proc/sys/net/khttpd/serverport  echo /var/www > /proc/sys/net/khttpd/documentroot  echo php3 > /proc/sys/net/khttpd/dynamic  echo shtml > /proc/sys/net/khttpd/dynamic  echo 1 > /proc/sys/net/khttpd/start
       
  

In this case, you must first modify the Apache configuration:

 

       
           Port 80 
       
 

Change

       
            Port 8080 
       
 

 

[1] [2] Next page

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.