Fork me on Github
Fork me on Github

Joe Dog Software

Proudly serving the Internets since 1999

Amazon Linux vs. RedHat Enterprise

Your JoeDog has moved … again.

We were on a t.small instance on Amazon Web Services running RedHat Enterprise Linux. That instance cost us $0.086 / hour — that’s 8.6¢ an hour. The monthly billing total was around $65.00. A t.small instance includes 1 CPU, 8GB of disk and 2GB of RAM. Two gigs was a lot of memory in 2004, but contemporary software goes Oliver Twist on that shit. “Please, sir, may I have some more?”

Your JoeDog wanted more. We had trouble managing our application stack within the confines of two gigs of RAM. Your JoeDog checked its options on the Amazon pricing chart and found something interesting: Amazon Linux is priced far below RedHat Enterprise. A t.small server running that OS was only $0.026 per month. With prices that low, it offered room for a server upgrade. For $0.052 / hour, we could get a t.medium server which has 2 CPU and 4GB of RAM. That was more acceptable.

Yes, more memory is more awesome but there’s an ever better reason to switch from RHEL7. That OS uses systemd as its startup mechanism. Amazon uses SYSVINIT. (Earlier version of RHEL used SYSVINIT. Systemd is new to RHEL7)

We cutover to the new server a few hours ago. It was a simple move since Your JoeDog was using an Amazon RDS database. We just copied content and configs to the new server and we were off and running.

Is Amazon Linux right for you? Probably. For starters, it’s similar. It has the look and feel of a RedHat variant. It uses RPM for package management and it’s directory hierarchy is similar. As mentioned above, it’s startup mechanism is SYSVINIT rather than systemd. In this sense, it’s closer to RHEL6 than RHEL7.

For the most part, the “enterprise” premium provides enterprise support. Some software vendors won’t provide any support unless you run their product on a “certified” Linux. If you don’t have that particular requirement, then Amazon’s flavor should serve you as well (at a fraction of the cost).



Write-error on swap-device

Your JoeDog was down this morning. This site is hosted on the free plan at Amazon Web Services. Through the EC2 web portal, he was able to read the console logs of the downed instance. It was filled with entries which looked like this:

9443.085875 Write-error on swap-device (202:0:10258840)
9443.085875 Write-error on swap-device (202:0:10295632)
9443.085875 Write-error on swap-device (202:0:10320576)
9443.085875 Write-error on swap-device (202:0:10336216)
9443.085875 Write-error on swap-device (202:0:10395280)

So Your JoeDog plugged that error into the Google machine and it produced this Amazon EC2 forum entry. The Amazon rep asked that troubled soul if he could stop and start his instance. So Your JoeDog did a stop and start. That didn’t solve his problem, either. In the end, he was forced to clone the volume and bring up a whole new server. He took the opportunity to add more memory. Yeah, that means he’s no longer on the free plan but he can’t deal with the low-memory micro instance for another second. Not. One. More. Second.

So if you’re a troubled soul who found this entry because you googled “Write-error on swap-device” for your downed EC2 instance, here’s how you bring up a clone.

  1. EC2 Dashboard => Instances (select downed instance)
  2. Actions => Image => Create image (that’s going to take a while)
  3. On the left nav: Images => AMIs (select the new one)
  4. Select it, then hit Launch. (follow the instructions)

Once your new server is up and running, log in and scrutinize the environment. You should have all the content that was one the old one. It is, afterall, a clone. Once you’re feeling good about the new server, you can terminate the old one and delete the old image.

 



Amazon Web Services Free Edition

(Or how to run a website on a shoestring budget)

Last fall, Your JoeDog moved this site into Amazon’s web cloud. He’s using a micro instance on the free tier. It’s free for a year then $0.017 an hour after that.

Note that “micro” part. We’re talking about a pretty lean server. When it first came online, this site screeched to a halt at semi-irregular intervals. It was running out of memory. To increase its capacity while remaining in the free tier, Your JoeDog added some swap. “How do you add swap space in AWS?” Glad you asked. Here’s how:

  $ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
  $ sudo chown root:root /var/swap.1
  $ sudo chmod 600 /var/swap.1
  $ sudo /sbin/mkswap /var/swap.1
  $ sudo /sbin/swapon /var/swap.1

You can check your creation with the free command:

  $ free -m

By adding swap, Your JoeDog was better able to keep this site humming. Unfortunately, it still locked up. One day, it locked up for an extended period of time.

To monitor the site’s availability, we signed up for pingdom. There’s a free version which allows you to monitor a single URL and send text alerts. (Email won’t do us much good since that service is hosted here.)

Not long after the alerts were configured, one fired. The site was down(ish). Downish? What’s that mean. It was more like a series of brief outages. While this was going on, Your JoeDog’s inbox started filling with new-comment-needs-approval messages.

LINK SPAMMERS!! Some asshole was botting the site with unthrottled comment posts and they essentially DOS’d it.

To free up resources, Your JoeDog created an AWS database instance and moved his content from a local database with an export/import. There’s only one reason you shouldn’t do the same: cost. After the free period, you’ll be charged for that as well.

So what’s the moral of this story? If you can afford it, don’t waste your time on the free instance. These micro VMs are too light to handle traffic bursts. And if you’re a serious business, then you really shouldn’t bother. In the grand scheme of things, Amazon’s computing-for-lease is really inexpensive … except, of course, if you’re a lowly open source developer.