RDO Servers

New member
Joined
Apr 3, 2015
Messages
770
Points
0
Hey everyone,

I figured I would share something we recently learned about getting the best performance out of MySQL and IIS. We recently put up a test Wordpress site. One copy of it on our site, one copy on Amazon Elastic Compute Cloud (EC2). After running some speed tests, we realized our's was consistently 1 - 1.5 seconds slower then the instance on EC2. The delay was coming from "wait" time, or the 'time to first byte' (TTFB).

Come to find out, MySQL does not like IPv6. You can set MySQL to resolve IPv6 addresses, but by default, it will not work with the mysqlnd driver.

What does this mean for your site?

If you have MySql connection strings in your php application set to "localhost", IIS will return a IPv6 loopback address.
MySql will think it is a hostname or string, rather then a IP.
Your application will have to timeout, then try again once it falls back to the IPv4 address.

How do you fix it?

If you are running a VPS or dedicated server, you can disable IPv6 support, or set a preference for IPv4 over IPv6. If your like most people and using a shared hosting server, then this type of server wide change is not an option for you!

But, you can still fix the problem quite easily! Rather then using "localhost" in your connection string, use the actual IPv4 loopback IP: "127.0.0.1"
With this simple change, our wordpress site was loading in milliseconds, rather than seconds!

I hope this info helped someone, or at least someone learned a little something!
 

elcidofaguy

Well-known member
Joined
Jan 13, 2015
Messages
1,281
Points
113
Nice one! Always great to know of such tips which can improve performance... Curious to know if this or something similar applies to apache server also... Cheers!
 

RDO Servers

New member
Joined
Apr 3, 2015
Messages
770
Points
0
RDO Servers
The root of the problem is the mysqlnd driver for php. Its a know bug reported here [URLnf=https://bugs.php.net/bug.php?id=67563]https://bugs.php.net/bug.php?id=67563[/URLnf]

So any web server that uses mysqlnd can have the same issue.
 
Newer threads
Replies
9
Views
4,998
Replies
9
Views
3,674
Replies
1
Views
2,392
Replies
9
Views
3,858
Similar threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top