A quick update here, I'm starting to believe there is a memory leak in either the way I've configured or compiled httpd on AWS EC2. I'm running a t2.small with 4GB memory with LAMP installed and 4 very small (< 5 hits a day) sites running on it. In my opinion, even with mod_php, Apache should require no more than 100MB IN TOTAL. That's not, however, the case:
[ec2-user@ip-172-31-21-23 ~]$ free -m total used free shared buffers cached Mem: 3954 *3809* 145 19 214 643 -/+ buffers/cache: 2952 1002 Swap: 0 0 0 [ec2-user@ip-172-31-21-23 ~]$ ps aux | grep 'httpd' | awk '{print $6/1024;}' 2.07812 45.9297 9.48438 2648.25 [ec2-user@ip-172-31-21-23 ~]$ ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print "Num Processes: " NR " Average: " avg " MB";}' Num Processes: 4 Average: 676.416 MB There you have it. A *4GB, $50/mo EC2 server* with the default installation of LAMP <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html>, at *96% utilized memory* and *71%* of the used memory going to 4 Apache processes (average of 676.4MB per process). If you're wondering how it is installed: [ec2-user@ip-172-31-21-23 ~]$ httpd -V Server version: Apache/2.4.27 (Amazon) Server built: Aug 2 2017 18:02:45 Server's Module Magic Number: 20120211:68 Server loaded: APR 1.5.1, APR-UTIL 1.4.1 Compiled using: APR 1.5.1, APR-UTIL 1.4.1 Architecture: 64-bit Server MPM: worker threaded: yes (fixed thread count) forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="/var/run/httpd/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" and the loaded modules: [ec2-user@ip-172-31-21-23 ~]$ httpd -M Loaded Modules: core_module (static) so_module (static) http_module (static) access_compat_module (shared) actions_module (shared) alias_module (shared) auth_basic_module (shared) auth_digest_module (shared) authz_core_module (shared) authz_dbd_module (shared) authz_dbm_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_owner_module (shared) authz_user_module (shared) autoindex_module (shared) data_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) expires_module (shared) ext_filter_module (shared) filter_module (shared) headers_module (shared) include_module (shared) info_module (shared) log_config_module (shared) mime_module (shared) negotiation_module (shared) reqtimeout_module (shared) request_module (shared) rewrite_module (shared) setenvif_module (shared) slotmem_plain_module (shared) slotmem_shm_module (shared) socache_dbm_module (shared) socache_memcache_module (shared) socache_shmcb_module (shared) status_module (shared) unixd_module (shared) userdir_module (shared) version_module (shared) vhost_alias_module (shared) watchdog_module (shared) dav_module (shared) dav_fs_module (shared) dav_lock_module (shared) mpm_worker_module (shared) ssl_module (shared) cgid_module (shared) php5_module (shared) pagespeed_module (shared) Thoughts on optimization/memory repair? Thank you! On Wed, Sep 6, 2017 at 2:25 PM, Tony DiLoreto <t...@miglioretechnologies.com > wrote: > Thanks Luca, I'll give that a shot. What surprises me is how much each > process was consuming; at times 250mb each. Are you saying the majority of > that is for php? > > At the end of the day, I'm looking for the optimal configuation for a > standard Wordpress site server. Given the ubiquity of the platform you'd > expect more people to have blogged about the required mods and MPM > settings for this, but I've come back with little. > > Do we have a "barebones Wordpress" list of mods that are required? > > On Wed, Sep 6, 2017 at 1:30 AM Luca Toscano <toscano.l...@gmail.com> > wrote: > >> Hi Tony, >> >> usually httpd consumes a very little amount of memory, if it is behaving >> in that way it is probably due to some module like mod_php. Can you give us >> a bit more info about your mpm used and the list of modules loaded? For >> example, the most common use case that we see is mpm-prefork and mod_php >> causing a ton of RAM consumed (each httpd process allocates memory for a >> PHP interpreter), meanwhile a solution like mpm-worker|event + >> mod_proxy_fcgi + php-fpm works way better. >> >> My suggestion would be to narrow down what module is really causing your >> memory to saturate before tuning the mpm. >> >> Luca >> >> >> 2017-09-06 1:33 GMT+02:00 Tony DiLoreto <t...@miglioretechnologies.com>: >> >>> Hi Luca, >>> >>> Basically my server runs out of free memory and freezes. On AWS I have >>> to stop/start it again to be able to SSH in. What I'd really like is a >>> MAX_PERCENTAGE_AVAILABLE_MEMORY directive that limits Apache to <= some >>> % of free memory. That way it can never halt my system. >>> >>> Hope this helps. >>> >>> On Tue, Sep 5, 2017 at 1:16 PM Luca Toscano <toscano.l...@gmail.com> >>> wrote: >>> >>>> Hi Tony, >>>> >>>> 2017-08-31 23:43 GMT+02:00 Tony DiLoreto <t...@miglioretechnologies.com >>>> >: >>>> >>>>> Hi All, >>>>> >>>>> I've been scouring the internet for best practices or heuristics for >>>>> specifying parameter values of the MPM directives. My server seems to lock >>>>> up regardless of the values I enter. Are there "rules of thumb" for each >>>>> MPM type (prefork, worker, event)? >>>>> >>>>> >>>> Can you tell us what do you mean with "lock up"? >>>> >>>> Luca >>>> >>> -- >>> Tony DiLoreto >>> President & CEO >>> Migliore Technologies Inc >>> >>> 716.997.2396 >>> t...@miglioretechnologies.com >>> >>> >>> >>> miglioretechnologies.com >>> *The best in the business...period!* >>> >> >> -- > Tony DiLoreto > President & CEO > Migliore Technologies Inc > > 716.997.2396 > t...@miglioretechnologies.com > > > > miglioretechnologies.com > *The best in the business...period!* > -- Tony DiLoreto President & CEO Migliore Technologies Inc 716.997.2396 t...@miglioretechnologies.com miglioretechnologies.com *The best in the business...period!*