Aller au contenu principal

Optimisation des Performances

Tips to make FeedbackPulse SaaS run faster as you scale.


Quick Wins

1. Cache Configuration

php artisan config:cache    # Cache .env and config files
php artisan route:cache # Cache routes
php artisan view:cache # Pre-compile Blade views

Run these after every deployment. Clear with php artisan optimize:clear.

2. Use Redis for Cache & Sessions

Redis is significantly faster than file or database cache:

sudo apt install redis-server php8.2-redis
CACHE_STORE=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis

3. Use Base de Donnees Queue (Minimum)

QUEUE_CONNECTION=database

Run a queue worker via Supervisor to process jobs in the background instead of inline.

4. Enable OPcache

; /etc/php/8.2/fpm/conf.d/10-opcache.ini
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0 ; Disable in production

Base de Donnees Optimization

Add Indexes

FeedbackPulse ships with appropriate indexes, but if you're running large queries, verify:

-- Check for slow queries
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 2;

MySQL Tuning

innodb_buffer_pool_size = 1G       # 50-70% of available RAM
innodb_log_file_size = 256M
max_connections = 200
innodb_flush_log_at_trx_commit = 2 # Slight durability trade-off for speed

Web Server Optimization

Nginx: Enable Gzip

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 256;
gzip_vary on;

Static File Caching

location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}

PHP-FPM Tuning

pm = dynamic
pm.max_children = 20 # Adjust based on RAM
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 10
pm.max_requests = 500 # Prevent memory leaks

Scaling Recommendations

TenantsRecommended Setup
1-50Single VPS, file cache, sync queue
50-200Single VPS, Redis cache, database queue with Supervisor
200-1000Dedicated server, Redis cache+queue, MySQL tuning
1000+Load balancer, separate DB server, Redis cluster, multiple queue workers

Monitoring

# Check PHP-FPM status
sudo systemctl status php8.2-fpm

# Check MySQL process list
mysqladmin processlist

# Check disk space
df -h

# Check memory usage
free -m

# Check Laravel logs for errors
tail -f storage/logs/laravel.log

Etapes Suivantes