External Application
LiteSpeed server can forward requests to external applications to process and generate dynamic content.
Since 2.0, LiteSpeed server supports seven types of external applications: CGI, FastCGI, Web Server, Servlet Engine, LSAPI Application, Load Balancer and Piped Logger.
  • CGI stands for Common Gateway Interface and the current standard is CGI/1.1. CGI applications run in standalone processes. A CGI process is started for each request and will exit after finishing the request.

  • FastCGI is a fast, open, and secure web server interface that solves the performance problems inherent from CGI without introducing the overhead and complexity of proprietary APIs (Application Programming Interfaces). For more information, please visit http://www.fastcgi.com
    LiteSpeed web server defines two types of FastCGI applications: Local FastCGI and remote FastCGI. There is no real difference between them except how they are started. Local FastCGI refers to a FastCGI application that is started automatically by the web server on demand. Remote FastCGI refers to a FastCGI application that is not started by the web server and it can run either on a remote machine or on the same machine. In addition to generating dynamic response (RESPONDER role), a FastCGI application can be used for authentication (AUTHORIZER role) as well.

  • Web Server is a server application that supports HTTP 1.0/1.1 protocols. LiteSpeed web server can serve as a transparent reverse proxy to accelerate and protect any web server and application server. When communicating with backend web servers, LiteSpeed will always try to utilize "persistent connection" in order to achieve highest performance.

  • Servlet Engine is an application that implements Java Servlet and Java Server Pages, like Apache Tomcat and Jetty. LiteSpeed can communicate with Servlet engine through AJPv1.3 (Apache JServ Protocol version 1.3). Servlet engine can only be started outside of LiteSpeed and can be setup to run on a remote machine.

  • LSAPI (LiteSpeed Server API) Application is an application that communicates with LiteSpeed Web Server through LSAPI, which is a fast, scalable server interface specfically designed for LiteSpeed Web Server to achieve maximum efficiency.
    LSAPI has similar mechanism to FastCGI but LSAPI application can be up to 15% faster than a comparable FastCGI application. For the most demanding web applicatin, LSAPI is highly recommended over FastCGI.
    Our tests show that LSAPI PHP, using LiteSpeed SAPI, is up to 30% faster than FastCGI PHP. For more information about LSAPI and PHP Litespeed SAPI please visit http://www.litespeedtech.com/lsapi/.

  • Load balancer is a virtual external application, which only assigns requests to backend worker applications based on work load. Worker applications can be CGI, FastCGI, web server, Servlet engine and LSAPI applications. Different types of applications can be mixed together under one load balancer. Load balancer and Piped Loger cannot be used as worker applications.

  • Piped Logger is an application that can process access log in real-time, for examples, writing access log into database, performing real-time statistics calculation, etc.

Unlike CGI application, FastCGI, LSAPI application and Servlet Engine do not exit after processing a request: the process will stay/persist and serve as many requests as it can. The socket connection can be reused for multiple requests as well.

There are two ways to use external applications in LiteSpeed web server:
  1. As a handler of a specific context;
  2. As a handler of a script language via file suffix binding.

FastCGI application, LSAPI application, web server, Servlet Engine and Load Balancer have to be defined in External Application section before being used in script handler or context configuration. However, it is not necessary to define CGI application here.
External Applications can be configured at server level or at virtual host level. When configured at server level, it can be used by all virtual hosts; when configured at virtual host level, it can only be used by that virtual host.
 
Table of Contents
External App Settings Type   Name   Address   Max Connections   Environment   Initial Request Timeout   Retry Timeout   Persistent Connection   Keep Alive Timeout   Response Buffering   Auto Start   Max Idle Time   Command   Back Log   Instances   Run On Start Up   Priority   Memory Soft Limit   Memory Hard Limit   Process Soft Limit   Process Hard Limit   
 
TypeGo to top
Description: Specifies the type of external application. Choose from
  • FastCGI: a FastCGI application with Responder role.
  • FastCGI Authorizer: a FastCGI application with Authorizer role
  • Servlet Engine: a Servlet engine with AJPv13 connector, such as tomcat.
  • Web Server: a web server or application server that support HTTP protocol.
  • LSAPI App: an application that communicate with web server in LSAPI protocol.
  • Load Balancer: a virtual application that can balance load among worker applications.
  • Piped Logger: an application that can process access log entries received on its STDIN stream.
Syntax: Select from drop down list
NameGo to top
Description: A unique name for an external application. You will refer it by this name when you use it in other parts of the configuration.
AddressGo to top
Description: A unique socket address used by the external application. IPv4 socket and Unix Domain Socket (UDS) are supported. IPv4 socket can be used for communication over the network, but UDS can only be used when the external application residing on the same machine.
Syntax: IPv4Addr:port or UDS://path
Example: 127.0.0.1:5434, UDS://tmp/lshttpd/php.sock.
Tips: [Security] If the external application runs on the same machine, UDS is preferred. If you have to use IPv4 socket, set the IP part to localhost or 127.0.0.1, thus the external application is inaccessible from other machines.
[Performance] Unix Domain Socket generally provides higher performance than an IPv4 socket.
Max ConnectionsGo to top
Description: Specifies the maximum concurrent connections that can be established between the web server and an external application. This setting controls how many requests can be processed concurrently by an external application. However, the real limit also depends on the external application itself. Set this value higher will not help if the external application is not fast enough or cannot scale to large number of concurrent requests.
Syntax: Integer number
Tips: [Performance] Setting a high value does not directly translate to higher performance. Set the limit to a value that will not overload the the external application will provide the best performance/throughput.
EnvironmentGo to top
Description: Specifies some extra environment variables for the external application.
Syntax: key=value multiple variables can be separated by "ENTER"
Initial Request TimeoutGo to top
Description: Specifies the maximum time the web server waits for the external application to respond to the first request over a new established connection. If the web server does not receive any data from the external application within this timeout limit, it will mark this connection as bad. This helps to identify communication problem with external application as quickly as possible. If some requests take longer time to process, increase this limit to avoid "503" error messages.
Syntax: Integer number
Retry TimeoutGo to top
Description: Specifies the period of time that the web server waits before retrying the external application that had prior communication problem.
Syntax: Integer number
Persistent ConnectionGo to top
Description: Specifies whether to keep the connection open after a request has been processed. Persistent connection can increase performance but some FastCGI external applications does not support persistent connection fully. In order to run Ruby On Rails via a FastCGI interface, persistent connection needs to be turned off. Default is on. Currently, this option is only effective for a FastCGI external application.
Syntax: Select from radio box
Keep Alive TimeoutGo to top
Description: Specifies the maximum time to keep an idle persistent connection open. When set to -1, the connection never timeout. When set to >=0, the connection will be closed after the timeout has been reached.
Syntax: int
Response BufferingGo to top
Description: Specifies whether to buffer response received from external applications. If Apache's Non-Parsed-Header mode is available enabled, buffering is turned off for response with full HTTP headers.
Syntax: Select from drop down list
Auto StartGo to top
Description: Specifies whether you want the web server to start the application automatically. Only local FastCGI and LSAPI application running on the same machine can be started automatically. The IP in the Address must be a local IP.
Syntax: Select from radio box
Max Idle TimeGo to top
Description: Specifies the maximum idle time before an external application is stopped by the server. When set to -1, the external application will not be stopped by the server. Default value is -1. This feature allows resources used by idle applications to be freed. It is especially useful in mass hosting environment when you need to define many applications running in setuid mode for the sake of maximum security.
Syntax: Select from radio box
CommandGo to top
Description: Specifies the full command line including parameters to execute the external application. Required value if Auto Start is enabled. A parameter should be quoted with a double or single quote if the parameter contains space or tab characters.
Syntax: Full path to the executable with optional parameters.
Back LogGo to top
Description: Specifies the backlog of the listening socket. Required if Auto Start is enabled.
Syntax: Integer number
InstancesGo to top
Description: Specifies the maximum instances of the external application the server will create. It is required if Auto Start is enabled. Most FastCGI/LSAPI applications can only process one request per process instance and for those type of applications, instances should be set to match the value of Max Connections. Some FastCGI/LSAPI applications can spawn multiple child processes to handle multiple requests concurrently and for these type of applications, instances should be set to '1' and let the application spawn Max Connections number of children processes.
Syntax: Integer number
Run On Start UpGo to top
Description: Specifies whether to start the external application at server start up. Only applicable to external applications that can manage its own child processes and where 'Instances' value is set to '1'. If enabled, external processes will be created at server startup instead of run-time.
Syntax: Select from radio box
Tips: [Performance] If configured external process has significant startup overhead, such as Rail apps, then this option should be enabled to decrease first-page response time.
PriorityGo to top
Description: Specifies priority of the external application process. Value ranges from -20 to 20, lower number means higher priority. This priority cannot be set higher (lower number) than server's own. Otherwise, server's priority will be used and this value is disregarded.
Syntax: int
See Also: Server Priority
Memory Soft LimitGo to top
Description: Specifies memory consumption limit in bytes for an external application process or an external application started by server. The main purpose of this limit is to prevent excessive memory usage because of software bug or intention attacks, not to impose a limit on normal usage, make sure to leave enough head room, otherwise your application will fail and 503 error may be returned. It can be set at server level or at individual external application level. Server level limit will be used if it is not set at individual application level. Operating system's default will be used if the value is set to 0 or absent at both levels.
Syntax: Integer number
Tips: [Attention] Do not over tune this limit, it may result in 503 errors if your application need more memory.
Memory Hard LimitGo to top
Description: same as Memory Soft Limit, "Soft Limit" can be raised up to the "Hard Limit" from within a user process. It can be set at server level or at individual external application level. Server level limit will be used if it is not set at individual application level. Operating system's default will be used if the value is set to 0 or absent at both levels.
Syntax: Integer number
Process Soft LimitGo to top
Description: Limits the total number of processes can be created on behalf of a user. This effectively limits the number of processes can be launched by web server on behalf of a user. All existing processes will be counted against this limit, not just new process to be started. If the limit is set to 10, and there are more than 10 processes running under one user, then no new process can be started by web server for that user (suEXEC).
The main purpose of this limit is to prevent "fork bomb" attacks or excessive usage, not to impose a limit on normal usage, make sure to leave enough head room. It can be set at server level or at individual external application level. Server level limit will be used if it is not set at individual application level. Operating system's default value will be used if this value is 0 or absent at both levels.
Syntax: Integer number
Process Hard LimitGo to top
Description: Same as Process Soft Limit, "Soft Limit" can be raised up to the "Hard Limit" from within a user process. It can be set at server level or at individual external application level. Server level limit will be used if it is not set at individual application level. Operating system's default value will be used if the value is set to 0 or absent at both levels.
Syntax: Integer number