System Administration Guide: Resource Management and Network Services

Chapter 2 Managing Web Cache Servers

This chapter provides an overview of the Solaris Network Cache and Accelerator (NCA). Also, procedures for using NCA and reference material about NCA are included.

Network Cache and Accelerator (Overview)

The Solaris Network Cache and Accelerator (NCA) increases web server performance by maintaining an in-kernel cache of web pages that are accessed during HTTP requests. This in-kernel cache uses system memory to significantly increase performance for HTTP requests that are normally handled by web servers. Using system memory to hold web pages for HTTP requests increases web server performance by reducing the overhead between the kernel and the web server. NCA provides a sockets interface through which any web server can communicate with NCA with minimal modifications.

In situations where the requested page is retrieved from the in-kernel cache (cache hit), performance improves dramatically. In situations where the requested page in not in the cache (cache miss) and must be retrieved from the web server, performance is also significantly improved.

This product is intended to be run on a dedicated web server. If you run other large processes on a server that runs NCA, problems can result.

NCA provides logging support in that NCA logs all cache hits. This log is stored in binary format to increase performance. The ncab2clf command can be used to convert the log from binary format to common log format (CLF).

The Solaris 9 release includes the following enhancements:

Managing Web Cache Servers (Task Map)

The following table describes the procedures that are needed to use NCA.

Task 

Description 

For Instructions 

Planning for NCA 

A list of requirements to enable the use of NCA. Review before configuring NCA. 

"System Requirements for NCA"

Enabling NCA 

Steps to enable in-kernel caching of web pages on a web server. 

"How to Enable Caching of Web Pages"

Disabling NCA 

Steps to disable in-kernel caching of web pages on a web server. 

"How to Disable Caching of Web Pages"

Administering NCA logging 

Steps to enable or disable the NCA logging process. 

"How to Enable or Disable NCA Logging"

Loading the NCA socket library 

Steps to use NCA if the AF_NCA socket is not supported. 

"How to Load the NCA Socket Utility Library"

Administering the Caching of Web Pages (Tasks)

The following sections cover the system requirements that are needed to use NCA and the procedures to enable or disable parts of the service.

System Requirements for NCA

To support NCA, the system must meet these requirements:

This product is intended to be run on a dedicated web server. Running other large processes on a server that runs NCA can cause problems.

How to Enable Caching of Web Pages

  1. Become superuser.

  2. Register the interfaces.

    Type the names of each of the physical interfaces in the /etc/nca/nca.if file. See the nca.if(4) man page for more information.


    # cat /etc/nca/nca.if
    hme0
    hme1

    Each interface must have an accompanying hostname.interface-name file and an entry in /etc/hosts file for the contents of hostname.interface-name. To start the NCA feature on all interfaces, place an asterisk, *, in the nca.if file.

  3. Enable the ncakmod kernel module.

    Change the status entry in /etc/nca/ncakmod.conf to enabled.


    # cat /etc/nca/ncakmod.conf
    #
    # NCA Kernel Module Configuration File
    #
    status=enabled
    httpd_door_path=/var/run/nca_httpd_1.door
    nca_active=disabled

    See the ncakmod.conf(4) man page for more information.

  4. Enable NCA logging.

    Change the status entry in /etc/nca/ncalogd.conf to enabled.


    # cat /etc/nca/ncalogd.conf
    #
    # NCA Logging Configuration File
    #
    status=enabled
    logd_path_name="/var/nca/log"
    logd_file_size=1000000

    You can change the location of the log file by changing the path that is indicated by the logd_path_name entry. The log file can be a raw device or a file. See the following examples for samples of NCA log file paths. See the ncalogd.conf(4) man page for more information about the configuration file.

  5. For IA only: Increase the virtual memory size.

    Use the eeprom command to set the kernelbase of the system.


    # eeprom kernelbase=0x90000000
    # eeprom kernelbase
    kernelbase=0x90000000

    The second command verifies that the parameter has been set.


    Note -

    Setting the kernelbase reduces the amount of virtual memory that user processes can use to less than 3 Gbytes. This restriction means that the system is not ABI compliant. When the system boots, the console displays a message that warns you about noncompliance. Most programs do not actually need the full 3-Gbyte virtual address space. If you have a program that needs more than 3 Gbytes, you need to run the program on a system that does not have NCA enabled.


  6. Reboot the server.

Example-Using a Raw Device as the NCA Log File

The logd_path_name string in ncalogd.conf can define a raw device as the place to store the NCA log file. The advantage to using a raw device is that the service can run faster because the overhead in accessing a raw device is less.

The NCA service tests any raw device that is listed in the file to ensure that no file system is in place. This test ensures that no active file systems are accidentally written over.

To prevent this test from finding a file system, run the following command to destroy part of the file system on any disk partition that had been configured as a file system. In this example, /dev/rdsk/c0t0d0s7 is the raw device that has an old file system on it.


# dd if=/dev/zero of=/dev/rdsk/c0t0d0s7 bs=1024 count=1

After running dd, you can then add the raw device to the ncalogd.conf file


# cat /etc/nca/ncalogd.conf
#
# NCA Logging Configuration File
#
status=enabled
logd_path_name="/dev/rdsk/c0t0d0s7"
logd_file_size=1000000

Example-Using Multiple Files for NCA Logging

The logd_path_name string in ncalogd.conf can define multiple targets as the place to store the NCA log file. The second file is used when the first file is full. The following example shows how to select to write to the /var/nca/log file first and then use a raw partition.


# cat /etc/nca/ncalogd.conf
#
# NCA Logging Configuration File
#
status=enabled
logd_path_name="/var/nca/log /dev/rdsk/c0t0d0s7"
logd_file_size=1000000

How to Disable Caching of Web Pages

  1. Become superuser.

  2. Disable the ncakmod kernel module.

    Change the status entry in /etc/nca/ncakmod.conf to disabled.


    # cat /etc/nca/ncakmod.conf
    # NCA Kernel Module Configuration File
    #
    status=disabled
    httpd_door_path=/var/run/nca_httpd_1.door
    nca_active=disabled

    See the ncakmod.conf(4) man page for more information.

  3. Disable NCA logging.

    Change the status entry in /etc/nca/ncalogd.conf to disabled.


    # cat /etc/nca/ncalogd.conf
    #
    # NCA Logging Configuration File
    #
    status=disabled
    logd_path_name="/var/nca/log"
    logd_file_size=1000000

    See the ncalogd.conf(4) man page for more information.

  4. Reboot the server.

How to Enable or Disable NCA Logging

NCA logging can be turned on or off as needed after NCA has been enabled. See "How to Enable Caching of Web Pages" for more information.

  1. Become superuser.

  2. Change NCA logging.

    To permanently disable logging, you need to change the status in /etc/nca/ncalogd.conf to disabled and reboot the system. See the ncalogd.conf(4) man page for more information.

    1. Stop logging.


      # /etc/init.d/ncalogd stop
      
    2. Start logging.


      # /etc/init.d/ncalogd start
      

How to Load the NCA Socket Utility Library

Follow this process only if your web server does not provide native support of the AF_NCA socket.

Add a line to the web server startup script that causes the library to be preloaded. The line should resemble the following:


LD_PRELOAD=/usr/lib/ncad_addr.so /usr/bin/httpd

Caching Web Pages (Reference)

The following sections cover the files and components that are needed to use NCA. Also, specifics about how NCA interacts with the web server are included.

NCA Files

You need several files to support the NCA feature. Many of these files are ASCII, but some of them are binary. The following table lists all of the files.

Table 2-1 NCA Files

File Name 

Function 

/etc/hostname.*

File that lists all physical interfaces that are configured on the server. 

/etc/hosts

File that lists all host names that are associated with the server. Entries in this file must match entries in /etc/hostname.* files for NCA to function.

/etc/init.d/ncakmod

Script that starts the NCA server. This script is run when a server is booted. 

/etc/init.d/ncalogd

Script that starts NCA logging. This script is run when a server is booted. 

/etc/nca/nca.if

File that lists the interfaces on which NCA is run. See the nca.if(4) man page for more information.

/etc/nca/ncakmod.conf

File that lists configuration parameters for NCA. See the ncakmod.conf(4) man page for more information.

/etc/nca/ncalogd.conf

File that lists configuration parameters for NCA logging. See the ncalogd.conf(4) man page for more information.

/usr/bin/ncab2clf

Command that is used to convert data in the log file to the common log format. See the ncab2clf(1) man page for more information.

/usr/lib/net/ncaconfd

Command that is used to configure NCA to run on multiple interfaces during boot. See the ncaconfd(1M) man page for more information.

/usr/lib/nca_addr.so

Library that uses AF_NCA sockets instead of AF_INET sockets. This library must be used on web servers that use AF_INET sockets. See the ncad_addr(4) man page for more information.

/var/nca/log

File that holds the log file data. The file is in binary format, so do not edit it. 

NCA Architecture

The NCA feature includes the following components.

The kernel module ncakmod maintains the cache of web pages in system memory. The module communicates with a web server, httpd, through a sockets interface (family type PF_NCA).

The kernel module also provides a logging facility that logs all HTTP cache hits. NCA logging writes HTTP data to the disk in binary format. NCA provides a conversion utility for converting binary log files to common log format (CLF).

The following figure shows the flow of data for the conventional path and the path that is used when NCA is enabled.

Figure 2-1 Data Flow with the NCA Service

Flow diagram shows the flow of data from a client request through the NCA layer in the kernel.

NCA to Httpd Request Flow

The following list shows the request flow between the client and the web server.

  1. An HTTP request is made from the client to the web server.

  2. If the page is in cache, the in-kernel cache web page is returned.

  3. If the page is not in cache, the request goes to the web server to retrieve or update the page.

  4. Depending on the HTTP protocol semantics that are used in the response, the page is cached or not. Then, the page is returned to the client. If the Pragma: No-cache header is included in the HTTP request, the page is not cached.

Interpositioning Library for Door Server Daemon Support

Many web servers use AF_INET sockets. By default, NCA uses AF_NCA sockets. To correct this situation, an interpositioning library is provided. The new library is loaded in front of the standard socket library, libsocket.so. The library call bind() is interposed by the new library, ncad_addr.so. If the status is enabled in /etc/nca/ncakmod.conf, the version of Apache that is included with the Solaris 9 release is already set up to call this library. If you are using IWS or Netscape servers, see "How to Load the NCA Socket Utility Library" to use the new library.