Configuring the Zend Download Server (ZDS)

Zend Download Server settings are accessed from ZDS | Overview.

 

(This feature is currently not applicable for Windows Operating Systems)

 

The ZDS (Zend Download Server) is a PHP (Zend Engine) plug-in. The purpose of this plug-in is to efficiently deal with serving large, downloads. This is done to preserve Website performance levels when handling large downloads that are served over the HTTP Protocol and consume bandwidth.

Downloads include, Video Files, Binary Products (such as .exe and .msi files), and other large files which are served over the HTTP protocol, and can potentially limit the performance of your Website.

The ZDS provides two options:

  1. Configure ZDS Settings

  2. Test ZDS

ZDS functions in two modes:  

Either mode can be run separately or in conjunction. Read on to find out how to configure the ZDS to run in either mode.

Manual Mode

In Manual mode, downloads are initiated by a PHP script that uses one all-purpose PHP function call. ZDS includes the PHP functions zend_send_file(filename[,mime_type][,custom_headers]) and zend_send_file(string buffer[, string mime_type][, string custom_headers]).

 

Calling zend_send_file() immediately starts the file download and terminates your PHP script's execution. This effectively frees up the Apache process to handle the next incoming request.

The zend_send_file() function can also serve files that are not under the Web server's document root. Furthermore, it can be used to run logical functions such as access restriction checks, before downloads are started. From an external point of view, the effect is similar to fpassthrou ($fh) and then exit.

 

zend_send_buffer is used when servicing large downloads created on-the-fly (such as PDF files, large images etc.). When using this function it is important to specify the mime_type. From an external point of view, the effect is similar to echo and then exit.

Usage Example

Example:

If a download function is called my_send_file($filename), you should integrate the zend_send_file() call in the following way in your source code:

if (function_exists("zend_send_file")) {

    zend_send_file($filename);

} else {

    my_send_file($filename);

}

 

Alternate Method

zend_send_file can also be set to accept a second argument, the mime type of the file. This will override the default mime type setting.

The parameters are: zend_send_file(string filename[, string mime_type]).

Usage Example

Example:

It would be called in the following way in your source code:

if (function_exists("zend_send_file")) {

    zend_send_file("/path/to/file.wma", "video/my-wma-type");

} else {

    my_send_file($filename);

}

 

zend_send_buffer

The parameters are bool zend_send_file(string buffer[, string mime_type][, string custom_headers]).

Usage Example

Example:

It would be called in the following way in your source code:

if (function_exists("zend_send_buffer")) {

    zend_send_buffer($my_picture_content,"image/giff");

} else {

    my_send_buffer($my_picture_content);

}

 

Note:

If the mime_type is not specified or empty, the first mime type mechanism is used.

Manual Mode Usability Notes:

Do not create any output in Manual mode, before calling zend_send_file() - neither headers nor body - as headers will not have any effect when sent by the ZDS (they will only take affect if sent outside the ZDS).
Once you call zend_send_file(), the script terminates, so make sure all of your business logic runs before you call this function.
Sometimes files that are not under the same document root need to be served. Therefore, It is recommended to use the full path name to the file you want to serve. This will guarantee your script will work, even if you move it from your Web server's document root.

Transparent Mode

In Transparent mode, the file types that should be downloaded via ZDS are pre-configured, by mapping these files in the configuration file of your Web server. Files greater than the min_file_size directive will be automatically served by the ZDS.

To run ZDS in Transparent mode, make sure you meet the following requirements:

Both methods (manual mode and transparent mode) ensure that the Web application will continue to work even if, for some reason, you decide to temporarily disable the ZDS, (as long as the ZDS module was loaded).

To Configure the ZDS:

Go to ZDS | Overview.

download_server_settings.png  

Zend Download Server Settings

The settings screen contains the general ZDS configuration settings:

Server MaxClients Recommendation:

The MaxClients setting depends on your server hardware. To achieve accurate test results the server should be set between 50-150 MaxClients. The MaxClients value must be the same in the Download Server Settings and the Web server’s configuration file.

These settings are applied to downloads handled in one of the two handling modes: Manual and Transparent.

 

 

Related Links

Related Links:
Settings

Testing

ZDS Functions

ZDS Directives