1

regarding apache tuning, there are lots of good documents and posts on the web eg. How To Tune Apache on Ubuntu 14.04 Server

unfortunately almost all of them describe how to tune apache with mpm_prefork.

as I understand though, prefork method is a bit old and lacks efficiency in multi threading and ... anyway my client insists on using mpm_event, and their main problem is with a few number of visitors their VPS become unresponsive, and I can see that the problem is with memory as their ram gets full, it gets to use the swap, swap gets full and the only way to restore the server would be restarting httpd service, or god forbid, restarting server itself!

The VPS has 2GB of ram while it servers as webserver, mailserver and MySql is also installed on it. the php.ini file is allowing max_memory=140M (which i think is a bit high?!) but for now they really need this amount. with a quick calculation about other tasks that VPS is doing, I think it is safe to assign 1GB of memory to apache.

But I can not find any method on the web to calculate the settings for mpm_event to limit it's usage to this 1GB max.

any help would be appreciated on this calculation

needed info from comments:

ps -ef | grep php => nothing

phpinfo() from Apache => Server Api : CGI/FastCGI

apachectl -M =>

Loaded Modules:
 core_module (static)
 authn_file_module (static)
 authn_dbm_module (static)
 authn_anon_module (static)
 authn_dbd_module (static)
 authn_socache_module (static)
 authn_core_module (static)
 authz_host_module (static)
 authz_groupfile_module (static)
 authz_user_module (static)
 authz_dbm_module (static)
 authz_owner_module (static)
 authz_dbd_module (static)
 authz_core_module (static)
 access_compat_module (static)
 auth_basic_module (static)
 auth_form_module (static)
 auth_digest_module (static)
 allowmethods_module (static)
 file_cache_module (static)
 cache_module (static)
 cache_disk_module (static)
 cache_socache_module (static)
 socache_shmcb_module (static)
 socache_dbm_module (static)
 socache_memcache_module (static)
 so_module (static)
 macro_module (static)
 dbd_module (static)
 dumpio_module (static)
 buffer_module (static)
 ratelimit_module (static)
 reqtimeout_module (static)
 ext_filter_module (static)
 request_module (static)
 include_module (static)
 filter_module (static)
 substitute_module (static)
 sed_module (static)
 deflate_module (static)
 http_module (static)
 mime_module (static)
 log_config_module (static)
 log_debug_module (static)
 logio_module (static)
 env_module (static)
 expires_module (static)
 headers_module (static)
 unique_id_module (static)
 setenvif_module (static)
 version_module (static)
 remoteip_module (static)
 proxy_module (static)
 proxy_connect_module (static)
 proxy_ftp_module (static)
 proxy_http_module (static)
 proxy_fcgi_module (static)
 proxy_scgi_module (static)
 proxy_wstunnel_module (static)
 proxy_ajp_module (static)
 proxy_balancer_module (static)
 proxy_express_module (static)
 session_module (static)
 session_cookie_module (static)
 session_dbd_module (static)
 slotmem_shm_module (static)
 ssl_module (static)
 lbmethod_byrequests_module (static)
 lbmethod_bytraffic_module (static)
 lbmethod_bybusyness_module (static)
 lbmethod_heartbeat_module (static)
 unixd_module (static)
 dav_module (static)
 status_module (static)
 autoindex_module (static)
 info_module (static)
 suexec_module (static)
 cgi_module (static)
 dav_fs_module (static)
 dav_lock_module (static)
 vhost_alias_module (static)
 negotiation_module (static)
 dir_module (static)
 actions_module (static)
 speling_module (static)
 userdir_module (static)
 alias_module (static)
 rewrite_module (static)
 suphp_module (shared)
 ruid2_module (shared)
 mpm_event_module (shared)
  • You maybe should start tuning down the amount of unnecessary modules you are actually loading, doubt you are using half of those in a single server. About event, few child processess, lots of threads per child, basically. Start with 100 threads per process (2-3 processes) and test around that in your current server and load. – ezra-s May 25 '21 at 15:04

1 Answers1

0

Beware if you're using mod_php, it's not compatible with the threaded apache workers, you can use it only with mpm_prefork. There is a better but more complicated setup that can work if you insist on mpm_event (or even mpm_worker), use php-fcgi. This way you'll have a complete split apache / php, so you can use pmp_event on apache and pass only the php requests to a php process pool managed by php-fcgi.

But as you're talking about memory and swap i'll look more at tuning the hpp part. Can you confirm you're using mod_php? If so what are the memory settings in php.ini?

Fredi
  • 2,227
  • 9
  • 13
  • Honestly I'm not sure if it is mod_php, as `php -i | grep "Server"` returns `Server API => Command Line Interface`, does it help ? – Muhammad Naderi Nov 21 '16 at 13:48
  • sorry for last comment, my `Server Api` using phpinfo() is `CGI/FastCGI` ... – Muhammad Naderi Nov 21 '16 at 14:00
  • phpinfo() served from Apache? If you're sure you're using that you should see php processes with this command: `ps -ef | grep php` and post your results to your question. As for RAM usage, i dont think changing MPM will do much of a difference. But anyway, post the output of: `apachectl -M` in your question too – Fredi Nov 21 '16 at 14:43
  • I have edited the question with info you asked for – Muhammad Naderi Nov 21 '16 at 15:23