
100.000 visit/tháng chia ra trung bình ~3.300 visit/ngày, peak có thể lên 200-300 concurrent. Đây là threshold mà nhiều site WordPress bắt đầu "đụng tường" trên shared hosting hoặc VPS chưa tuning. Bài này tôi share stack đang chạy production: OpenLiteSpeed + LSCache + Redis Object Cache + MariaDB tuned + Cloudflare CDN + WebP - đo được TTFB < 200ms, p95 < 500ms cho user VN. Tất cả config copy paste được. Mục tiêu: bạn deploy xong 1 buổi tối, site bay mượt cả năm.
1. Chọn cấu hình VPS đúng
| Traffic/tháng | vCPU | RAM | Disk | Gợi ý gói |
|---|---|---|---|---|
| 10-50k visit (5-20k page view) | 2 | 2GB | 40GB | VPS 20 (199k) |
| 50-150k visit | 4 | 4GB | 80GB | VPS 30 (299k) |
| 100-300k visit (sweet spot bài này) | 4 | 8GB | 80GB NVMe | VPS 50 (639k) |
| 300k-1M visit (WooCommerce, multi-site) | 6 | 16GB | 160GB | VPS 80/160 |
| 1M+ visit (cần load balancer) | 8+ | 32GB+ | 250GB+ | VPS 250/320 |
Với 100k visit/tháng, VPS 50 của TND (4 vCPU, 8GB RAM, 80GB Ceph SSD Enterprise NVMe, giá 639.000đ/tháng) là sweet spot. RAM 8GB cho phép bạn chạy được LiteSpeed + PHP-FPM + MariaDB + Redis cùng lúc mà còn dư cache, không bị swap. NVMe Ceph cho I/O cao, MariaDB query nhanh. IPv4 sạch để mail SMTP gửi đi không bị flag.
2. Stack overview
┌─────────────────────────────────────────────┐
│ Cloudflare CDN + WAF │
│ (cache static, anti-DDoS, hide origin) │
└──────────────────┬──────────────────────────┘
│
┌──────────────────▼──────────────────────────┐
│ VPS Ubuntu 24.04 LTS │
│ │
│ OpenLiteSpeed (web server + page cache) │
│ │ │
│ ├── LSCache plugin (page cache) │
│ │ │
│ ▼ │
│ PHP 8.3 LSAPI (faster than PHP-FPM) │
│ │ │
│ ├── Redis (object cache) │
│ │ │
│ ▼ │
│ MariaDB 11.4 (database, tuned) │
└─────────────────────────────────────────────┘Tại sao OpenLiteSpeed thay vì Nginx? OpenLiteSpeed có LSCache - page cache server-level miễn phí, tích hợp sẵn plugin WordPress, mặc định invalidate cache đúng khi update post. Bạn không phải config FastCGI cache thủ công như Nginx. PHP LSAPI cũng nhanh hơn PHP-FPM ~10-20% trên benchmark WordPress.
Nếu bạn quen Nginx hơn, dùng Nginx + FastCGI cache + PHP-FPM 8.3 cũng OK, perf chỉ kém OLS ~5-10%.
3. Cài stack bằng OpenLiteSpeed 1-line
# SSH vào VPS Ubuntu 24.04
ssh root@your-vps-ip
# Cài CyberPanel (control panel free, chạy trên OpenLiteSpeed)
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
# Chọn:
# 1. Install CyberPanel
# 1. OpenLiteSpeed (free, OK cho 100k visit)
# Full installation: Y
# Remote MySQL: N
# Password: s -> set admin password
# Memcached + Redis: Y cả 2
# Watchdog: YCài 15-20 phút. Xong, mở https://your-vps-ip:8090, login bằng admin password.
Tạo website trong CyberPanel
Websites -> Create Website:
- Domain: yourdomain.com
- Email: admin email
- PHP: 8.3
- SSL: tick (Let's Encrypt auto)
- DKIM Support: tick (cho email)
WordPress + LSCache -> 1 click cài. Xong, vào yourdomain.com/wp-admin với credentials CyberPanel cung cấp.
4. Tuning PHP 8.3 LSAPI
File: /usr/local/lsws/lsphp83/etc/php/8.3/litespeed/php.ini
; Memory limit cho WordPress + plugin
memory_limit = 512M
; Upload size
upload_max_filesize = 64M
post_max_size = 64M
; Execution time
max_execution_time = 300
max_input_time = 300
; OPcache - cực quan trọng cho perf
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1
opcache.validate_timestamps = 1
opcache.save_comments = 1
; Realpath cache (filesystem lookup faster)
realpath_cache_size = 4096K
realpath_cache_ttl = 600
; Session redis (thay vì file)
session.save_handler = redis
session.save_path = "tcp://127.0.0.1:6379"Restart LiteSpeed:
systemctl restart lsws5. Tuning MariaDB 11.4
File: /etc/mysql/mariadb.conf.d/50-server.cnf
[mysqld]
# InnoDB buffer pool - quy tắc: 50-70% RAM nếu VPS chỉ chạy MySQL
# VPS 8GB RAM: dành 3GB cho MariaDB (vì còn LiteSpeed, PHP, Redis)
innodb_buffer_pool_size = 3G
innodb_buffer_pool_instances = 4
innodb_log_file_size = 512M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
# Query cache - DEPRECATED trong MariaDB 10.5+, để 0
query_cache_size = 0
query_cache_type = 0
# Connection
max_connections = 200
thread_cache_size = 50
# Temp tables
tmp_table_size = 128M
max_heap_table_size = 128M
# Slow query log để debug
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
# Character set
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_cisystemctl restart mariadb
# Verify
mysql -u root -p -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';"6. Redis Object Cache - giảm 40-80% DB query
CyberPanel đã cài Redis. Giờ kết nối WordPress:
# 1. SSH vào, edit wp-config.php
cd /home/yourdomain.com/public_html
nano wp-config.php
# Thêm vào trước dòng "That's all, stop editing":
define('WP_CACHE', true);
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_DATABASE', 0);
define('WP_REDIS_PREFIX', 'yourdomain_'); # nếu chạy multi-site cùng VPSVào wp-admin -> Plugins -> Add New -> tìm "Redis Object Cache" (của Till Krüss) -> Install + Activate. Vào Settings -> Redis -> click "Enable Object Cache". Status phải hiện "Connected".
Test hit rate sau 1 ngày:
redis-cli INFO stats | grep keyspace
# keyspace_hits: 124583 (request hit cache)
# keyspace_misses: 8421 (miss, query DB)
# Hit rate = hits / (hits + misses) = ~93%/etc/redis/redis.conf: maxmemory 512mb + maxmemory-policy allkeys-lru. Redis sẽ tự evict key cũ khi đầy.7. LSCache plugin - page cache server-level
CyberPanel cài WordPress đã bao gồm LSCache plugin. Vào LiteSpeed Cache trong wp-admin:
- General: Enable LiteSpeed Cache.
- Cache TTL: Public 3600s (1h), Private 1800s, Front Page 86400s (24h).
- Purge: Auto Purge on Update tick All.
- Excludes: /cart/, /checkout/, /my-account/ (nếu có WooCommerce).
- Browser Cache: Enable, TTL 31557600s (1 năm) cho asset tĩnh.
- Object Cache: Enable, Redis, host 127.0.0.1 port 6379.
- Image Optimization: Enable, Auto Request Cron, WebP.
Sau khi enable, test bằng curl:
# Lần 1: MISS (chưa cache)
curl -I https://yourdomain.com/
# X-LiteSpeed-Cache: miss
# Lần 2: HIT
curl -I https://yourdomain.com/
# X-LiteSpeed-Cache: hitKhi hit, request không qua PHP/DB - chỉ serve HTML từ disk. Site có thể chịu hàng ngàn req/s.
8. Cloudflare CDN + WAF (free plan đủ dùng)
- Đăng ký Cloudflare, add domain, change nameserver tại nhà reg.
- SSL: Full (Strict) - bắt buộc dùng SSL Let's Encrypt trên VPS.
- Caching: Standard, Browser Cache TTL: 1 month.
- Speed: Auto Minify HTML/CSS/JS (off nếu LSCache đã làm), Brotli ON, Early Hints ON.
- Network: HTTP/3 ON, 0-RTT ON.
- Security: Bot Fight Mode ON, Security Level Medium.
- Rules: Page Rule cho /wp-admin/* -> Cache Level: Bypass, Disable Performance.
Page Rule quan trọng nhất: Cache Everything cho /wp-content/uploads/* với Edge Cache TTL 1 month. Hình ảnh sẽ serve từ edge gần user, origin VPS không phải gánh.
9. Image optimization: WebP + lazy load
LSCache plugin có Image Optimization module miễn phí dùng QUIC.cloud. Bật xong vào IMG Optm -> Run Optimization. Nó upload ảnh lên QUIC, generate WebP/AVIF, download về VPS. Mỗi lần plugin gọi Cron tự xử ảnh mới.
Plugin alternative: ShortPixel, Imagify, Smush - đều OK, có quota free.
Lazy load: LSCache cũng có. Bật: LiteSpeed -> Page Optimization -> Media -> Lazy Load Images.
10. Database housekeeping (làm hàng tuần)
# SSH vào, vào wp-cli
cd /home/yourdomain.com/public_html
# Xoá post revision cũ (chỉ giữ 5 latest mỗi post)
wp post delete $(wp post list --post_type='revision' --format=ids) --force
# Xoá spam comment
wp comment delete $(wp comment list --status=spam --format=ids) --force
# Optimize tables MariaDB
wp db optimize
# Limit autoload data (nguyên nhân site chậm hàng đầu)
wp option list --autoload=on --format=table | sort -k2 -n | tail -20Nếu có option autoload > 100KB thì xem có nên disable autoload không. Plugin "Autoload Cleaner" giúp xác định.
11. Backup tự động
# /root/backup-wp.sh
#!/bin/bash
DOMAIN="yourdomain.com"
WP_PATH="/home/${DOMAIN}/public_html"
BACKUP_DIR="/backups"
DATE=$(date +%F)
mkdir -p $BACKUP_DIR
# Backup files
tar czf $BACKUP_DIR/files-$DATE.tar.gz -C $WP_PATH .
# Backup database
DB_NAME=$(grep DB_NAME $WP_PATH/wp-config.php | cut -d "'" -f 4)
DB_USER=$(grep DB_USER $WP_PATH/wp-config.php | cut -d "'" -f 4)
DB_PASS=$(grep DB_PASSWORD $WP_PATH/wp-config.php | cut -d "'" -f 4)
mysqldump -u $DB_USER -p"$DB_PASS" $DB_NAME | gzip > $BACKUP_DIR/db-$DATE.sql.gz
# Xoá backup cũ > 14 ngày
find $BACKUP_DIR -name "*-*.tar.gz" -mtime +14 -delete
find $BACKUP_DIR -name "*-*.sql.gz" -mtime +14 -delete
# Optional: upload lên S3 / R2 / B2
# aws s3 sync $BACKUP_DIR s3://your-bucket/wp-backups/
# Cron: chạy 2h sáng hàng ngày
# crontab -e
# 0 2 * * * /root/backup-wp.sh > /var/log/backup.log 2>&112. Monitoring: biết khi nào site có vấn đề
# Cài Uptime Kuma trên VPS phụ hoặc subdomain
docker run -d --restart=always -p 3001:3001 \
-v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
# Vào http://your-ip:3001 - tạo monitor HTTPS check
# - URL: https://yourdomain.com
# - Interval: 60s
# - Notification: Telegram bot (free, dễ setup)Hoặc dùng dịch vụ free: UptimeRobot, BetterUptime, Healthchecks.io.
13. Benchmark thực tế
Setup này test với Loader.io / k6 trên VPS 50:
| Scenario | RPS | P95 latency | Note |
|---|---|---|---|
| Cached page (LSCache HIT) | 3000+ | 50-100ms | Hầu như không hit PHP |
| Logged-in user (cache MISS) | 50-100 | 300-500ms | Qua PHP, Redis hit |
| WooCommerce add-to-cart | 30-50 | 400-700ms | DB write |
Với 100k visit/tháng (~3.300/ngày, peak ~50 concurrent), VPS 50 dư sức. Khi traffic gấp 5 lên 500k thì cân nhắc nâng cấp gói VPS lớn hơn tại TND hoặc thêm 1 VPS làm read replica cho MariaDB.
14. Quick win checklist
- [ ] OpenLiteSpeed + PHP 8.3 LSAPI cài qua CyberPanel
- [ ] OPcache enable, memory 256M
- [ ] MariaDB innodb_buffer_pool 30-50% RAM
- [ ] Redis object cache + maxmemory limit
- [ ] LSCache plugin enable, page cache HIT verify
- [ ] Cloudflare proxy on, SSL Full Strict
- [ ] Image WebP via LSCache + lazy load
- [ ] Backup script + cron hàng ngày
- [ ] Uptime monitoring + Telegram alert
- [ ] DB optimize wp-cli weekly cron
15. Kết luận
Stack này tôi đã chạy production cho nhiều site WordPress trong nhiều năm, 100k traffic/tháng "dễ thở" trên VPS 50, 500k vẫn ổn trên VPS 80, đến 1M+ thì nên scale ngang (load balancer + 2 web node + DB riêng). Quan trọng là cache đúng tầng: server cache > object cache > query cache. Bỏ qua server cache mà cố tuning DB sẽ không bao giờ đạt TTFB thấp.
Bài viết liên quan
Cần VPS chạy WordPress mượt cho 100k+ traffic?
Tham khảo gói VPS 50 (4 vCPU, 8GB RAM, 80GB Ceph SSD Enterprise NVMe, IPv4 sạch) - sweet spot cho WordPress + LiteSpeed + Redis + MariaDB. Datacenter VN/US, khởi tạo 60 giây, support tiếng Việt 24/7.
- Hermes computer_use tool: agent điều khiển desktop ảo trên VPS qua Docker
- Thuê Cloud VPS Việt Nam: hướng dẫn chọn cấu hình cho startup + SaaS nhỏ
- Playwright + Crawlee + VPS scrape 10k page mỗi ngày không bị ban
- Claude Code là gì? Cách chạy Claude Code 24/7 trên VPS không cần để máy bật
- Hóa đơn VAT phần mềm bản quyền: Thông tư 78/2021 + quy trình xuất hóa đơn TND
- Hermes Agent cho dropshipping/affiliate: auto-research sản phẩm + viết content


