UDS local connections are much faster and are more secure than TCP/UDP ones currently used by Lucee. Everything else uses them (databases, reverse proxys, webservers, PHP, etc.)
Since Java 17 it is available for via NIO connections as well.
Please make it available/integrated into Lucee as well, at least for databases (MySQL, Postgres, MariaDB) and for connecting with the webserver/reverse proxy, instead of AJP.
2 Likes
Update: managed to create an UnixDdomainSocket in Tomcat (v9.0.71), it’s pretty straight forward, in the server.xml :
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol" unixDomainSocketPath="/tmp/lshttpd/cfm.sock" unixDomainSocketPathPermissions="rwxrwxrwx" connectionTimeout="20000" maxThreads="100" URIEncoding="UTF-8" />
Success: Tomcat actually creates (and manages) the cfm.sock file above, except it is always empty (0 bytes)
Configuration in the LiteSpeed WebAdmin Console is also straight forward, basically copied the SAPI connector settings for PHP - except not set the socket to be created by LS, as Tomcat already does that:
Name: tomcatUDS
Address: UDS://tmp/lshttpd/cfm.sock
And when I restart everything I get a 503 error - service unavailable. No other errors in the logs, Tomcat establishes the socket successfully.
All I can deduce is that there is a need to also have a UDS connection between Tomcat & Lucee, not just the webserver/revproxy (Litespeed in this case) and Tomcat. Something like the DB connectors that need to be added in the Lucee Admin console in order to connect them with Lucee? Any suggestion is appreciated.
UPDATE: managed to make Tomcat UDS socket work… sorta’
Tomcat server.xml settings:
<Connector protocol="AJP/1.3" port="8009" secretRequired="false" address="127.0.0.1" allowedRequestAttributesPattern=".*" scheme="http" URIEncoding="UTF-8" />
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol" unixDomainSocketPath="/tmp/lshttpd/cfm.sock" connectionTimeout="20000" maxThreads="100" useSendfile="true" URIEncoding="UTF-8" />
In the reverse proxy server (OpenLiteSpeed) I tried all variants, but only one worked: adding the Tomcat UDS socket as a Web Server. While Tomcat AJP works connected as a Servlet Engine, UDS fails if you try to connect it this way. (also fails as a CGI app)
Comparison: There is no significant difference in speed between connecting Tomcat via AJP servlet vs UDS webserver in the case of CMF pages, would need to test at much greater loads, meaning thousands of concurrent requests to Lucee.
Still, there are further benefits in regard to security for using UDS instead of AJP, from what I read.
TL;DR: Further testing is required in comparing the two, the main idea being that Lucee already has UDS support, as it seems.
2 Likes