I have a Java /Vert.x web application that I’ve deployed to Cloud Run. I wanted to connect it to a database, so Cloud SQL seemed the obvious choice. But after trying, I’m wondering if it’s really feasible to connect a modern Java web application from Cloud Run to Cloud SQL.
By “modern Java web application”, I mean one leveraging the event-loop paradigm as opposed to the traditional thread-per-request model. This means that we want to leverage non-blocking APIs for IO operations such as database access.
However, Cloud SQL requires connections from Cloud Run using a UNIX socket, rather than via a standard JDBC address. Unfortunately, there are very few JDBC drivers/connection pools that support connectivity via UNIX sockets (to my knowledge, Hikari CP is the only option). Importantly, there are no non-blocking drivers that support socket connection (that I’ve found).
So as far as I can tell, my options are:
Am I missing something? It seems odd that GCP would preclude such a large swath of applications, so I’m guessing that I might be.
Hello,
As of right now, I could not find any official supported solution so it seems that you would have to pick one of your own options. However, you can check out this github link, as it seems there may be plans to integrate Cloud SQL with r2dbc. You can also officially create a feature request for Cloud SQL as well as for Cloud Run If you would like to see TCP connection support.