Skip to content

Instantly share code, notes, and snippets.

@taylorotwell
Last active May 6, 2016 13:55
Show Gist options
  • Select an option

  • Save taylorotwell/8a1233273fc28553e04fa99d4dc72771 to your computer and use it in GitHub Desktop.

Select an option

Save taylorotwell/8a1233273fc28553e04fa99d4dc72771 to your computer and use it in GitHub Desktop.
Forge Ubuntu 16.04 servers are running Apt updates painfully slow in some European and Asian regions.
For example, 1GB servers in the Linode Singapore region take almost one hour to provision and many things
time out completely because Apt seems to be running so slow. This problem did not seem to be present on
Ubuntu 14.04 and does not seem to affect American regions.
Reward: SOLVED!
@donkfather

Copy link
Copy Markdown

maybe they don't have the same repositories .. and the repositories in those regions are very slow

@akalongman

Copy link
Copy Markdown

That is problem of new Apt and Ubuntu 16.04 mirrors

@mamorunl

mamorunl commented May 6, 2016

Copy link
Copy Markdown

We were having the same issue on our servers, but that was only because we had IPv6 enabled which our servers were not provisioned for.

@nicolasbeauvais

Copy link
Copy Markdown

Have you tried using a local mirror for Asia / Europe ?

ubuntu mirros

@aaranmcguire

Copy link
Copy Markdown

Can you paste in a copy of /etc/apt/sources.list.. Just to see if Linode used custom apt servers for that region.

@mpociot

mpociot commented May 6, 2016

Copy link
Copy Markdown

have you tried placing

deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiverse

in the /etc/apt/sources.list file?

@dvlpp

dvlpp commented May 6, 2016

Copy link
Copy Markdown

Clearly, that's not an american problem. I won't look for a solution unless reward is changed to euro, yen or yuan.

@ViruSzZ

ViruSzZ commented May 6, 2016

Copy link
Copy Markdown

try to force IPv4 in apt and see if that would help

echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99forceipv4

@sunel

sunel commented May 6, 2016

Copy link
Copy Markdown

http://askubuntu.com/questions/37753/how-can-i-get-apt-to-use-a-mirror-close-to-me-or-choose-a-faster-mirror

or

sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update

@MartelliEnrico

MartelliEnrico commented May 6, 2016

Copy link
Copy Markdown

Did you try changing the repository url? Here's the list of all the repos, with che corresponding command to use, like:

deb http://mirror.nus.edu.sg/ubuntu/ xenial main 
deb-src http://mirror.nus.edu.sg/ubuntu/ xenial main 

for the Singapore repo.

@bsh314

bsh314 commented May 6, 2016

Copy link
Copy Markdown

You can use deepin Linux script to figure out what repos has best speed

@nilportugues

Copy link
Copy Markdown

Using apt-fast would also help. Parallel apt-gets

@joecampo

joecampo commented May 6, 2016

Copy link
Copy Markdown

Not exactly a solution, but could certainly help overall could be to use apt-fast: https://github.com/ilikenwf/apt-fast which will download packages in parallel, it uses all the same commands as regular apt-get (install, remove, update upgrade, dist-upgrade) so you can just alias it alias apt-get='apt-fast'

@jarkas

jarkas commented May 6, 2016

Copy link
Copy Markdown

Check out the fastest mirror by issuing this command:

curl -s http://mirrors.ubuntu.com/mirrors.txt | xargs -n1 -I {} sh -c 'echo curl -r 0-102400 -s -w %{speed_download} -o /dev/null {}/ls-lR.gz {}' |sort -g -r

Then choose the fastest one, it should be in the top of the list. Then replace your current mirror to your /etc/apt/sources.list

@taylorotwell

Copy link
Copy Markdown
Author

@ViruSzZ and @mamorunl seem to be on the right track as forcing ipv4 does seem to make it much faster. Still investigating.

@thasmo

thasmo commented May 6, 2016

Copy link
Copy Markdown

As a temporary fix you could force IPv4 for apt-get:

apt-get -o Acquire::ForceIPv4=true update
apt-get -o Acquire::ForceIPv4=true upgrade

@thasmo

thasmo commented May 6, 2016

Copy link
Copy Markdown

You could also try uncommenting precedence ::ffff:0:0/96 100 in /etc/gai.conf.

@algun

algun commented May 6, 2016

Copy link
Copy Markdown

sudo nano /etc/resolv.conf

add google dns, this may solve your slow connection problem.

nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8

@timhaak

timhaak commented May 6, 2016

Copy link
Copy Markdown

Also check your HD IO. I tracked a similar problem on Azure due to their horrible IO.

This shouldn't be your problem.

@pim

pim commented May 6, 2016

Copy link
Copy Markdown

I used to have this problem many years ago (EU region), setting the DNS manually usually fixed it.

@timhaak

timhaak commented May 6, 2016

Copy link
Copy Markdown

Oh also setting up a proxy for the apt updates may also help long term if your updating multiple servers continually.

This is a nice place to start https://wiki.ubuntu.com/SquidDebProxy.

@euperia

euperia commented May 6, 2016

Copy link
Copy Markdown

Are the network interfaces' Duplex set up correctly? I had an issue where a NIC was running at 10mb/s instead of the 1GB/s it should have been. This was on a VM with Webfusion, and happened on both 12.04 and 14.04.

If they're VM's with bridged networking then I guess you won't see the duplex value with ethtool eth0.

@z-avanes

z-avanes commented May 6, 2016

Copy link
Copy Markdown

try use local mirrors
disable ipv6 and force use ipv4

@6pm

6pm commented May 6, 2016

Copy link
Copy Markdown

throw in trash ubuntu and use windows or osx

@masterpowers

Copy link
Copy Markdown

This might help u on top of precedence of ipv4 to ipv6
You can mirror to amazon s3 Asian Region

SouthEast Asia (Singapore)

deb http://ap-southeast-1.clouds.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://ap-southeast-1.clouds.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://ap-southeast-1.clouds.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
NorthEast Asia (Tokyo)

deb http://ap-northeast-1.clouds.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://ap-northeast-1.clouds.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://ap-northeast-1.clouds.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse

@taylorotwell

Copy link
Copy Markdown
Author

Was solved first by @mamorunl thanks!

@masterpowers

Copy link
Copy Markdown
Western Europe (Dublin, Ireland)

deb http://eu-west-1.clouds.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://eu-west-1.clouds.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://eu-west-1.clouds.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
Central Europe (Frankfurt, Germany)

deb http://eu-central-1.clouds.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://eu-central-1.clouds.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://eu-central-1.clouds.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse

@ViruSzZ

ViruSzZ commented May 6, 2016

Copy link
Copy Markdown

I believe the command I posted fixed the issue but anyway....

@intcorecompany

Copy link
Copy Markdown

disable IPv6 and force working with IPv4

@ViruSzZ

ViruSzZ commented May 6, 2016

Copy link
Copy Markdown

@taylorotwell please tell us whether the gai.conf fixed the issue or the command I posted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment