lower the number of apache restarts

Hello,

We are using opcache for website speed optimization which work very well but when there is a apache restart no matter graceful or full the load on the server rises a lot because it need to recompile and cache everything again (downside of using mod_fcgid but this is another talk). But virtualmin make graceful restart on almost every change you make also installing wordpress with automated script install is doing graceful. For example if client want to add website (1 graceful), install wordpress (1 graceful), install SSL certificate (2 restarts. One for activating SSL and then another when installing the certificate). So those are 4 graceful restarts in no more than 2 minutes.

So you one good solution will be scheduled apache restarts. I imagine it like this: When apache restart is needed instead of make the restart to change one variable from 0 to 1 ( or to touch a file somewhere) if it is not done already. Then a cron which is ruining every minute (for example) checks if there this variable and if it is set to 1 to do graceful (and change it back to 0) if not to not do anything.

This way for a couple of changes the restart will be only one.

Other thing will be to add support for PHP-FPM.

Status: 
Closed (fixed)

Comments

Thanks, we'll look into that.

One problem is that doing this would make it so that functionality the user is trying to setup wouldn't work right away, which could be confusing or frustrating to users.

I do understand the issue you're experiencing on your server of course.

But we need to be careful adding new features (we already have too many), especially ones that don't appear to be in high demand.

I do have an idea though.

Are you, or someone on your team, familiar with creating shell scripts?

One thing you could do is create a shell script to do what you want.

When called, perhaps this shell script creates a temp file somewhere, indicating that an Apache restart is required.

You could then change the program Virtualmin uses for restarting Apache to point at this shell script you created.

Then, you could create a cron job that runs regularly, whatever time period you are comfortable with -- and if it sees this shell script, it would restart Apache.

You can configure what programs Webmin is using for restarting Apache by going into Webmin -> Servers -> Apache, and there, click the gear icon at the top. In there, you'll be able to see the various paths being used.

Would that perhaps do what you're after?

This would be basically impossible to implement in Virtualmin - for example, if installing a script requires an apache restart to change the PHP version or install a PHP module, later phases of the script install could fail.

Yes I understand that but, most cases all (for us all cases because we install wordpress and we have everything it need installed already) the modules but although virtualmin is doing graceful but it should not. If it is possible to not doing graceful restart when they are not needed for sure it will be great.

I suppose you could fake it by configuring Virtualmin to run a script that does nothing instead of apachectl , and then have a cron job that runs the real apachectl every 10 minutes.

we have think on this but unfortunately it is not a good solution.

How can we disable apache graceful on script install?

We have try to remove couple of the code parts in the install script but non of them work and it is doing a graceful.

Can you post the output from a script install in which Apache was restarted? It shouldn't be needed unless some PHP module is installed..

Downloading http://wordpress.org/latest.tar.gz (178 bytes) ..
Downloading https://wordpress.org/latest.tar.gz (7.59 MB) ..
     Received 1008 bytes (0 %)
     Received 777.66 kB (10 %)
     Received 1.52 MB (20 %)
     Received 2.28 MB (30 %)
     Received 3.04 MB (40 %)
     Received 3.80 MB (50 %)
     Received 4.56 MB (60 %)
     Received 5.32 MB (70 %)
     Received 6.07 MB (80 %)
     Received 6.83 MB (90 %)
     Received 7.59 MB (100 %)
.. download complete.

Configuring webserver PHP settings ..
.. already done.
Applying web server configuration ..
.. done

Now installing WordPress version Latest ..
WordPress installation complete. It can be accessed at http://domain.com/wp-admin/install.php.
More information on using this script can be found at http://wordpress.org/.

.. done
Applying web server configuration ..
.. done

<-  Return to script information  |  Return to list of scripts  |  Return to virtual server details

I'll take a look into removing the Apache restart in this case - for 99% of script installs, no change is needed so no restart actually has to be done.

I found the cause of some un-necessary restarts - this will be fixed in the 5.05 Virtualmin release.

Status: Active » Fixed