Zum Hauptinhalt springen

๐Ÿ“Š Performance Tuning

Optimize Monitron SaaS for high-load environments with many monitors.


๐Ÿ˜ PHP Configurationโ€‹

memory_limit = 256M
max_execution_time = 120
upload_max_filesize = 100M
post_max_size = 100M
opcache.enable = 1
opcache.memory_consumption = 256
opcache.max_accelerated_files = 20000
opcache.validate_timestamps = 0 # Set to 1 during development

๐Ÿ’พ Database Optimizationโ€‹

MySQL my.cnfโ€‹

[mysqld]
innodb_buffer_pool_size = 512M # 50-70% of RAM for dedicated DB servers
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2 # Faster writes, slight durability risk
query_cache_type = 0 # Disabled in MySQL 8+
max_connections = 200

Index Healthโ€‹

Monitron includes indexes on frequently queried columns. Verify they exist:

SHOW INDEX FROM monitor_checks;
SHOW INDEX FROM monitors;

โšก Redisโ€‹

Use Redis for both caching and queues for best performance:

.envโ€‹

CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis

Install Redisโ€‹

sudo apt install redis-server
sudo systemctl enable redis

๐Ÿ”„ Queue Worker Tuningโ€‹

For Many Monitors (200+)โ€‹

# /etc/supervisor/conf.d/monitron-worker.conf
[program:monitron-worker]
numprocs=6 # More workers for more monitors
command=php /var/www/monitron/artisan queue:work redis --sleep=1 --tries=3 --max-time=3600 --max-jobs=1000

Separate Critical Queueโ€‹

[program:monitron-worker-critical]
numprocs=2
command=php /var/www/monitron/artisan queue:work redis --queue=checks-critical --sleep=1 --tries=3

[program:monitron-worker-standard]
numprocs=4
command=php /var/www/monitron/artisan queue:work redis --queue=checks-standard,default --sleep=3 --tries=3

๐Ÿ“ฆ Laravel Optimizationโ€‹

# Run ALL optimizations
php artisan optimize
php artisan view:cache
php artisan event:cache
php artisan filament:optimize

# Autoloader optimization
composer install --no-dev --optimize-autoloader --classmap-authoritative

๐ŸŒ Nginx Tuningโ€‹

worker_processes auto;
worker_connections 2048;

http {
keepalive_timeout 65;
gzip on;
gzip_types text/plain application/json application/javascript text/css;

fastcgi_cache_path /tmp/nginx-cache levels=1:2 keys_zone=monitron:10m;
}

๐Ÿ“Š Monitoring Your Monitoringโ€‹

Yes, you should monitor Monitron itself! Use an external uptime service (or a second Monitron instance) to check:

  • Your Monitron dashboard URL
  • Queue worker health (add a heartbeat ping to your worker)
  • Database connectivity
  • Disk space on the Monitron server