0
  • I have a multithreaded C application that connects to Database(DBaaS to be specific) using MySQL APIs.
  • It makes around 400+ connections using mysql_real_connect() function.
  • It takes around 10 minutes to make all the 400+ connections.

Can anyone suggest me how can I reduce the time taken for connection establishment? How can I achieve parallelism for the connections establishment?

himanshu
  • 175
  • 3
  • 12
  • 1
    _Gotta be the first question surely_ WHY So many connections, what could you possibly do with them al, seriously I am interested – RiggsFolly Aug 10 '20 at 14:30
  • Have you set `skip_name_resolve` in the my.cnf? – Bill Karwin Aug 10 '20 at 14:44
  • @RiggsFolly I am trying to find out the max performance using my C application and i have observed that performance does not increase after these connections so decided to keep these many connections. – himanshu Aug 10 '20 at 15:08
  • @BillKarwin can you please elaborate on the purpose of skip_name_resolve? – himanshu Aug 10 '20 at 15:09
  • https://www.percona.com/blog/2008/05/31/dns-achilles-heel-mysql-installation/ – Bill Karwin Aug 10 '20 at 15:12
  • MySQL Server attempts to do a reverse DNS lookup on the client's hostname when you connect. If MySQL is relying on a slow DNS server, this can make it a lot slower to connect. The fix is to tell MySQL Server not to do DNS lookups for client connections, but then you must use only IP addresses in GRANT statements, not hostnames. – Bill Karwin Aug 10 '20 at 15:14
  • @BillKarwin I don't think I can actually do this, because in my case i'm using database as a service and I am provided with a connection string and not the IP address. – himanshu Aug 10 '20 at 15:23
  • It's the GRANT on the server that must use the IP address, not your connection string. But yeah, if you aren't the administrator of the MySQL Server instance, you can't change this setting. – Bill Karwin Aug 10 '20 at 15:58
  • @BillKarwin I am sorry, I thought of it as the other way around. So Can i say there is DNS lookup from both ends, from client's end(as i'm using connection-string) as well as server's end(reverse DNS lookup)? – himanshu Aug 11 '20 at 04:57
  • Yes, that's correct. To read more about this: https://dev.mysql.com/doc/refman/8.0/en/host-cache.html – Bill Karwin Aug 11 '20 at 13:46

0 Answers0