Categories
How-To scalability hacking sysadmin TechBiz WebApps

How to Load Balance and Auto Scale with Amazon’s EC2

This blog post is a quick introduction to load balancing and auto scaling on with Amazon’s EC2.

I was kinda amazed about how easy it was.

Prelims: Download the load balancer API software, auto scaling software, and cloud watch software. You can get all three at a download page on Amazon.

Let’s load balancer two servers.

elb-create-lb lb-example --headers \
--listener "lb-port=80,instance-port=80,protocol=http" \
--availability-zones us-east-1a

The above creates a load balancer called “lb-example,” and will load balance traffic on port 80, i.e. the web pages that you serve.

To attach specific servers to the load balancer you just type:

elb-register-instances-with-lb lb-example --headers \
--instances i-example,i-example2

where i-example and i-example2 are the instance id’s of the servers you want added to the load balancer.

You’ll also want to monitor the health of the load balanced servers, so please add a health check:

elb-configure-healthcheck lb-example --headers \
--target "HTTP:80/index.html" --interval 30 --timeout 3 \
--unhealthy-threshold 2 --healthy-threshold 2

Now let’s set up autoscaling:

as-create-launch-config example3autoscale --image-id ami-mydefaultami \
--instance-type m1.small
as-create-auto-scaling-group example3autoscalegroup  \
--launch-configuration example3autoscale \
--availability-zones us-east-1a \
--min-size 2 --max-size 20 \
--load-balancers lb-example
as-create-or-update-trigger example3trigger \
--auto-scaling-group example3autoscalegroup --namespace "AWS/EC2" \
--measure CPUUtlization --statistic Average \
--dimensions "AutoScalingGroupName=example3autoscalegroup" \
--period 60 --lower-threshold 20 --upper-threshold 40 \
--lower-breach-increment=-1 --upper-breach-increment 1 \
--breach-duration 120

With the 3 commands above I’ve created an auto-scaling scenario where a new server is spawned and added to the load balancer every two minutes if the CPU Utilization is above 20% for more than 1 minute.

Ideally you want to set –lower-threshold to something high like 70 and –upper-threshold to 90, but I set both to 20 and 40 respectively just to be able to test.

I tested using siege.

Caveats: the auto-termination part is buggy, or simply didn’t work. As the load went down, the number of the server on-line remained the same. Anybody have thoughts on this?

What does auto-scaling and load balancing in the cloud mean? Well, the total cost of ownership for scalable, enterprise infrastructure just went down by lots. It also means that IT departments can just hire a cloud expert and deploy solutions from a single laptop instead of having to figure out the cost for hardware load balancers and physical servers.

The age of Just-In-Time IT just got ushered in with auto-scaling and load balancing in the cloud.

Categories
sysadmin TechBiz WebApps

Monitoring Websites on the Cheap: Screen and Sitebeagle

If you don’t fail fast enough, you’re on the slow road to success.

One idea that I recently failed was using a screen and sitebeagle to monitor sites.

It’s not a complete failure… it works okay.

Due to budget constraints, I put my screen and sitebeagle set up on a production server.

For some reason that production server ran out of space and became unresponsive. Screen no doubt caused this. I was alerted of the issue and did a reboot.

After the reboot, although Amazon’s monitoring tools told me the server was okay, the server was not. The MySQL database was in an EBS volume and needed to be re-mounted.

The solution I now have in place is still screen and sitebeagle. But I use another server with screen and sitebeagle on it to monitor the production server that gave me the issue in the first place.

It’s a question of who will monitor the monitors… in a world of web sites with few site users the answers pretty bleak. In the world of super popular commercial sites, the answer’s clear. The wisdom of crowds will monitor the web sites.

Categories
Announcements TechBiz

Lone Coder in a Sea of Power Users?

Hey folks, I might expand this into a larger article for either mashable.com or techcrunch.com .

I was wondering if you folks who are coders feel that you’ve been put in a situation where you are the lone coder in a sea of power users?

If so, is this situation ideal for you? Not ideal?

How do you deal with job queues?

How do you deal with working with power users with conflicting interests?

I’m really interested in war stories where you feel you’re the lone expert.

Cheers, Barce

Categories
TechBiz WebApps

Gear6.com Hijacks @memcached on Twitter

By taking the @memcached username on Twitter, Gear6.com has engaged in identity theft. Yes, someone call the police now.

I’m pretty sure this is one of those posts that won’t make anyone happy.

Let me first start off with what is meant by identity theft. Wikipedia provides a pretty solid, working definition. If you disagree with it, then I’m curious as to why and how, but for this discussion, I’m using it to prove a point.

“Identity theft is a crime used to refer to fraud that involves someone pretending to be someone else in order to steal money or get other benefits.”

For example, if I walked around telling people I’m Chow Yun Fat while flashing a fake ID that says Chow Yun Fat, and I say, “Let me into this party. Wasn’t Crouching Tiger Hidden Dragon an awesome film?” then I’m stealing Chow Yun Fat’s identity. There is no way he’d say, “It’s cool, go ahead and pretend to be me.”

Let’s take a look at @memcached on Twitter.

First off, having the url, http://twitter.com/memcached , is like having a business card. A business card cannot be used to legally establish identity, but it strongly suggests an identity.

In this case, I would expect that http://twitter.com/memcached is someone, or a group of persons working on the memcached open source project.

Let’s say I go to the url for the memcached twitter account.

What do I see?

http://twitter.com/memcached/status/1376487185

@bdeshong How are you liking the new changes in 1.3.2? Digging the new stats?

I see a few posts of @memcached pretending to be a member of the memcache open source coding team just like some dude pretending to be Chow Yun Fat at a party.

And here’s bdeshong thinking he’s talking to memcache:

@memcached Haven’t had a chance to spend any time with it just yet. In the next week or two, though…

http://twitter.com/bdeshong/status/1376501081

There are other examples where they announce releases of memcache as if they were the memcached development team.

This is the equivalent of me signing up with the @twitter account and announcing based on the twitter blog that twitter has released new code.

Now they’re clearly pretending to be someone else, but are they doing it for stealing money? Getting other benefits? Well, no money has changed hands here. There are just a lot of confused people, but confusing folks isn’t a crime.

Are they getting benefits?

Yes! In the Internet age attention equals money in terms of pageviews. They are definitely getting the benefit of the advertising garnered through the memcached name!

This sort of reverse-swiftboating where the stolen, good name of an open source software project is used to prop up business interests. I really do believe that building scalable websites is a good business model, but please don’t steal names that represent reputations you haven’t earned.

I ask @ev and the folks at Twitter to please take away @memcached from Gear6.com and give it to the *real* memcached community.

Categories
php Questions ruby TechBiz WebApps

My Favorite Coder Interview Question

What is your favorite algorithm?

My favorite algorithm right now is the merge sort.

v1: Nuno Nogueira (Nmnogueira), v2: edited by Daniel Miller (cobaltBlue)
v1: Nuno Nogueira (Nmnogueira), v2: edited by Daniel Miller (cobaltBlue)

I like it so much that I’ve implemented it in PHP and Ruby.

The problem is that as a web developer I’ve never had to use a merge sort. Back in the old days when pagination was tricky, I’ve had to use a linked list, but you really don’t have to use the merge sort anymore.

So at this point it’s really just academic.

What interview question should really count now?

More on that in my next post. As a clue, I’d like to say it has to do with Leibniz’s statement, “The present is big with the future.” A techie who believes that and the principle of sufficient reason is the kind of techie you want.

Categories
TechBiz WebApps

Google Adwords: A Great Trend Spotter

I initially put up Google Adwords to bring more traffic to this blog.

What’s interesting with using Google Adwords is that you get to bid on certain key words. 3 months later I’m noticing that a few word phrases have gone up in price:
Google Adwords, a great trending spotter

It’s a great sign that the phrase, “newlisp webserver,” has gone up 400%. It’s definitely a sign that more people are taking a commercial interest in newlisp as a serious web server. I’ve wrote about how newlisp is the fastest way to get onto the Internet before, and it still continues to be the fastest.

What’s also interesting is seeing that ec2 and lamp are still pretty stale.

The big take away is that you can use Google Adwords as a trending tool.

Categories
software TechBiz

3 Clients for Storing Data into Amazon S3

It’s not that difficult to store data into your Amazon S3 account and share that data with 50,000 or so people on the cheap.

Armed with just your Access Key ID and Secret Access Key, you can use these two cool storage clients.

S3 Webmaster

For Windows, you can download the S3 Webmaster for free, and you just simply drag and drop your files and S3 will automatically set the permissions for public download.

S3Hub

For Macs, there is S3Hub, which works whether or not you have an S3 account. If you don’t have an S3 account you can view other public S3 buckets. If you do have an account you can easily upload and share the assets you stored.

Transmit

If your data storage needs run the gamut from sftp, webdav, iDisk, automated upload workflows, and S3, you’ll want to plunk down some cash like I did and get Transmit. At $17.95 it’s a bargain. I use it’s webdav and S3 features almost daily.

Categories
command-line How-To TechBiz

The Infamous Zed Shaw Declares ACL Is Dead

If you work with ACL, this may be the most important video you watch ever. Zed shows how ACL is not Turing complete, which explains all the problems you’ve been having with control lists.


Zed Shaw – The ACL is Dead from CUSEC on Vimeo.

Categories
command-line How-To TechBiz

Setting Up An EC2 LAMP Server

Pre-requisites:

Now we’re ready to build an EC2 LAMP Server.

cd .ec2

You’ll find that a lot of ec2 stuff happens in the .ec2 directory.

To list the possible servers that you can set up run:

ec2-describe-images -a

I ran

ec2-describe-images -a | wc -l

and got 1477 possible servers. Some are Windows.

Let’s say we see this listing:

IMAGE ami-1539dc7c level22-ec2-images/ubuntu-8.04-hardy-20080205a.manifest.xml

If we want to start up the ubuntu server listed above we just type:

ec2-run-instances ami-5647a33f -k ec2-keypair

And then we run this command:

ec2-describe-instances

We should see either “pending” or the actual instance running with its FQDN listed in the 4th column. An example FQDN is this:

ec2-173-33-159-95.compute-1.amazonaws.com

And if we go to:
http://ec2-173-33-159-95.compute-1.amazonaws.com/

we should see a webserver.

And if we ssh:

ssh -i ec2-keypair ec2-173-33-159-95.compute-1.amazonaws.com

we’ll get the root prompt:
#~

That’s basically it. Now you can go in and mess around with server settings.

In the next blog post, we’ll look at how to save your custom server settings and set up using S3.

Categories
TechBiz WebApps

Amazon’s EC2 and S3 — Computing on the Cheap

I was really inspired by the story of Pownce., and how they used S3 for storing media assets.

I really liked how easy it was to share media with Pownce. Alas, it’s no more and shut down on December 15th of last year.

What’s a guy to do? Well, using a combination of Transmit, a file upload and synchronization client, and S3 I can hack my own file sharing. I just upload the files I want to share and send the links to friends.

Here’s a link to an S3 media asset.

Once I felt comfortable about S3, I took the dive into EC2.

Pros: You can have a server of your choice, in my case LAMP, running in less than 5 minutes.

Cons: If the server crashes, all your data is gone.

Solution: Use ESB for database storage and S3 to back up files and custom executables.

How much does it cost?

For 1 LAMP server with 1.7GiB RAM running with a virtual 1.7Ghz CPU, and about 160GiB of storage will run you about 10 cents an hour, which is not bad considering that a colo will charge you around $100 per 1U or 12.5 cents per hour, and you’re stuck with the hardware you have.

The savings are even greater if you’re just setting up servers for prototyping and tearing them down. My last EC2 bills averaged at about $35 per month.

The next few blog posts will go into more detail about how to set up your own EC2 virtual server, and the pitfalls I’ve run into.