Last week, I moved my WordPress DB from my t2.micro instance to RDS, with the hope that the change would improve my website performance (I was originally hosting both the web and DB server on the same EC2 instance). The good news is that I no longer get the “database connection” errors I was wont to receive. Bad news is that I’m still having performance problems: now with Apache.
As a stopgap, I configured an alarm to reboot my instance in case I received a status failure. This was a less-than-ideal fix; my server would reboot multiple times a day – sometimes 2-3 times in a 30 minute window!
Last weekend, I finally got a chance to dedicate time to resolving the issue. I spent most of my time looking at the threading options for Apache – prefork, worker, and event. I tried both prefork (the default) and event (which is the less memory-intensive option of the three). I ultimately stayed with prefork, with the following settings (h/t to Marjin van Deele’s post: Tweaking a AWS EC2-micro instance for WordPress)1.
Timeout 30
KeepAlive On
MaxKeepAliveRequests 50
KeepAliveTimeout 10
<IfModule prefork.c>
StartServers 3
MinSpareServers 2
MaxSpareServers 5
MaxClients 10
MaxRequestsPerChild 1000
</IfModule>
Two days later, my server seems to be ok. Next step is to strip out some of the preloaded modules from Apache (as outlined in Hayden James’ post: Strip Down Apache to Improve Performance & Memory Efficiency).
![Amazon-RDS[1]](http://darianbjohnson.s3.amazonaws.com/wp-content/uploads/2016/06/Amazon-RDS1-163x200.png)
![errorestablishingadatabaseconnection-180x180[1]](http://darianbjohnson.s3.amazonaws.com/wp-content/uploads/2016/06/errorestablishingadatabaseconnection-180x1801.gif)
For the first few months of it’s existence, this website was slow. I wasn’t sure what the problem was; I thought that maybe I needed more compute (the site is running on a t2.micro EC2 instance). Fortunately, before I switched instance sizes, I did some reading online.
The flow is as follows:

S topic receives the mobile number as a message