Skip to content

PHP Settings

PHP Settings: Performance Optimization and Configuration for rConfig V8

Section titled “PHP Settings: Performance Optimization and Configuration for rConfig V8”

rConfig V8 relies on PHP to execute its core functionality, and proper PHP configuration directly impacts system performance, stability, and the ability to handle large-scale network management operations. Understanding and optimizing key PHP settings ensures rConfig can process extensive configuration files, execute tasks across hundreds of devices simultaneously, and maintain responsive operations under load.

This addresses the challenge of PHP’s default conservative resource limits, which are designed for typical web applications but inadequate for network configuration management systems processing large datasets and long-running background operations. Organizations can leverage PHP tuning to eliminate timeout errors, memory exhaustion failures, and performance bottlenecks.

The memory_limit setting defines the maximum amount of memory a single PHP process can consume before being terminated. For rConfig operations, adequate memory allocation is essential when:

  • Processing large configuration files from enterprise routers or switches
  • Executing compliance checks across thousands of device configurations simultaneously
  • Generating comprehensive reports with extensive historical data
  • Performing bulk operations like policy assignments across device inventories
  • Running backups that aggregate configuration data from entire repositories

Insufficient memory allocation manifests as “Allowed memory size exhausted” errors, typically during configuration downloads, report generation, or bulk operations. These failures interrupt operations and require manual retry, impacting operational efficiency.

The max_execution_time setting controls how long a PHP script can run before PHP automatically terminates it. This protects servers from runaway processes but can prematurely terminate legitimate long-running operations.

For rConfig, execution time becomes critical when:

  • Downloading configurations from hundreds of devices in a single task
  • Running comprehensive compliance evaluations across large device inventories
  • Generating detailed audit reports spanning extended time periods
  • Executing system backups that compress large configuration repositories
  • Performing database maintenance operations on tables with millions of rows

Insufficient execution time causes tasks to fail mid-operation, leaving partial results and requiring restart. While the queue system mitigates some execution time constraints through background processing, certain operations still require extended PHP execution windows.

Memory requirements scale with deployment size and operation complexity. These recommendations assume dedicated rConfig servers where PHP is the primary memory consumer:

Server RAMRecommended memory_limitDeployment Size
4GB3072M (3GB)Small: < 500 devices
8GB6144M (6GB)Medium: 500-1,000 devices
16GB12288M (12GB)Large: 1,000-5,000 devices
32GB+28672M (28GB)Enterprise: 10,000+ devices

Note: These values allocate approximately 75-85% of available RAM to PHP, leaving sufficient memory for the OS, database, and web server processes. Adjust downward if other memory-intensive applications share the server.

Execution time requirements depend on the number of devices managed and the complexity of operations:

Environment SizeRecommended max_execution_timeRationale
Small (< 100 devices)300 seconds (5 minutes)Most operations complete within this window
Medium (100-500 devices)600 seconds (10 minutes)Bulk operations require extended processing
Large (500-1,500 devices)900 seconds (15 minutes)Comprehensive tasks span many devices
Enterprise (1,500+ devices)1200 seconds (20 minutes)Large-scale operations need maximum time

The recommended approach for PHP configuration modifies the php.ini file directly. This ensures settings apply consistently across all PHP operations including web requests, command-line scripts, and queue workers.

Locate the active php.ini file:

Terminal window
php -i | grep "Loaded Configuration File"

This command displays the path to the active configuration file. Common locations include:

  • Ubuntu/Debian: /etc/php/8.3/fpm/php.ini or /etc/php/8.3/apache2/php.ini
  • CentOS/RHEL/Rocky/AlmaLinux: /etc/php.ini

Important considerations:

  • PHP may use different php.ini files for web (Apache/Nginx) versus command-line operations
  • Modify the web server PHP configuration for web interface operations
  • Modify the CLI PHP configuration if running artisan commands directly
  • PHP-FPM typically requires configuration in the FPM-specific php.ini

Step 1: Identify PHP version and configuration file location

Terminal window
php -v
php -i | grep "Loaded Configuration File"

Note the PHP version (e.g., 8.3) and configuration file path.

Step 2: Create configuration backup

Terminal window
php -v
php -i | grep "Loaded Configuration File"

Note the PHP version (e.g., 8.3) and configuration file path.

Terminal window
sudo cp /etc/php/8.3/fpm/php.ini /etc/php/8.3/fpm/php.ini.backup.$(date +%Y%m%d)

If using Apache instead of PHP-FPM, also backup the Apache configuration:

Terminal window
sudo cp /etc/php/8.3/apache2/php.ini /etc/php/8.3/apache2/php.ini.backup.$(date +%Y%m%d)

Step 2: Create configuration backup

Terminal window
sudo cp /etc/php/8.3/fpm/php.ini /etc/php/8.3/fpm/php.ini.backup.$(date +%Y%m%d)

If using Apache instead of PHP-FPM, also backup the Apache configuration:

Terminal window
sudo cp /etc/php/8.3/apache2/php.ini /etc/php/8.3/apache2/php.ini.backup.$(date +%Y%m%d)

Step 3: Edit the PHP configuration file

Terminal window
sudo nano /etc/php/8.3/fpm/php.ini

Step 4: Locate and modify memory_limit

Press Ctrl+W, type memory_limit, press Enter. Find the line:

memory_limit = 128M

Change to your desired value based on server RAM, in this case 6G may be appropriate:

memory_limit = 6144M

Step 5: Locate and modify max_execution_time

Press Ctrl+W, type max_execution_time, press Enter. Find the line:

max_execution_time = 30

Change to your desired value based on deployment size:

max_execution_time = 600

Step 6: Save changes

Press Ctrl+O to write changes, Enter to confirm, Ctrl+X to exit.

Step 7: Restart PHP and web server

For PHP-FPM with Nginx:

Terminal window
sudo systemctl restart php8.3-fpm
sudo systemctl restart nginx

For Apache:

Terminal window
sudo systemctl restart apache2

Step 8: Verify configuration changes

Terminal window
php -i | grep memory_limit
php -i | grep max_execution_time

After modifying PHP settings and restarting services, verification ensures changes took effect correctly:

Check settings via command-line PHP:

Terminal window
php -i | grep memory_limit
php -i | grep max_execution_time

This verifies settings for CLI operations and queue workers.

An operational test confirms settings apply during actual rConfig operations:

  1. Navigate to System Settings >> System Optimization and review system information
  2. Attempt a resource-intensive operation like generating a large report
  3. Monitor for memory or timeout errors in Application Log
  4. If operations complete successfully without errors, configuration is adequate

Symptom: Changes Not Applied After Restart

Section titled “Symptom: Changes Not Applied After Restart”

Diagnosis: Verify correct php.ini file was modified and services restarted.

Possible Causes:

  • Modified php.ini for CLI instead of web server
  • Modified wrong PHP version’s configuration
  • Web server or PHP-FPM not restarted after changes
  • Syntax error in php.ini preventing PHP from loading

Resolution Steps:

  1. Verify which php.ini file is active for web requests:

    Terminal window
    php -i | grep "Loaded Configuration File"
  2. Check if PHP-FPM or web server is running:

    Terminal window
    sudo systemctl status php-fpm
    sudo systemctl status nginx
  3. Review PHP error logs for configuration errors:

    Terminal window
    sudo tail -50 /var/log/php-fpm/error.log
  4. Test PHP configuration syntax:

    Terminal window
    php -i > /dev/null
  5. If syntax errors exist, restore backup and retry modifications

Symptom: Operations Still Failing with Memory Errors

Section titled “Symptom: Operations Still Failing with Memory Errors”

Diagnosis: Memory allocation insufficient for operation scale or memory leak present.

Possible Causes:

  • Configuration processing requires more memory than allocated
  • Memory leak in PHP extensions or rConfig code
  • Multiple concurrent operations exhausting available memory
  • Database queries returning extremely large result sets

Resolution Steps:

  1. Review System Logs for specific memory exhaustion messages
  2. Identify which operation causes the error (device count, report size)
  3. Increase memory_limit incrementally (add 2-4GB)
  4. If problem persists despite large allocation, contact rConfig support for memory profiling
  5. Consider breaking large operations into smaller batches

Symptom: Queue Workers Ignore PHP Configuration

Section titled “Symptom: Queue Workers Ignore PHP Configuration”

Diagnosis: Queue workers use separate PHP configuration or process management settings.

Possible Causes:

  • Queue workers run under different PHP configuration
  • Supervisor process manager has its own timeout settings
  • Queue worker command-line PHP uses different php.ini
  • Environment variables override php.ini settings

Resolution Steps:

  1. Verify CLI PHP configuration:

    Terminal window
    php -i | grep "Loaded Configuration File"
  2. Check if different from web PHP configuration, modify both files identically

  3. Review Supervisor configuration for timeout settings in /etc/supervisor/conf.d/rconfig-horizon.conf

  4. Restart Horizon queue workers:

    Terminal window
    php /var/www/html/rconfig8/current/artisan horizon:terminate
    sudo systemctl restart rconfig-horizon

Delete phpinfo files immediately: The phpinfo() function exposes comprehensive server configuration including database credentials, API keys, and security-sensitive settings. Never leave phpinfo.php files accessible on production servers. If verification is needed, delete the file within minutes of creation.

Balance resource allocation with system stability: While generous memory limits improve rConfig performance, excessively high limits allow runaway processes to consume all available RAM, potentially crashing the entire server. Set memory_limit to 75-85% of available RAM, ensuring the operating system retains sufficient resources for stability.

Monitor for resource exhaustion attacks: Malicious actors may attempt to trigger resource-intensive operations to exhaust server memory or CPU. Monitor for unusual patterns of resource consumption and implement rate limiting on API endpoints if exposed.

Align PHP settings with deployment scale: As device inventories grow, revisit PHP configuration quarterly to ensure settings remain adequate. A memory_limit appropriate for 100 devices will prove insufficient when managing 1,000 devices.

Prioritize queue system over execution time increases: For truly large-scale operations, rely on the queue system rather than continually increasing max_execution_time. Queue workers process jobs independently with sophisticated retry logic, providing better scalability than extended synchronous execution.

Monitor actual resource usage: Use tools like top, htop, or monitoring dashboards to observe actual PHP memory consumption during peak operations. This empirical data guides configuration adjustments more accurately than estimates.

Restart PHP-FPM regularly on high-volume systems: PHP-FPM workers can accumulate memory over time (memory bloat). Schedule PHP-FPM restarts during maintenance windows (weekly or monthly) on high-volume deployments to maintain optimal performance.

Document configuration changes: Maintain internal documentation noting PHP configuration values, when they were changed, and why. This prevents confusion during troubleshooting and helps with capacity planning.

Version control configuration files: Store copies of php.ini and other configuration files in version control systems. This enables rapid restoration after server rebuilds and provides audit trails of configuration evolution.

Test configuration changes in non-production first: Whenever possible, validate PHP configuration changes in staging or test environments before applying to production. This identifies issues before they impact operations.

Review PHP configuration during major version upgrades: PHP version upgrades (e.g., 7.4 to 8.3) often introduce different default settings or require configuration migration. After PHP upgrades, verify all customizations remain in effect.

Coordinate with system updates: Operating system updates sometimes replace customized configuration files with defaults. After OS updates, verify PHP settings remain as configured and reapply customizations if necessary.

Monitor for PHP deprecation warnings: As PHP evolves, certain functions and features are deprecated. Review PHP error logs regularly for deprecation warnings that may require code or configuration updates in future PHP versions.

memory_limitSuitable For
128MVery small deployments (< 50 devices)
512MSmall deployments (50-200 devices)
1024M (1GB)Medium deployments (200-500 devices)
2048M (2GB)Large deployments (500-1,000 devices)
4096M (4GB)Very large deployments (1,000-5,000 devices)
8192M (8GB)Enterprise deployments (5,000+ devices)
max_execution_timeSuitable For
300 (5 minutes)Small deployments (< 100 devices)
600 (10 minutes)Medium deployments (100-500 devices)
900 (15 minutes)Large deployments (500-1,500 devices)
1200 (20 minutes)Enterprise deployments (1,500+ devices)
Operating SystemPHP-FPMApacheCLI
Ubuntu/Debian/etc/php/8.3/fpm/php.ini/etc/php/8.3/apache2/php.ini/etc/php/8.3/cli/php.ini
CentOS/RHEL/Rocky/AlmaLinux/etc/php.ini/etc/php.ini/etc/php.ini
Terminal window
sudo systemctl restart php8.3-fpm
sudo systemctl restart nginx
sudo systemctl restart apache2
sudo systemctl restart httpd
sudo php artisan rconfig:clear-all

Proper PHP configuration is fundamental to rConfig V8 performance and stability. Memory limits and execution time settings must scale with deployment size to prevent timeout errors, memory exhaustion failures, and operational interruptions. Organizations managing hundreds or thousands of network devices require generous resource allocation to support concurrent configuration downloads, compliance evaluations, and report generation.

Key takeaways for effective PHP configuration:

  • Allocate 75-85% of server RAM to PHP memory_limit on dedicated rConfig servers
  • Scale execution time with device count, but rely on queue system for truly large operations
  • Modify php.ini directly rather than using .htaccess for consistent application across all PHP operations
  • Always create backups before modifying configuration to enable rapid recovery from errors
  • Verify changes using both command-line and web interface testing to confirm application

Regular review and adjustment of PHP settings as deployments grow ensures rConfig maintains reliable, performant operations at scale. When configuration adjustments prove insufficient, contact rConfig support for assistance with performance profiling and advanced optimization strategies.