MySQL optimization--skip-name-resolve

Source: Internet
Author: User
Tags ip number mutex

Article Source: http://blog.chinaunix.net/uid-9370128-id-1687475.html

The same IDC, IDC internal DNS server, the IP of each server to do a reverse resolution,
but not the internal network IP to do reverse resolution, so use Skip-name-resolve after using the intranet address to Mysqlslap request response half faster


Appendix: 7.5.6. How MySQL uses DNS

,--skip-networking involving parameter--skip-name-resolve,--Skip-host-cache

When a new client connects to Mysqld, Mysqld creates a new thread to process the request. The thread first checks whether the hostname is in the host name cache. If not, the thread attempts to resolve the host name:

· If the operating system supports thread-safe gethostbyaddr_r () and Gethostbyname_r () calls, threads use them to perform host name resolution.

· If the operating system does not support thread-safe calls, the thread locks a mutex and calls Gethostbyaddr () and gethostbyname (). In this case, no other thread can resolve the host name that is not in the host name cache until the 1th line threads unlocked the mutex.

You can use the--skip-name-resolve option to start mysqld to disable DNS host name lookups. However, in this case, you can only use the IP number in the authorization table in MySQL.

If you have a very slow DNS and many hosts, you can improve performance by disabling DNS lookups with--skip-name-resolve or by adding the Host_cache_size definition (default: 128) and recompiling the mysqld.

You can use the--skip-host-cache option to start the server to disable host name caching. To clear the host name cache, execute the FLUSH hosts statement or execute the mysqladmin flush-hosts command.

If you want to completely disable TCP/IP connections, start mysqld with the--skip-networking option.


Appendix. Grabbing data to be fully covered

when you connect to MySQL, you do a reverse address query to DNS
MySQL responds to clients only when the timeout fails
the MySQL process waiting to be parsed is the login state

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.