Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (33 sloc) 1.74 KB
author comments date layout slug title categories tags archive 2015
tvjames
true
2015-03-06 08:50:00 +1000
post
ubuntu-apt-slow-on-ec2
Making Ubuntu apt faster on ec2
Technology
ubuntu
ec2
2015
03

Note, this is based on experience in ap-southeast-2 only, using Ubuntu Cloud AMIs

I've found the performance of the default Ubuntu AWS region based apt mirror to vary greatly. Sometimes downloading a package will occur at 6+MB/s while other times it'll be barely 1KB/s.

157 BYTES PER SECOND on AWS. What the actual fuck! pic.twitter.com/u0VJT7sJI1

— Thomas James (@thomasvjames) February 27, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

This can be a problem if you're not pre-baking you're AMIs and you hit the grace period for instance spin-up in an autoscale group with a health check. If you're not careful you'll have a cycle of spin-up->unhealthy->terminate, which could end up being quite costly.

The source of this would appear to be load on the mirrors. Thankfully canonical have provided a simple solution. Switch over to the S3 backed apt mirror for that region. Why these aren't the default, who knows.

Step 1: Throw this in your instance's USER_DATA:

EC2_REGION="ap-southeast-2"
sed -i -e "s/${EC2_REGION}.ec2.archive.ubuntu.com/${EC2_REGION}.ec2.archive.ubuntu.com.s3.amazonaws.com/g" /etc/apt/sources.list
apt-get update

Step 2: Enjoy much faster apt-get.

Step 3: There is no step 3.