I've got Tomcat and MySQL on the same box and want them to talk using Unix sockets to save a bit of TCP/IP overhead.
The docs say that this is not possible:
"MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as Java does not support Unix Domain Sockets. Therefore, when MySQL Connector/J connects to MySQL, the security manager in MySQL server will use its grant tables to determine whether or not the connection should be allowed."
I can see that that allows a pure Java implementation, but does anyone know if support for Unix domain sockets is planned at all?
Mark Matthews 20 January 2004 20:10:30 [ permanent link ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Michael McTernan wrote:
Hi there,>
I've got Tomcat and MySQL on the same box and want them to talk using Unix> sockets to save a bit of TCP/IP overhead.>
The docs say that this is not possible:>
"MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as
Java does> not support Unix Domain Sockets. Therefore, when MySQL Connector/J connects> to MySQL, the security manager in MySQL server will use its grant tables to> determine whether or not the connection should be allowed.">
I can see that that allows a pure Java implementation, but does anyone
know> if support for Unix domain sockets is planned at all?
In the limited testing I've done, the JNI overhead makes Unix domain sockets _slower_ than TCP/IP, so if you're looking for a performance boost, you won't find it there.
Because Connector/J has pluggable socket factories, it would be relatively straightforward to take something like this:
Morten Norby Larsen 20 January 2004 20:59:59 [ permanent link ]
Just out of curiousity, as I know nothing about these low-level issues:
Would you actually gain anything from Unix sockets? If I understand correctly, using them would mean that you go through some kernel-level drivers (i.e., no physical network interface), which is of course a big advantage over calls across a TCP/IP layer on top of a some physical network.
However, I would guess that if you connect through 127.0.0.1 (which is what localhost normally maps to), then you should never get anywhere near a physical network layer, and so the overhead is only what the TCP/IP layer gives. The TCP/IP overhead shouldn't amount to that much, compared to the database's disk access, or am I totally wrong here? Your bytes are still routed through the kernel, just along a different (and probably slightly longer) path than if you used Unix Domain Sockets.
I would love any insight into these issues!
Thanks,
Morten
Mark Matthews wrote:
-----BEGIN PGP SIGNED MESSAGE-----> Hash: SHA1>
Michael McTernan wrote:>
Hi there,>>
I've got Tomcat and MySQL on the same box and want them to talk using Unix>>sockets to save a bit of TCP/IP overhead.>>
The docs say that this is not possible:>>
"MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as>
Java does>
not support Unix Domain Sockets. Therefore, when MySQL Connector/J>
connects>
to MySQL, the security manager in MySQL server will use its grant>
tables to>
determine whether or not the connection should be allowed.">>
I can see that that allows a pure Java implementation, but does anyone>
know>
if support for Unix domain sockets is planned at all?>
In the limited testing I've done, the JNI overhead makes Unix domain> sockets _slower_ than TCP/IP, so if you're looking for a performance> boost, you won't find it there.>
Because Connector/J has pluggable socket factories, it would be> relatively straightforward to take something like this:>
And implement com.mysql.jdbc.SocketFactory using the Unix domain support> in the package above to get the support for Unix domain you're looking for.>
Either that, or plead with Sun through the BugParade to add unix domain> socket support >
Regards,>
-Mark>
- --> Mr. Mark Matthews> MySQL AB, Software Development Manager, J2EE and Windows Platforms> Office: +1 708 557 2388> www.mysql.com>
For a connection from a client to a server running on the same host, if you connect using TCP/IP rather than a Unix socket file, performance is 7.5% slower. (If you connect to the hostname localhost, MySQL uses a socket file by default.)>>
Which I find rather extreme !
On Tue, 2004-01-20 at 18:59, Morten Norby Larsen wrote:> Just out of curiousity, as I know nothing about these low-level issues:>
Would you actually gain anything from Unix sockets? If I understand > correctly, using them would mean that you go through some kernel-level > drivers (i.e., no physical network interface), which is of course a big > advantage over calls across a TCP/IP layer on top of a some physical > network.>
However, I would guess that if you connect through 127.0.0.1 (which is > what localhost normally maps to), then you should never get anywhere > near a physical network layer, and so the overhead is only what the > TCP/IP layer gives. The TCP/IP overhead shouldn't amount to that much, > compared to the database's disk access, or am I totally wrong here? Your > bytes are still routed through the kernel, just along a different (and > probably slightly longer) path than if you used Unix Domain Sockets.>
I would love any insight into these issues!>
Thanks,>
Morten>
Mark Matthews wrote:>
-----BEGIN PGP SIGNED MESSAGE-----> > Hash: SHA1> >
Michael McTernan wrote:> >
Hi there,> >>
I've got Tomcat and MySQL on the same box and want them to talk using Unix> >>sockets to save a bit of TCP/IP overhead.> >>
The docs say that this is not possible:> >>
"MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as> >
Java does> >
not support Unix Domain Sockets. Therefore, when MySQL Connector/J> >
connects> >
to MySQL, the security manager in MySQL server will use its grant> >
tables to> >
determine whether or not the connection should be allowed."> >>
I can see that that allows a pure Java implementation, but does anyone> >
know> >
if support for Unix domain sockets is planned at all?> >
In the limited testing I've done, the JNI overhead makes Unix domain> > sockets _slower_ than TCP/IP, so if you're looking for a performance> > boost, you won't find it there.> >
Because Connector/J has pluggable socket factories, it would be> > relatively straightforward to take something like this:> >
And implement com.mysql.jdbc.SocketFactory using the Unix domain support> > in the package above to get the support for Unix domain you're looking for.> >
Either that, or plead with Sun through the BugParade to add unix domain> > socket support > >
Regards,> >
-Mark> >
- --> > Mr. Mark Matthews> > MySQL AB, Software Development Manager, J2EE and Windows Platforms> > Office: +1 708 557 2388> > www.mysql.com> >
Michael McTernan 20 January 2004 23:27:16 [ permanent link ]
Hi,
Sure, a localhost loopback connection shouldn't touch any physical device. But there are still a number of other things to happen I guess, you still have to go through TCP, IP and perhaps the routing tables... I'm not sure & it's a topic for a different forum ;)
"Unix sockets are faster than TCP/IP but can only be used when connecting to a server on the same computer. Unix sockets are used if you don't specify a hostname or if you specify the special hostname localhost."
So I guess someone measured a performance increase, probably using the benchmarks, which should be quite simple to do.
The TCP/IP overhead shouldn't amount to that much,> compared to the database's disk access, or am I totally wrong here?
Yes, the biggest bottleneck is always the first to be optimised, but after assembling and tweaking a RAID 5 array of 15000rpm disks I don't see that there is much more I can do there without spending more money. It would also be nice to not have the open socket, although I'm locking it to localhost only for security in any case.
Just out of curiousity, as I know nothing about these low-level issues:>
Would you actually gain anything from Unix sockets? If I understand> correctly, using them would mean that you go through some kernel-level> drivers (i.e., no physical network interface), which is of course a big> advantage over calls across a TCP/IP layer on top of a some physical> network.>
However, I would guess that if you connect through 127.0.0.1 (which is> what localhost normally maps to), then you should never get anywhere> near a physical network layer, and so the overhead is only what the> TCP/IP layer gives. The TCP/IP overhead shouldn't amount to that much,> compared to the database's disk access, or am I totally wrong here? Your> bytes are still routed through the kernel, just along a different (and> probably slightly longer) path than if you used Unix Domain Sockets.>
I would love any insight into these issues!>
Thanks,>
Morten>
Mark Matthews wrote:>
-----BEGIN PGP SIGNED MESSAGE-----> > Hash: SHA1> >
Michael McTernan wrote:> >
Hi there,> >>
I've got Tomcat and MySQL on the same box and want them to talk> using Unix> >>sockets to save a bit of TCP/IP overhead.> >>
The docs say that this is not possible:> >>
"MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as> >
Java does> >
not support Unix Domain Sockets. Therefore, when MySQL Connector/J> >
connects> >
to MySQL, the security manager in MySQL server will use its grant> >
tables to> >
determine whether or not the connection should be allowed."> >>
I can see that that allows a pure Java implementation, but does anyone> >
know> >
if support for Unix domain sockets is planned at all?> >
In the limited testing I've done, the JNI overhead makes Unix domain> > sockets _slower_ than TCP/IP, so if you're looking for a performance> > boost, you won't find it there.> >
Because Connector/J has pluggable socket factories, it would be> > relatively straightforward to take something like this:> >
And implement com.mysql.jdbc.SocketFactory using the Unix domain support> > in the package above to get the support for Unix domain you're> looking for.> >
Either that, or plead with Sun through the BugParade to add unix domain> > socket support > >
Regards,> >
-Mark> >
- --> > Mr. Mark Matthews> > MySQL AB, Software Development Manager, J2EE and Windows Platforms> > Office: +1 708 557 2388> > www.mysql.com> >
Would you actually gain anything from Unix sockets?
I was using a socket implementation from jlirc.sourceforge.net, with some small adaptions for Connector/J (see attachment).
Performance is slightly worse than TCP/IP. I have no exact figures, however.
A useful application for sockets could be a dedicated server that is not meant to be accessible through the network ("--skip-networking"). Also, you avoid conflicts with other processes running on the same TCP/IP port.
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .