12

I have a Wordpress blog with one post. I wanted to self-host for the experience and "fun" of it. I rarely get any viewers at all because I am just setting up. I am on an Amazon EC2-micro Arch-Linux instance using Apache 2.4.23 and MySQL 5.5.52 to run Wordpress. I have 1 GB of RAM.

I did not think that this would be a resource heavy application, but every time I try to run Wordpress, after a couple days the server always crashes. This is due to Apache spawning 100s of processes and not killing them. Shouldn't these go away after a while?

Top Processes

I have spent quite a bit of time now googling the problem. I have set up 2 GB of swap trying to fix it. The processes overflow that too. I have added maxClients 40 to my httpd.conf and that seemed to work for a while, but after about 2 weeks Apache crashed again. I have tried other configurations in httpd.conf but they would cause Apache to crash even quicker. I have a block that currently looks like this (after several tries):

# StartServers 3
# MinSpareServers 2
# MaxSpareServers 5
# ServerLimit 10
 maxClients 40
# MaxRequestsPerChild 100
# KeepAliveTimeout 2

Could anyone experienced with this specific problem give me some advice? I'm just trying to host a simple WordPress blog. If it helps, here is my httpd -V

[ec2-user~]$ httpd -V
Server version: Apache/2.4.23 (Amazon)
Server built:   Jul 29 2016 21:42:17
Server's Module Magic Number: 20120211:61
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:     prefork
  threaded:     no
    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"

Edit: Also the fact that these processes are in uninterruptible sleep (IO, Status = D) is problematic!

  • Why Apache? There's precious little reason to use it over nginx these days 2) Do your Apache logs reflect a significant amount of traffic?
  • – EEAA Dec 29 '16 at 02:49
  • 6
    ^^^ Another misguiding and iliterate comment. The question is. Why Apache with mod_php forcing Apache to use prefork? The answer is, he clicked a button somewhere and he got that, but that does not mean Apache does not perform well, that just means the whole set up is not meant to be performant, just easy to install. – Daniel Ferradal Dec 29 '16 at 10:06
  • "How do I fix Apache?" Answer: "Don't use Apache." Perfect. – Layne B Jun 11 '21 at 00:08