Mirrors
From EIRMA Wiki
| Quick Links |
|---|
|
Overview and Tutorial |
|
Pre-Installation Installation Post-Installation |
|
Administration |
|
Moderation Design Advanced |
|
Other |
Contents |
LDM supports the use of mirror servers to balance file transfer load across several servers. For technical reasons explained below, this feature is better suited to handling file transfers as links rather than as managed downloads.
When users attempts to access entries that satisfy the criteria explained below, LDM checks each suitable server to see whether the url is currently available. If more than one server reports availability, she is given a choice of mirror to use, with the preferred mirror pre-selected. (If she is attempting to play a media file through the Jukebox or if only one site reports that it is available, then the fastest server is selected automatically.)
Normally, the list of available mirrors is sorted as follows:
- With effect from release 2.3.0, by priority, with the highest priority mirror first
- For mirrors of equal priority, by response time
This order may be modified, for example when the GeoIP extra is installed.
When the user is offered more than one choice, the form will include the current http response code. If the code indicates an error (i.e. not code 2xx), the user is not given the opportunity to use the mirror concerned.
Specifying Mirrors
Mirror sites are specified and activated/deactivated via LDM->Admin->Mirrors page. These parameters apply:
- Its name
- Whether it is considered to be active
- A url match: The (regular expression) string with which urls of entries to be mirrored will begin
- A replacement: The (regular expression) string to be substituted for the match
- From version 2.3.0, a priority value
Consider a site that runs three mirror servers, mirror1.site.com, mirror2.site.com and mirror3.site.com, as well as the main server at www.site.com. All four mirrors have equal priority. These would be specified as follows:
| Name | Active | Match | Replace | Priority |
|---|---|---|---|---|
| Base | Yes | http://www.site.com | http://www.site.com | 100 |
| Mirror1 | Yes | http://www.site.com | http://mirror1.site.com | 100 |
| Mirror2 | Yes | http://www.site.com | http://mirror2.site.com | 100 |
| Mirror3 | Yes | http://www.site.com | http://mirror3.site.com | 100 |
Note that the base server must be included as one of the mirrors, otherwise it will not be used.
As a second example, consider a site running two mirrors with slightly different directory structures, mirror1.site.com/filestore, and mirror2.site.com/files/downloads, plus the main server at www.site.com. These would be specified as follows:
| Name | Active | Match | Replace | Priority |
|---|---|---|---|---|
| Base | Yes | http://www.site.com | http://www.site.com | 100 |
| Mirror1 | Yes | http://www.site.com | http://mirror1.site.com/filestore | 100 |
| Mirror2 | Yes | http://www.site.com | http://mirror2.site.com/files/downloads | 100 |
Normally, you will not change the priority values from the default value of 100. The main purpose of this setting is to allow plug-in extras to modify the default choice of mirror, as with the example of geolocation described below.
Mirror Groups
Groups of mirrors can be established by giving different match strings. Be careful not to specify ambiguous match strings. For example, the definitions:
- http://www.site.com and
- http://www.site.com/file
are probably ambiguous, since http://www.site.com/file/file1.pdf will match both.
Mirroring Links and Downloads
There is a technical difficulty in using the mirror facility to handle LDM downloads, i.e. to transfer filetypes defined in the vBulletin attachments table when LDM->Admin->Settings force_redirect=0. LDM handles these downloads by sequentially reading the file and retransmitting it to the user, which means that mirrored downloads will always pass through the main server on their way to the user. Consequently, the expected performance gain will not be realised.
This difficulty can be overcome by setting force_redirect=1. While this reduces the level of security over file locations, it ensures that the mirroring process works correctly and without overhead for all filetypes.
Modifying the Recommended Mirror: Geolocation
From version 2.3.0, plugin extras can modify the recommended mirror and force the use of a particular mirror.
The GeoIP extra allows you to direct users to different mirrors according to their country. Full details are provided in the extra's readme.txt file.
The extra requires that you install either the free or commercial version of Maxmind's GeoIP country database, and define a map of country codes to mirrors. It looks up the user's IP address in the GeoIP database, then determines the preferred mirror from your country/mirror map, and adjusts the priority of this mirror to place it at the head of the list.
Regular Expression Matches
The match and replacement strings use Perl-style regular expressions, see a tutorial. The regex match is performed with the "i" (case insensitive) switch and is anchored to the start of the url.
