Content Delivery Network (CDN)
- Content Delivery Network (CDN) Configuration
This article details the configuration of a Content Delivery Network (CDN) for a MediaWiki 1.40 installation. A CDN significantly improves website performance and user experience by caching static content closer to users geographically. This guide assumes you have a functioning MediaWiki installation and administrative access. We will cover concepts, provider selection, configuration steps, and verification.
What is a CDN?
A Content Delivery Network (CDN) is a geographically distributed network of proxy servers and their data centers. The goal is to serve content to users with high availability and high performance. CDNs cache static assets like images, JavaScript, and CSS files. When a user requests this content, the CDN server closest to them delivers it, reducing latency and improving load times. Without a CDN, all requests would go directly to the origin server (your MediaWiki instance), potentially causing bottlenecks during peak traffic. This is especially important for wikis with a global audience. See Performance optimization for further details on related techniques.
CDN Provider Selection
Choosing the right CDN provider is crucial. Factors to consider include:
- Cost: Pricing models vary greatly.
- Global Coverage: Ensure the provider has points of presence (PoPs) near your target audience.
- Features: Look for features like SSL support, compression, and analytics.
- Integration: Ease of integration with MediaWiki is important.
- Support: Reliable customer support is vital for troubleshooting.
Popular CDN providers include Cloudflare, Amazon CloudFront, Akamai, and Fastly. For this guide, we'll outline a general approach applicable to most providers, but specific steps may differ. Always consult the provider’s documentation. Consider using a provider that supports HTTPS for secure content delivery.
CDN Configuration Steps
The following steps outline the general configuration process.
1. Account Creation & Zone Setup: Create an account with your chosen CDN provider and set up a "zone" or "distribution" pointing to your MediaWiki server's hostname (e.g., `www.example.com`). 2. DNS Configuration: Update your domain's DNS records (usually at your domain registrar) to point to the CDN provider's nameservers or CNAME record. This directs traffic to the CDN. Incorrect DNS configuration is a common cause of issues; verify carefully. See DNS records for further understanding. 3. Cache Configuration: Configure caching rules within the CDN. Specify which file types to cache (e.g., `.jpg`, `.png`, `.js`, `.css`) and for how long (cache TTL - Time To Live). Carefully consider caching strategies to avoid serving outdated content. 4. SSL/TLS Configuration: Enable SSL/TLS on the CDN to serve content over HTTPS. You'll likely need to provide an SSL certificate (either generated by the CDN or uploaded from your own certificate authority). Maintaining secure connections is vital for user trust and Security. 5. Purging/Invalidation: Learn how to purge or invalidate the CDN cache when you update content on your MediaWiki server. This ensures users receive the latest versions of files. 6. Origin Shield (Optional): Some CDNs offer an "origin shield" feature. This designates a single CDN PoP as the sole point of contact with your origin server, reducing load.
MediaWiki Configuration
After configuring the CDN, you need to tell MediaWiki to use the CDN URLs for static assets. This is done through the `LocalSettings.php` file.
```php $wgCDNServers = array(
'local' => '//cdn.example.com', // Replace with your CDN URL
);
$wgUseTrackbacks = false; //Disable Trackbacks. They frequently cause issues with CDNs. ```
The `$wgCDNServers` variable defines the base URL for CDN assets. The `//` prefix allows the browser to use the same protocol (HTTP or HTTPS) as the current page. The `wgUseTrackbacks` setting helps avoid CDN issues. Remember to clear the MediaWiki cache after modifying `LocalSettings.php` using Maintenance scripts.
Technical Specifications: CDN Performance Metrics
The following table shows typical performance improvements with a CDN:
Metric | Without CDN | With CDN |
---|---|---|
Average Page Load Time | 3.5 seconds | 1.2 seconds |
Time to First Byte (TTFB) | 800ms | 200ms |
Origin Server Load | High | Low |
Bandwidth Costs | Higher | Lower |
Technical Specifications: Common CDN Cache TTL Settings
File Type | Recommended TTL |
---|---|
Images (.jpg, .png, .gif) | 7 days - 30 days |
JavaScript (.js) | 1 day - 7 days |
CSS (.css) | 1 day - 7 days |
Fonts (.woff, .ttf) | 30 days |
Technical Specifications: Supported CDN Features
Feature | Description | Availability |
---|---|---|
SSL/TLS Support | Enables secure HTTPS delivery. | Common |
Compression (Gzip, Brotli) | Reduces file sizes for faster transfer. | Common |
Geographic Filtering | Restricts content access based on location. | Less Common |
Web Application Firewall (WAF) | Protects against web attacks. | Common (often as an add-on) |
Real-time Analytics | Provides insights into CDN performance. | Common |
Verification and Troubleshooting
1. Browser Developer Tools: Use your browser's developer tools (usually accessed by pressing F12) to verify that static assets are being served from the CDN domain. Check the "Network" tab. 2. Ping/Traceroute: Use `ping` and `traceroute` to confirm that requests are being routed through the CDN's servers. 3. CDN Analytics: Review the CDN provider's analytics dashboard for performance metrics and caching statistics. 4. Cache Purging: Test cache purging to ensure that updates are reflected quickly. 5. Common Issues:
* DNS Propagation: Allow sufficient time for DNS changes to propagate (up to 48 hours, though usually faster). * Caching Issues: Purge the cache if you're seeing outdated content. * SSL/TLS Errors: Verify SSL/TLS configuration and certificate validity. * Mixed Content: Ensure all resources are served over HTTPS if your site is using HTTPS. See HTTPS configuration. * Incorrect CDN URL: Double-check the `$wgCDNServers` setting in `LocalSettings.php`.
Further Reading
- Configuration curves
- Site configuration
- Performance optimization
- Security
- DNS records
- HTTPS configuration
- Maintenance scripts
Intel-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Core i7-6700K/7700 Server | 64 GB DDR4, NVMe SSD 2 x 512 GB | CPU Benchmark: 8046 |
Core i7-8700 Server | 64 GB DDR4, NVMe SSD 2x1 TB | CPU Benchmark: 13124 |
Core i9-9900K Server | 128 GB DDR4, NVMe SSD 2 x 1 TB | CPU Benchmark: 49969 |
Core i9-13900 Server (64GB) | 64 GB RAM, 2x2 TB NVMe SSD | |
Core i9-13900 Server (128GB) | 128 GB RAM, 2x2 TB NVMe SSD | |
Core i5-13500 Server (64GB) | 64 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Server (128GB) | 128 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Workstation | 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000 |
AMD-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Ryzen 5 3600 Server | 64 GB RAM, 2x480 GB NVMe | CPU Benchmark: 17849 |
Ryzen 7 7700 Server | 64 GB DDR5 RAM, 2x1 TB NVMe | CPU Benchmark: 35224 |
Ryzen 9 5950X Server | 128 GB RAM, 2x4 TB NVMe | CPU Benchmark: 46045 |
Ryzen 9 7950X Server | 128 GB DDR5 ECC, 2x2 TB NVMe | CPU Benchmark: 63561 |
EPYC 7502P Server (128GB/1TB) | 128 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/2TB) | 128 GB RAM, 2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/4TB) | 128 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/1TB) | 256 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/4TB) | 256 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 9454P Server | 256 GB RAM, 2x2 TB NVMe |
Order Your Dedicated Server
Configure and order your ideal server configuration
Need Assistance?
- Telegram: @powervps Servers at a discounted price
⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️