Tuning Apache to Improve t2.micro Performance

A few simple changes to your Apache config file can greatly improve your micro instance performance.

apache-server-logo[1]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).

Leveraging RDS to improve performance in the AWS Free Tier

Amazon-RDS[1]Six months ago, I created a Free tier account and got access to a t2.micro instance at no cost (for a year). My plan was to port my old blog over from Blogger (check), freshen up on my Linux skills (check), and to dip my toe into Lambda and DynamoDB waters (check and check).

errorestablishingadatabaseconnection-180x180[1]As the name implies – a micro instance is SMALL (1 vCPU, 1 GiB RAM). Naturally, a micro instance isn’t the most robust1. I was constantly having Apache crash, or getting the dreaded WordPress database connection error.

Fortunately, the Free tier also comes with 750 hours of RDS. So, following the instructions Pascal Alma’s website, I proceeded to move my WordPress DB instance from EC2 to RDS.

The move was straight forward…. with a few hiccups:

  1. I originally planned to use the AWS Database Migration Service, but had a heck of a time getting the endpoints to connect. After 20 minutes of fooling around, I gave up on DMS and instead used the export/import instructions in Mr Alma’s website.
  2. Security, Security, Security – make sure that you allow communication between your EC2 and RDS servers. I have my EC2 instances in one security group and my RDS instance in another, so I needed to alter the security group inbound rules to allow communication between the server (you’ll need this to both move the data and for ongoing operations).2

A few hours later (and honestly what should have taken 30 mins), I was running my blog against the MySQL database instance in RDS.

My only concern is cost; this blog is a hobby and I not looking forward to paying $100 a year for two t2.micro instances (webserver and DB). Maybe I’ll move the web server to a nano instance… food for thought.

My Favorite Albums: OutKast’s Aquemini

aquemini-558a0696ab9efI spent the summer and fall of 1998 as a college intern at a research facility in Columbus, Ohio. I was at a real crossroads – my grades from the fall of 1997 and the spring of ’98 were not good1. I was focused on all the wrong things, and I was hoping my natural ability would allow me to get by.

Unfortunately, it wasn’t enough, so I made the hard decision to take a semester (Fall 1998) off from school.

Looking back, it was one of the best decisions in my life. I was away from school and away from friends. I was expected to show up to work on time and to be prepared when I showed up. I had to pay my bills on time and budget.

I was able to align my priorities. I started taking better care of myself.

That’s one of the reasons I love Aquemini. It was the soundtrack to that season in my life. I loved jams, I loved the beats, I loved the lyrics. Dre and Big Boi were maturing from  Southernplayalistic… and ATLiens. I was maturing, too. Continue reading “My Favorite Albums: OutKast’s Aquemini”

Switching to Playstation Vue: Cost Analysis

Switching to PlayStation Vue could result in $1200 in savings over the next two years.

19992670539_23769d7c20_z[1]I have to admit something: I haven’t been eating my own dog food – at least when it comes to disruptive technologies. My company preaches leveraging disruptors; as a consultant, I constantly encourage my clients to take advantage of the newest tech to reduce capital (and operating cost).

So, I’m ashamed to say that I haven’t practiced what I’ve preached – when it comes to communication and media costs. I have a contract with satellite company. I have a home phone with a local provider. Last week, I received a bill from my local telco for $112 – and that’s just for internet service and a home phone (which my family only uses for the alarm and to have in case of an emergency). Continue reading “Switching to Playstation Vue: Cost Analysis”

AWS Elastic Beanstalk – Managed Platform Updates

AWS Elastic Beanstalk can now update to the latest version of your underlying platform during a specified maintenance window.

ElasticBeanstalk_Thumbnail[1]Last night, I logged into the EC2 instance that supports this blog. Turns out that I’ve been a negligent system administrator – there were 69 updates pending!

The issue of patching and maintenance may seem trivial; however, companies spend millions of dollars keeps the underlying platforms for their enterprise systems up-to-date.

Enter the Managed Platform Updates updates to the AWS Elastic Beanstalk service. As stated on the AWS blog:

You can now choose to have your AWS Elastic Beanstalk environments automatically update to the latest version of the underlying platform running your application during a specified maintenance window. Elastic Beanstalk regularly releases new versions of supported platforms (i.e., Java, PHP, Ruby, Node.js, Python, .NET, Go, and Docker) with operating system, web & application server, and language & framework updates. Previously, you had to manually initiate updates to your Elastic Beanstalk environments using the Elastic Beanstalk console, command line interface (CLI), or API. Now, you can simply select a weekly maintenance window and have Elastic Beanstalk automatically update the platform version of your environment during that window.

It’ll be interesting to see if companies take advantage of this functionality, and if it causes a reduction in TCO for systems as they move to AWS.