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:
Configure ZDS Settings
Test ZDS
ZDS functions in two modes:
Manual Mode - Calling the API function zend_send_file() from PHP scripts.
Transparent Mode - mapping file extensions to zend_mime_types.ini
Either mode can be run separately or in conjunction. Read on to find out how to configure the ZDS to run in either 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.
|
|
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]).
|
|
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]).
|
|
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.
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:
The file extensions appear in the zend_mime_types.ini file and the file is mapped to the correct mime type.
For example: to serve .mpeg files via the ZDS, add the following line in zend_mime_types.ini:
video/mpeg mpeg
In your Apache Server’s configuration file, map the file type to PHP.
For example, to map all .mpeg files to the ZDS in Apache by adding the following line to the Apache Server’s configuration:
AddType application/x-httpd-php .mpeg
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.
Zend Download Server Settings
The settings screen contains the general ZDS configuration settings:
Download Server Enabled - Indicates if the Download Server extension is running (Activating the Download Server here applies the changes to the Extensions list in Configuration | PHP Configuration.
Minimum File Size - The minimum size of files that will be served by the ZDS. Small files need not be served by the ZDS, since performance gain is insignificant. Default: 64Kbytes.
Server MaxClients - The testing tool (in Platform Administration) uses this value to determine your server’s MaxClients. Keep this value updated to the actual number of max clients of your server.
Log File - The name and location of the log file where the ZDS reports completed downloads. Default: <install_dir>/logs. Make sure the directory exists and that the user who starts the Web server (usually root) has "write" permissions.
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: |
|
|
|