External Application

LiteSpeed web server can forward requests to external applications to process and generate dynamic content. Since 2.0, LiteSpeed Web Server has supported seven types of external applications: CGI, FastCGI, web server, servlet engine, LiteSpeed SAPI application, load balancer, and piped logger.

  • CGI stands for Common Gateway Interface. 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 in CGI without introducing the overhead and complexity of proprietary APIs (Application Programming Interfaces). For more information, please visit {ext-href}http://www.fastcgi.com{ext-href-end}http://www.fastcgi.com{ext-href-end-a}. On LiteSpeed Web Server, FastCGI applications can take two roles: generating dynamic responses (a responder role) or authorizing requests (an authorizer role). LiteSpeed Web Server further defines two types of FastCGI applications: local FastCGI and remote FastCGI. Local FastCGI applications are started automatically by the web server on demand. Remote FastCGI applications are not started by the web server. (They can run on a remote machine or on the same machine.)
  • a 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 web servers and application servers. When communicating with backend web servers, LiteSpeed will always try to utilize persistent connections in order to achieve the highest performance.
  • A servlet engine is an application, like Apache Tomcat and Jetty, that implements Java servlets and Java Server Pages. LiteSpeed can communicate with servlet engines through AJPv1.3 (Apache JServ Protocol version 1.3). Servlet engine cannot be started by the web server and can be setup to run on a remote machine.
  • A LiteSpeed SAPI (LiteSpeed Server Application Programming Interface) application is an application that communicates with LiteSpeed Web Server through LSAPI, a fast, scalable server interface specifically designed for LiteSpeed Web Server to achieve maximum efficiency. LSAPI's mechanism of action are similar to FastCGI, but LSAPI applications can be up to 30% faster than comparable FastCGI applications. LSAPI is highly recommended over FastCGI for supported applications. (LSAPI currently supports applications written in PHP, Ruby, and Python.) For more information about LSAPI, please visit {ext-href}http://www.litespeedtech.com/products/litespeed-sapi/overview/{ext-href-end}http://www.litespeedtech.com/products/litespeed-sapi/overview/{ext-href-end-a}.
  • A load balancer is a virtual external application, which assigns requests to backend worker applications based on workload. Worker applications can be CGI, FastCGI, web server, servlet engine, or LSAPI applications. Different types of applications can be mixed together under one load balancer. Load balancers and piped loggers cannot be used as worker applications.
  • A piped logger is an application that can process access logs in real-time, writing an access log into database or performing real-time statistics calculations, for example.
Unlike CGI applications, FastCGI applications, LSAPI applications, and servlet engine do not exit after processing a request. The application process will stay/persist and serve as many requests as it can. The socket connection can be reused for multiple requests as well. External applications can be set up in the {PAGE=ExtApp_Help} section. External applications cannot, however, function on their own. Additional settings must be configured so that the web server knows which requests to send to which application. There are two ways to to configure this in LiteSpeed Web Server:
  1. Set the external application as a handler for a specific context.
  2. Set the external application as a handler of a script language via file suffix binding.
FastCGI applications, LSAPI applications, web servers, servlet engines, and load balancers have to be defined in the {PAGE=ExtApp_Help} section before you can configure them to handle a context or script suffix . It is not necessary to define CGI applications in the {PAGE=ExtApp_Help} section. External applications can be configured at the server level or at the virtual host level. When configured at the server level, the application can be used by all virtual hosts. When configured at the virtual host level, it can only be used by that virtual host.

Table of Contents

External Application 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 | suEXEC User | suEXEC Group | 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. Application types are differentiated by the service they provide or the protocol they use to communicate with the server. Choose from
  • FastCGI: a FastCGI application with a Responder role.
  • FastCGI Authorizer: a FastCGI application with an Authorizer role
  • Servlet Engine: a servlet engine with an AJPv13 connector, such as Tomcat.
  • Web Server: a web server or application server that supports HTTP protocol.
  • LiteSpeed SAPI App: an application that communicates with the web server using 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
Tips: Most applications will use either LSAPI or FastCGI protocol. LSAPI supports PHP, Ruby, and Python. Perl can be used with FastCGI. (PHP, Ruby, and Python can also be set up to run using FastCGI, but they run faster using LSAPI.) Java uses servlet engines.
NameGo to top
Description: A unique name for this external application. You will refer to 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 sockets and Unix Domain Sockets (UDS) are supported. IPv4 sockets can be used for communication over the network. UDS can only be used when the external application resides on the same machine as the server.
Syntax: IPv4 or IPV6 address: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 an IPv4|IPV6 socket, set the IP address to localhost or 127.0.0.1, so the external application is inaccessible from other machines.
[Performance] Unix Domain Sockets generally provide higher performance than IPv4 sockets.
Max ConnectionsGo to top
Description: Specifies the maximum number of 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. Setting this value higher will not help if the external application is not fast enough or cannot scale to a large number of concurrent requests.
Syntax: Integer number
Tips: [Performance] Setting a high value does not directly translate to higher performance. Setting the limit to a value that will not overload the external application will provide the best performance/throughput.
EnvironmentGo to top
Description: Specifies 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 in seconds the web server will wait 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 problems with external applications as quickly as possible. If some requests take longer 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 an external application that had a 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 connections can increase performance, but some FastCGI external applications do not support persistent connections fully. The default is "On".
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 will never timeout. When set to greater than or equal to 0, the connection will be closed after this time in seconds has passed.
Syntax: int
Response BufferingGo to top
Description: Specifies whether to buffer response received from external applications. If a "nph-" (Non-Parsed-Header) script is detected, buffering is turned off for responses 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 FastCGI and LSAPI applications running on the same machine can be started automatically. The IP in the Address must be a local IP. Starting through the LiteSpeed CGI Daemon instead of a main server process will help reduce system overhead.
Syntax: Select from drop down list
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. The default value is "-1". This feature allows resources used by idle applications to be freed. It is especially useful in the 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
Tips: [Performance] This feature is especially useful in the mass hosting environment. In order to prevent files owned by one virtual host from being accessed by the external application scripts of another virtual host, mass hosting often requires many different applications running at the same time in SetUID mode. Set this Max Idle Time low to prevent these external applications from idling unnecessarily.
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.
See Also: Auto Start
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 types 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. For these types of applications, instances should be set to "1" and environment variables used to control how many child processes the application can spawn.
Syntax: Integer number
suEXEC UserGo to top
Description: Specifies user name that the external application will run as. If not set, the external application will run as the user of the web server.
Syntax: Valid user name.
See Also: extGroup
suEXEC GroupGo to top
Description: Specifies group name that the external application will run as.
Syntax: Valid group name.
See Also: extUser
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 their 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 the configured external process has significant startup overhead, like a Rails app, 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. A lower number means a higher priority. An external application process cannot have a higher priority than the web server. If this priority is set to a lower number than the server's, the server's priority will be used for this value.
Syntax: int
See Also: Server Priority
Memory Soft LimitGo to top
Description: Specifies the memory consumption limit in bytes for an external application process or an external application started by the server.

The main purpose of this limit is to prevent excessive memory usage because of software bugs or intentional attacks, not to impose a limit on normal usage. Make sure to leave enough head room, otherwise your application may fail and 503 error may be returned. It can be set at the server- level or at an individual external application level. The server-level limit will be used if it is not set at the individual application level.

The operating system's default setting will be used if the value is absent at both levels or set to 0.
Syntax: Integer number
Tips: [Attention] Do not over adjust this limit. This may result in 503 errors if your application needs more memory.
Memory Hard LimitGo to top
Description: Much the same as Memory Soft Limit, except the soft limit can be raised up to the hard limit from within a user process. The hard limit can be set at server level or at an individual external application level. The server-level limit will be used if it is not set at an individual application level.

The operating system's default will be used if the value is absent at both levels or set to 0.
Syntax: Integer number
Example: [Attention] Do not over adjust this limit. This may result in 503 errors if your application need more memory.
Process Soft LimitGo to top
Description: Limits the total number of processes that can be created on behalf of a user. All existing processes will be counted against this limit, not just new processes 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 the web server for that user (through 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. This can be set at the server level or at an individual external application level. The server-level limit will be used if it is not set at an individual application level. The operating system's default setting will be used if this value is 0 or absent at both levels.
Syntax: Integer number
Example: [Attention] All processes run under the same user ID at server level will be counted against this limit. Do not over adjust this limit. Doing so may cause 503 errors if a user needs to create many processes.
Process Hard LimitGo to top
Description: Much the same as Process Soft Limit, except the soft limit can be raised up to the hard limit from within a user process. The hard limit can be set at the server level or at an individual external application level. The server-level limit will be used if it is not set at an individual application level. The operating system's default value will be used if the value is absent at both levels or set to 0.
Syntax: Integer number

STAY CONNECTED