Performans Optimizasyonu
XOOPS Performans Optimizasyonu
Section titled “XOOPS Performans Optimizasyonu”Maksimum hız ve verimlilik için XOOPS’yi optimize etmeye yönelik kapsamlı kılavuz.
Performans Optimizasyonuna Genel Bakış
Section titled “Performans Optimizasyonuna Genel Bakış”graph TD A[Performance] --> B[Caching] A --> C[Database] A --> D[Web Server] A --> E[Frontend] A --> F[Code] B --> B1[Page Cache] B --> B2[Query Cache] B --> B3[Template Cache] C --> C1[Indexes] C --> C2[Queries] C --> C3[Optimization] D --> D1[Compression] D --> D2[Headers] D --> D3[Connection] E --> E1[Images] E --> E2[CSS/JS] E --> E3[Lazy Load] F --> F1[Modules] F --> F2[Queries]Önbelleğe Alma Yapılandırması
Section titled “Önbelleğe Alma Yapılandırması”Önbelleğe alma, performansı artırmanın en hızlı yoludur.
Sayfa Düzeyinde Önbelleğe Alma
Section titled “Sayfa Düzeyinde Önbelleğe Alma”XOOPS’de tam sayfa önbelleğe almayı etkinleştirin:
Yönetici Paneli > Sistem > Tercihler > cache Ayarları
Enable Caching: YesCache Type: File Cache (or APCu/Memcache)Cache Lifetime: 3600 seconds (1 hour)Cache Module Lists: YesCache Configuration: YesCache Search Results: YesDosya Tabanlı Önbelleğe Alma
Section titled “Dosya Tabanlı Önbelleğe Alma”Dosya cache konumunu yapılandırın:
# Create cache directory outside web root (more secure)mkdir -p /var/cache/xoopschown www-data:www-data /var/cache/xoopschmod 755 /var/cache/xoops
# Edit mainfile.phpdefine('XOOPS_CACHE_PATH', '/var/cache/xoops/');APCu Önbelleğe Alma
Section titled “APCu Önbelleğe Alma”APCu bellek içi önbelleğe alma sağlar (çok hızlı):
# Install APCuapt-get install php-apcu
# Verify installationphp -m | grep apcu
# Configure in php.iniapc.enabled = 1apc.memory_size = 128Mapc.ttl = 0apc.user_ttl = 3600apc.shm_size = 128XOOPS’de etkinleştirin:
Yönetici Paneli > Sistem > Tercihler > cache Ayarları
Cache Type: APCuMemcache/Redis Önbelleğe alma
Section titled “Memcache/Redis Önbelleğe alma”Yüksek trafikli siteler için dağıtılmış önbelleğe alma:
Memcache’i yükleyin:
# Install Memcache serverapt-get install memcached
# Start servicesystemctl start memcachedsystemctl enable memcached
# Verify runningnetstat -tlnp | grep memcached# Should show listening on port 11211XOOPS’de yapılandırın:
Mainfile.php’yi düzenleyin:
// Memcache configurationdefine('XOOPS_CACHE_TYPE', 'memcache');define('XOOPS_CACHE_HOST', 'localhost');define('XOOPS_CACHE_PORT', 11211);define('XOOPS_CACHE_TIMEOUT', 0);Veya yönetici panelinde:
Cache Type: MemcacheMemcache Host: localhost:11211template Önbelleğe Alma
Section titled “template Önbelleğe Alma”XOOPS şablonlarını derleyin ve önbelleğe alın:
# Ensure templates_c is writablechmod 777 /var/www/html/xoops/templates_c/
# Clear old cached templatesrm -rf /var/www/html/xoops/templates_c/*Temada yapılandırın:
<!-- In theme xoops_version.php -->{smarty.const.XOOPS_VAR_PATH|constant}<{$xoops_meta}>
<!-- Templates use caching -->{cache} [Cached content here]{/cache}database Optimizasyonu
Section titled “database Optimizasyonu”database Dizinleri Ekle
Section titled “database Dizinleri Ekle”Düzgün şekilde indekslenmiş veritabanları çok daha hızlı sorgulanır.
-- Check current indexesSHOW INDEXES FROM xoops_users;
-- Common indexes to addALTER TABLE xoops_users ADD INDEX idx_uname (uname);ALTER TABLE xoops_users ADD INDEX idx_email (email);ALTER TABLE xoops_users ADD INDEX idx_uid_active (uid, user_actkey);
-- Add indexes to posts/content tablesALTER TABLE xoops_posts ADD INDEX idx_post_published (post_published);ALTER TABLE xoops_posts ADD INDEX idx_post_uid (post_uid);ALTER TABLE xoops_posts ADD INDEX idx_post_created (post_created);
-- Verify indexes createdSHOW INDEXES FROM xoops_users\GTabloları Optimize Et
Section titled “Tabloları Optimize Et”Düzenli tablo optimizasyonu performansı artırır:
-- Optimize all tablesOPTIMIZE TABLE xoops_users;OPTIMIZE TABLE xoops_posts;OPTIMIZE TABLE xoops_config;OPTIMIZE TABLE xoops_comments;
-- Or optimize all at onceREPAIR TABLE xoops_users;OPTIMIZE TABLE xoops_users;REPAIR TABLE xoops_posts;OPTIMIZE TABLE xoops_posts;Otomatik optimizasyon komut dosyası oluşturun:
#!/bin/bash# Database optimization script
echo "Optimizing XOOPS database..."
mysql -u xoops_user -p xoops_db << EOF-- Optimize all tablesOPTIMIZE TABLE xoops_users;OPTIMIZE TABLE xoops_posts;OPTIMIZE TABLE xoops_config;OPTIMIZE TABLE xoops_comments;OPTIMIZE TABLE xoops_users_online;
-- Show database sizeSELECT table_schema, ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) as total_mbFROM information_schema.tablesWHERE table_schema = 'xoops_db'GROUP BY table_schema;EOF
echo "Database optimization completed!"Cron ile zamanlama:
# Weekly optimizationcrontab -e# Add: 0 3 * * 0 /usr/local/bin/optimize-xoops-db.shSorgu Optimizasyonu
Section titled “Sorgu Optimizasyonu”Yavaş sorguları inceleyin:
-- Enable slow query logSET GLOBAL slow_query_log = 'ON';SET GLOBAL long_query_time = 2;
-- View slow queriesSELECT * FROM mysql.slow_log;
-- Or check slow log filetail -100 /var/log/mysql/slow.logYaygın optimizasyon teknikleri:
// SLOW - Avoid unnecessary queries in loopsforeach ($users as $user) { $profile = getUserProfile($user['uid']); // Query in loop! echo $profile['name'];}
// FAST - Get all data at once$profiles = getAllUserProfiles($user_ids);foreach ($users as $user) { echo $profiles[$user['uid']]['name'];}Tampon Havuzunu Artırın
Section titled “Tampon Havuzunu Artırın”Daha iyi önbelleğe alma için MySQL’yi yapılandırın:
/etc/mysql/mysql.conf.d/mysqld.cnf’yi düzenleyin:
# InnoDB Buffer Pool (50-80% of system RAM)innodb_buffer_pool_size = 1G
# Query Cache (optional, can be disabled in MySQL 5.7+)query_cache_size = 64Mquery_cache_type = 1
# Max Connectionsmax_connections = 500
# Max Allowed Packetmax_allowed_packet = 256M
# Connection timeoutconnect_timeout = 10MySQL’yi yeniden başlatın:
systemctl restart mysqlWeb Sunucusu Optimizasyonu
Section titled “Web Sunucusu Optimizasyonu”Gzip Sıkıştırmasını Etkinleştir
Section titled “Gzip Sıkıştırmasını Etkinleştir”Bant genişliğini azaltmak için yanıtları sıkıştırın:
Apache Yapılandırması:
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
# Don't compress images and already compressed files SetEnvIfNoCase Request_URI \.(jpg|jpeg|png|gif|zip|gzip)$ no-gzip dont-vary
# Log compressed responses DeflateBufferSize 8096</IfModule>Nginx Yapılandırması:
gzip on;gzip_types text/html text/plain text/css text/javascript application/javascript application/json;gzip_min_length 1000;gzip_vary on;gzip_comp_level 6;
# Don't compress already compressed formatsgzip_disable "msie6";Sıkıştırmayı doğrulayın:
# Check if response is gzippedcurl -I -H "Accept-Encoding: gzip" http://your-domain.com/xoops/
# Should show:# Content-Encoding: gzipTarayıcı Önbelleğe Alma Başlıkları
Section titled “Tarayıcı Önbelleğe Alma Başlıkları”Statik varlıklar için cache süresinin dolmasını ayarlayın:
Apache:
<IfModule mod_expires.c> ExpiresActive On
# Cache images for 30 days ExpiresByType image/jpeg "access plus 30 days" ExpiresByType image/gif "access plus 30 days" ExpiresByType image/png "access plus 30 days" ExpiresByType image/svg+xml "access plus 30 days"
# Cache CSS/JS for 30 days ExpiresByType text/css "access plus 30 days" ExpiresByType application/javascript "access plus 30 days" ExpiresByType text/javascript "access plus 30 days"
# Cache fonts for 1 year ExpiresByType font/eot "access plus 1 year" ExpiresByType font/ttf "access plus 1 year" ExpiresByType font/woff "access plus 1 year" ExpiresByType font/woff2 "access plus 1 year"
# Don't cache HTML ExpiresByType text/html "access plus 1 hour"</IfModule>Nginx:
location ~* \.(jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 30d; add_header Cache-Control "public, immutable";}
location ~* \.(css|js)$ { expires 30d; add_header Cache-Control "public";}
location ~ \.html$ { expires 1h; add_header Cache-Control "public";}Bağlantıyı Canlı Tutma
Section titled “Bağlantıyı Canlı Tutma”Kalıcı HTTP bağlantılarını etkinleştirin:
Apache:
<IfModule mod_http.c> KeepAlive On KeepAliveTimeout 15 MaxKeepAliveRequests 100</IfModule>Nginx:
keepalive_timeout 15s;keepalive_requests 100;Ön Uç Optimizasyonu
Section titled “Ön Uç Optimizasyonu”Görselleri Optimize Etme
Section titled “Görselleri Optimize Etme”Resim dosyası boyutlarını azaltın:
# Batch compress JPEG imagesfor img in *.jpg; do convert "$img" -quality 85 "optimized_$img"done
# Batch compress PNG imagesfor img in *.png; do optipng -o2 "$img"done
# Or use imagemin CLInpm install -g imagemin-cliimagemin images/ --out-dir=images-optimizedCSS ve JavaScript’yi küçültün
Section titled “CSS ve JavaScript’yi küçültün”CSS/JS dosya boyutlarını azaltın:
Node.js araçlarını kullanma:
# Install minifiersnpm install -g uglify-js clean-css-cli
# Minify JavaScriptuglifyjs script.js -o script.min.js
# Minify CSScleancss style.css -o style.min.cssÇevrimiçi araçları kullanma:
- CSS Küçültücü: https://cssminifier.com/
- JavaScript Küçültücü: https://www.minifycode.com/javascript-minifier/
Tembel Yükleme Resimleri
Section titled “Tembel Yükleme Resimleri”Resimleri yalnızca gerektiğinde yükleyin:
<!-- Add loading="lazy" attribute --><img src="image.jpg" alt="Description" loading="lazy">
<!-- Or use JavaScript library for older browsers --><img class="lazy" src="placeholder.jpg" data-src="image.jpg" alt="Description">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/17.1.2/lazyload.min.js"></script><script> var lazyLoad = new LazyLoad({ elements_selector: ".lazy" });</script>Oluşturmayı Engelleyen Kaynakları Azaltın
Section titled “Oluşturmayı Engelleyen Kaynakları Azaltın”CSS/JS’yi stratejik olarak yükleyin:
<!-- Load critical CSS inline --><style> /* Critical styles for above-the-fold */</style>
<!-- Defer non-critical CSS --><link rel="stylesheet" href="style.css" media="print" onload="this.media='all'">
<!-- Defer JavaScript --><script src="script.js" defer></script>
<!-- Or use async for non-critical scripts --><script src="analytics.js" async></script>CDN Entegrasyon
Section titled “CDN Entegrasyon”Daha hızlı küresel erişim için İçerik Dağıtım Ağı kullanın.
Popüler CDN’ler
Section titled “Popüler CDN’ler”| CDN | Maliyet | Özellikler |
|---|---|---|
| Bulut parlaması | Free/Paid | DDoS, DNS, cache, Analitik |
| AWS CloudFront | Ücretli | Yüksek performanslı, küresel |
| Tavşan CDN | Uygun fiyatlı | Depolama, video, cache |
| jsDelivr | Ücretsiz | JavaScript kütüphaneleri |
| cdnj’ler | Ücretsiz | Popüler kütüphaneler |
Cloudflare Kurulumu
Section titled “Cloudflare Kurulumu”-
https://www.cloudflare.com/ adresinden kaydolun
-
Alanınızı ekleyin
-
Ad sunucularını Cloudflare ile güncelleyin
-
Önbelleğe alma seçeneklerini etkinleştirin:
- cache Düzeyi: Agresif
- Her şeyi önbelleğe alma: Açık
- Tarayıcı Önbelleğe Alma TTL: 1 ay
-
XOOPS’de alan adınızı Cloudflare DNS kullanacak şekilde güncelleyin
CDN’yi XOOPS’de yapılandırın
Section titled “CDN’yi XOOPS’de yapılandırın”URLs resmini CDN olarak güncelleyin:
theme şablonunu düzenle:
<!-- Original --><img src="{$xoops_url}/uploads/image.jpg" alt="">
<!-- With CDN --><img src="https://cdn.your-domain.com/uploads/image.jpg" alt="">Veya PHP olarak ayarlayın:
// In mainfile.php or configdefine('XOOPS_CDN_URL', 'https://cdn.your-domain.com');
// In template<img src="{$smarty.const.XOOPS_CDN_URL}/uploads/image.jpg" alt="">Performans İzleme
Section titled “Performans İzleme”PageSpeed Insights Testi
Section titled “PageSpeed Insights Testi”Sitenizin performansını test edin:
- Google PageSpeed Insights’ı ziyaret edin: https://pagespeed.web.dev/
- XOOPS URL numaranızı girin
- Önerileri inceleyin
- Önerilen iyileştirmeleri uygulayın
Sunucu Performansı İzleme
Section titled “Sunucu Performansı İzleme”Gerçek zamanlı sunucu ölçümlerini izleyin:
# Install monitoring toolsapt-get install htop iotop nethogs
# Monitor CPU and memoryhtop
# Monitor disk I/Oiotop
# Monitor networknethogsPHP Performans Profili Oluşturma
Section titled “PHP Performans Profili Oluşturma”Yavaş PHP kodunu tanımlayın:
<?php// Use Xdebug for profilingxdebug_start_trace('profile');
// Your code here$result = someExpensiveFunction();
xdebug_stop_trace();?>MySQL Sorgu İzleme
Section titled “MySQL Sorgu İzleme”Yavaş sorguları izleyin:
# Enable query loggingmysql -u root -p
SET GLOBAL general_log = 'ON';SET GLOBAL log_output = 'FILE';SET GLOBAL general_log_file = '/var/log/mysql/query.log';
# Review slow queriestail -f /var/log/mysql/slow.log
# Analyze query with EXPLAINEXPLAIN SELECT * FROM xoops_users WHERE uid = 1\GPerformans Optimizasyonu Kontrol Listesi
Section titled “Performans Optimizasyonu Kontrol Listesi”En iyi performans için bunları uygulayın:
- Önbelleğe alma: file/APCu/Memcache önbelleğe almayı etkinleştir
- database: Dizinler ekleyin, tabloları optimize edin
- Sıkıştırma: Gzip sıkıştırmasını etkinleştir
- Tarayıcı Önbelleği: cache başlıklarını ayarlayın
- Resimler: Optimize edin ve sıkıştırın
- CSS/JS: Dosyaları küçült
- Tembel Yükleme: Resimler için uygulama
- CDN: Statik varlıklar için kullanın
- Canlı Tut: Kalıcı bağlantıları etkinleştir
- modules: Kullanılmayan modülleri devre dışı bırakın
- themes: Hafif, optimize edilmiş themes kullanın
- İzleme: Performans ölçümlerini izleyin
- Düzenli Bakım: Önbelleği temizleyin, Veritabanını optimize edin
Performans Optimizasyonu Komut Dosyası
Section titled “Performans Optimizasyonu Komut Dosyası”Otomatik optimizasyon:
#!/bin/bash# Performance optimization script
echo "=== XOOPS Performance Optimization ==="
# Clear cacheecho "Clearing cache..."rm -rf /var/www/html/xoops/cache/*rm -rf /var/www/html/xoops/templates_c/*
# Optimize databaseecho "Optimizing database..."mysql -u xoops_user -p xoops_db << EOFOPTIMIZE TABLE xoops_users;OPTIMIZE TABLE xoops_posts;OPTIMIZE TABLE xoops_config;OPTIMIZE TABLE xoops_comments;EOF
# Check file permissionsecho "Verifying file permissions..."find /var/www/html/xoops -type f -exec chmod 644 {} \;find /var/www/html/xoops -type d -exec chmod 755 {} \;chmod 777 /var/www/html/xoops/cachechmod 777 /var/www/html/xoops/templates_cchmod 777 /var/www/html/xoops/uploadschmod 777 /var/www/html/xoops/var
# Generate performance reportecho "Performance Optimization Complete!"echo ""echo "Next steps:"echo "1. Test site at https://pagespeed.web.dev/"echo "2. Monitor performance in admin panel"echo "3. Consider CDN for static assets"echo "4. Review slow queries in MySQL"Metriklerden Önce ve Sonra
Section titled “Metriklerden Önce ve Sonra”İyileştirmeleri izleyin:
Before Optimization:- Page Load Time: 3.5 seconds- Database Queries: 45- Cache Hit Rate: 0%- Database Size: 250MB
After Optimization:- Page Load Time: 0.8 seconds (77% faster)- Database Queries: 8 (cached)- Cache Hit Rate: 85%- Database Size: 120MB (optimized)Sonraki Adımlar
Section titled “Sonraki Adımlar”- Temel yapılandırmayı gözden geçirin
- Güvenlik önlemlerini sağlayın
- Önbelleğe almayı uygulayın
- Performansı araçlarla izleyin
- Metriklere göre ayarlama yapın
Etiketler: #performans #optimizasyon #önbelleğe alma #database #cdn
İlgili Makaleler:
- ../../06-Publisher-Module/User-Guide/Basic-Configuration
- Sistem Ayarları
- Güvenlik Yapılandırması
- ../Installation/Server-Requirements