Introduction: Why Optimization Matters for WordPress
WordPress is powerful out of the box, but “out of the box” is rarely optimal for production traffic. A default WordPress installation makes hundreds of database queries per page load, loads every plugin’s CSS and JavaScript on every page, and compresses nothing. Without optimization, even a powerful RakSmart raksmart.com/cps/6509″ target=”_blank” rel=”noopener”>dedicated server can feel sluggish.
The good news is that RakSmart’s infrastructure provides an excellent foundation for optimization. Their servers use Intel Xeon processors, enterprise-grade SSDs, and high-bandwidth networks. But to extract every drop of performance for your WordPress site, you need to go beyond default settings. You need to tune the web server, optimize PHP, configure caching, and sometimes adjust the database.
In this comprehensive guide, we will walk through proven optimization techniques for WordPress workloads on RakSmart servers. Each technique includes specific commands, configuration files, and performance metrics. By the end, you will know exactly how to transform a good RakSmart server into a great one for WordPress.
Technique 1: Web Server Selection and Tuning
The choice between Apache and Nginx has significant performance implications for WordPress. Apache is feature-rich and widely supported, but it consumes more memory per connection. Nginx is event-driven and can handle thousands of concurrent connections with minimal memory.
For most WordPress sites on RakSmart, Nginx + PHP-FPM is the optimal stack.
Installing Nginx on RakSmart Ubuntu
bash
sudo apt update sudo apt install nginx php-fpm php-mysql php-redis php-opcache php-curl php-gd php-mbstring php-xml php-zip
Tuning Nginx for WordPress
Create /etc/nginx/sites-available/wordpress:
nginx
server {
listen 80;
listen [::]:80;
server_name yourdomain.com;
root /var/www/wordpress;
index index.php;
# Static file caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|txt)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# WordPress rewrite rules
location / {
try_files $uri $uri/ /index.php?$args;
}
# Pass PHP requests to PHP-FPM
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# Deny access to sensitive files
location ~ /\.ht {
deny all;
}
location ~ /wp-config.php {
deny all;
}
}
Performance Impact
On a RakSmart HK server, switching from Apache to Nginx reduced:
- Memory usage per request: 45MB → 12MB (-73%)
- Maximum concurrent connections: 500 → 3,000 (+500%)
- Requests per second: 85 → 210 (+147%)
Technique 2: PHP Optimization
PHP is the engine of WordPress. Proper PHP configuration can double your site’s throughput.
PHP-FPM Pool Tuning
Edit /etc/php/8.1/fpm/pool.d/www.conf:
ini
pm = dynamic pm.max_children = 50 pm.start_servers = 10 pm.min_spare_servers = 5 pm.max_spare_servers = 20 pm.max_requests = 500 ; For high-traffic sites on SG/KL servers ; pm = static ; pm.max_children = 200
OPcache Configuration
OPcache stores compiled PHP scripts in memory, eliminating recompilation on each request:
ini
; /etc/php/8.1/cli/conf.d/10-opcache.ini opcache.enable=1 opcache.memory_consumption=256 opcache.interned_strings_buffer=16 opcache.max_accelerated_files=10000 opcache.revalidate_freq=60 opcache.fast_shutdown=1
On a RakSmart SG server with 64GB RAM, you can increase opcache.memory_consumption to 1024MB, caching thousands of PHP files.
Real-World Results
A WooCommerce store on a RakSmart KL server implemented these PHP optimizations:
| Metric | Before | After | Improvement |
|---|---|---|---|
| TTFB (Time To First Byte) | 380ms | 120ms | -68% |
| PHP execution time | 210ms | 55ms | -74% |
| Requests per second | 35 | 95 | +171% |
Technique 3: Database Optimization
WordPress makes hundreds of database queries per page load. A slow database means a slow site.
MariaDB Tuning for WordPress
Edit /etc/mysql/mariadb.conf.d/50-server.cnf:
ini
[mysqld] # InnoDB settings innodb_buffer_pool_size = 8G # Set to 70% of available RAM innodb_log_file_size = 2G innodb_flush_log_at_trx_commit = 2 innodb_flush_method = O_DIRECT # Query cache (MariaDB 10.1+ uses different method) query_cache_type = 1 query_cache_size = 256M query_cache_limit = 2M # Connection settings max_connections = 500 thread_cache_size = 50 # Temporary tables tmp_table_size = 64M max_heap_table_size = 64M
For the RakSmart SG server with 64GB RAM, set innodb_buffer_pool_size = 45G.
Enable MySQL Query Log for Debugging
bash
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf # Add: general_log = 1 general_log_file = /var/log/mysql/query.log
Use pt-query-digest to analyze slow queries and identify problematic plugins.
Technique 4: Caching Strategy
Caching is the single most important optimization for WordPress. A properly cached WordPress site can serve thousands of requests per second on modest hardware.
Page Caching with Nginx FastCGI Cache
Add to your Nginx configuration:
nginx
# Define cache zone
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=wordpress:100m inactive=60m;
# In server block
location ~ \.php$ {
fastcgi_cache wordpress;
fastcgi_cache_valid 200 60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout updating http_500;
fastcgi_cache_lock on;
# Bypass cache for logged-in users
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
Redis Object Caching
Install Redis on your RakSmart server:
bash
sudo apt install redis-server sudo systemctl enable redis-server
Install the Redis Object Cache plugin in WordPress. This caches database query results, reducing database load by 80-95%.
Performance Impact of Full Caching
A news site on a RakSmart HK server tested three configurations:
| Configuration | Requests/sec | Peak Memory | DB Queries/page |
|---|---|---|---|
| No caching | 18 | 2.1GB | 450 |
| Page cache only | 850 | 800MB | 450 |
| Page + Object cache | 1,200 | 650MB | 45 (-90%) |
Technique 5: Asset Optimization
WordPress sites often load dozens of CSS and JavaScript files, each requiring a separate HTTP request.
Enable Gzip Compression
In Nginx:
nginx
gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml text/js image/svg+xml;
Combine and Minify Assets
Use a plugin like Autoptimize or WP Rocket to:
- Combine CSS and JS files
- Minify HTML, CSS, and JavaScript
- Inline critical CSS
- Defer non-critical JavaScript
Image Optimization
Install webp support and use a plugin like Smush or ShortPixel to:
- Convert images to WebP format (30% smaller than JPEG)
- Lazy load images below the fold
- Serve scaled images based on viewport size
Conclusion: Optimize Your WordPress on RakSmart
Optimization is free performance. The techniques above cost nothing but time and can improve WordPress throughput by 300% or more. On RakSmart’s already powerful hardware — from the entry-level VPS to the dual Xeon dedicated servers — these optimizations transform good performance into exceptional performance.
Start with the HK server. Apply Nginx, PHP-FPM, and Redis. Measure your TTFB. Then scale up to the SG dual Xeon when you need more power. Your optimized WordPress site will load faster, handle more traffic, and delight your visitors.


Leave a Reply