IPv6 is the latest version of the Internet protocol, replacing the obsolete IPv4 that still powers most of the web and resolving the IP depletion problem. Is it really faster and should you care about it for your server?
Is IPv6 faster?
There is a bit of debate around this issue. On paper, IPv6 should be slightly slower. The header size is much larger, because IPv6 needs 128 bits for source and destination addresses, compared to 32 bits for IPv4. Overall, the header size for IPv6 has almost doubled.
However, this is not really a problem in practice, as IPv6 is not only an increase in address size – it greatly simplifies traffic management and, in some cases, can lead to a real increase in traffic. performance due to bottlenecks in the IPv4 infrastructure.
In the past, IPv6 was terribly slow, but it is improving from year to year. According to Facebook in 2015, IPv6 has improved TCP connection response times by up to 15%. However, this is of the order of a few milliseconds, which is not nothing, but it is not such a radical speed advantage that you would have to activate it immediately.
In some cases, however, IPv6 may actually be a bit slower than IPv4, not to mention the fact that some users cannot access IPv6 content.
Verdict: it doesn’t hurt to activate it
The good news is that we don’t need to settle this debate here, because the issue doesn’t really matter. You don’t have to choose one or the other. Most modern browsers send TCP handshake requests to both IPv4 and IPv6 the addresses of your web server (as well as any other alternative address). Whoever answers first is chosen to establish the complete connection.
If an older browser does not support this, it will simply connect to the IPv4 address. This is known as the Happy eyeballs (or Fast Fallback), and that’s the main reason that makes IPv6 adoptable in the first place.
Overall, if you can’t activate IPv6 for some reason, or don’t care about it, you won’t miss much. Activating it, however, is very simple, and with potential performance improvements on the table, it’s worth taking a few minutes to activate it. After all, it can’t hurt.
How to activate IPv6 in NGINX and Apache
Before you start, you need to make sure that your web server is even accessible via IPv6. This will usually imply that you request an IPv6 address from your VPS provider. For AWS, IPv6 addresses are created automatically for EC2 instances and are assigned to the ENI, not the instance itself.
After that, you will need to create a AAAA record (four times IPv4) in your DNS, so that users know which address to connect to. Your DNS provider should have an option for this. For AWS, you can even create AAAA alias records, which will be dynamically mapped to an AWS resource over IPv6.
For NGINX, you can activate IPv6 by listening to the available IPv6 addresses of your server, with the following notation:
Listen [::]: 80;
Optionally, you can listen to a single manual address using listening [ADDRESS]: 80, or enable IPv6 only using ipv6only = on.
For Apache, you can activate it in the same way using an additional Listen directive in your httpd.conf:
Listen [ADDRESS]: 80