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
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.