Card 06/ 09
DNS Example: Moving a Website to a New Server
Lowering the TTL a day early is what makes the switch fast.
Moving a site to a new address is fast only if the TTL was lowered first. A team changed www.example.com to a new server's address at 5pm, with the record's TTL at 86400 seconds, one day. At 9am the next morning, about half its users were still reaching the old server, which had already been shut down.
The second time, they planned the move around the TTL. The times below are for that second move.
Monday 10:00
Lower the TTL from 86400 to 300
Resolvers still hold copies with the one-day TTL, so nothing changes yet. Every user is on the old server.
Tuesday 10:00
Wait out the old TTL
Every copy cached with the one-day TTL has expired. Resolvers now hold the record for at most 300 seconds.
Tuesday 10:05
Change the address
Within five minutes almost every user has moved to the new server. Both servers keep running.
Wednesday 10:00
Raise the TTL again
The move has held, so the TTL goes back up to reduce queries, and the old server is shut down.
Three things are worth noticing.
The wait is the old TTL, not the new one. Lowering the TTL takes effect only when each resolver's existing copy expires, so the team had to wait a full day after lowering it. Changing the TTL and the address at the same time would have helped no one.
Both servers run during the switch. Some resolvers keep answers longer than the TTL says, and some clients cache too, so the old server keeps serving until traffic to it stops, not until the clock says it should.
The first move failed for the same reason. With a one-day TTL, a resolver that cached the record at 4:59pm was entitled to give out the old address until 4:59pm the next day. Half the users still on the old server at 9am was exactly what that TTL allowed.
← → move through sections and cards