Performance Optimization
- Performance Optimization
This article details server configuration options for improving the performance of a MediaWiki 1.40 installation. Optimizing performance is crucial for a positive user experience, especially as your wiki grows. We’ll cover database optimization, caching strategies, and web server tuning. This guide is aimed at system administrators and those familiar with server configuration.
1. Database Optimization
The database is often the biggest bottleneck in a MediaWiki installation. Choosing the right database and configuring it correctly are vital. We will focus on MySQL/MariaDB, as they are the most common choices.
1.1 Database Engine
InnoDB is the recommended storage engine for MediaWiki. It provides transaction support and better data integrity than MyISAM.
1.2 Key Configuration Variables
Here are some key MySQL/MariaDB variables to tune:
Variable | Description | Recommended Value |
---|---|---|
`innodb_buffer_pool_size` | The size of the buffer pool, which caches data and indexes in memory. | 50-80% of available RAM |
`innodb_log_file_size` | The size of each InnoDB log file. Larger files reduce checkpointing frequency. | 256M - 1G (depending on write load) |
`query_cache_size` | (Deprecated in MySQL 8.0, MariaDB still supports it) The size of the query cache. | 0 (Generally disabled in modern setups. Use alternative caching layers) |
`max_connections` | The maximum number of simultaneous client connections. | 150-300 (Adjust based on user load) |
`key_buffer_size` | (MyISAM only, if still in use) The size of the key buffer. | 16M - 64M (if MyISAM tables exist) |
1.3 Indexing
Proper indexing is crucial for query performance. Ensure indexes are created on frequently queried columns, such as `page_title`, `page_id`, and `user_id`. Use `EXPLAIN` to analyze query performance and identify missing indexes. See Manual:Database for more information.
2. Caching Strategies
Caching reduces the load on the database by storing frequently accessed data in memory. MediaWiki provides several caching mechanisms.
2.1 Memcached/Redis
Using an external caching system like Memcached or Redis is highly recommended. These systems can cache query results, parser output, and other frequently accessed data. Configure MediaWiki to use these caches via the `wgMemCachedServers` and `wgRedisServers` settings in `LocalSettings.php`.
2.2 Opcode Cache
An [opcode cache](https://en.wikipedia.org/wiki/Opcode_cache) (e.g., APCu, OPcache) caches the compiled PHP code, reducing the time it takes to execute scripts. Ensure an opcode cache is enabled and configured on your web server.
2.3 MediaWiki Caching
MediaWiki has built-in caching mechanisms. These include:
Cache Type | Description | Configuration |
---|---|---|
Parser Cache | Caches the output of the parser. | `$wgParserCacheType = 'redis';` or `$wgParserCacheType = 'memcached';` |
Query Cache | (Partially replaced by external caches) Caches database query results. | `$wgCachePages['query'] = true;` |
Output Cache | Caches rendered pages. | `$wgCachePages['all'] = true;` |
3. Web Server Tuning
The web server (e.g., Apache, Nginx) also plays a crucial role in performance.
3.1 Apache Configuration
If using Apache, consider using `mod_php` with a persistent PHP process manager like `mod_fcgid` or `mod_proxy_fcgi`. Disable unnecessary modules. Increase the `MaxRequestWorkers` setting to handle more concurrent requests. See Manual:Configuration for details.
3.2 Nginx Configuration
Nginx is often a better choice for high-traffic MediaWiki installations. Configure Nginx to serve static files directly and use PHP-FPM for PHP processing. Adjust worker processes and connection limits. Ensure proper caching headers are set for static assets. See Manual:Nginx for guidance.
3.3 PHP Configuration
Optimize the `php.ini` file. Key settings include:
Setting | Description | Recommended Value |
---|---|---|
`memory_limit` | The maximum amount of memory a PHP script can allocate. | 256M - 512M (depending on wiki size) |
`max_execution_time` | The maximum time a PHP script can run. | 30 - 60 seconds |
`post_max_size` | The maximum size of POST data. | 8M - 16M |
`upload_max_filesize` | The maximum size of uploaded files. | 8M - 16M |
4. Monitoring and Analysis
Regular monitoring is essential to identify performance bottlenecks. Use tools like:
- Special:Statistics - Provides basic wiki statistics.
- MySQL/MariaDB performance monitoring tools (e.g., `mysqltuner.pl`, Percona Monitoring and Management).
- Web server logs (access logs and error logs).
- System monitoring tools (e.g., `top`, `htop`, `vmstat`).
5. Future Considerations
- Consider using a Content Delivery Network (CDN) for static assets.
- Regularly review and optimize database queries.
- Keep MediaWiki and all its dependencies updated to the latest versions for bug fixes and performance improvements.
- Explore using a load balancer to distribute traffic across multiple servers. Refer to Manual:Load balancer.
Manual:Configuration
Manual:Database
Manual:Nginx
Special:Statistics
Help:Contents
Extension:Memcached
Extension:Redis
Manual:PHP
Manual:Upgrading
Manual:Command-line tools
Manual:API
Manual:Shortcuts
Help:Editing
Help:Linking
Special:Search
Special:AllPages
Special:ListUsers
Special:RecentChanges
Special:Watchlist
Special:MyPreferences
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.* ⚠️