Is it feasible to connect modern Java webapps (e.g. Vert.x) from Cloud Run to Cloud SQL?

27 views
Skip to first unread message

Dave Taubler

unread,
Mar 30, 2020, 9:06:31 AM3/30/20
to Google Cloud SQL discuss

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:

  • Use Hikari and block the main thread (not an option)
  • Use Hikari and create a ham-handed approach whereby the entire data access layer takes place in another thread
  • Use Hikari, and spend a lot of time creating an entirely new non-blocking driver to use with it


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.

David (Cloud Platform Support)

unread,
Mar 31, 2020, 3:46:22 PM3/31/20
to Google Cloud SQL discuss

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.

Dave Taubler

unread,
Mar 31, 2020, 5:24:19 PM3/31/20
to Google Cloud SQL discuss
Hi David,

Thanks I appreciate the response. It's good to know at least that I'm not missing something obvious (and that other folks are interested in this topic, as per the github link you provided).
Reply all
Reply to author
Forward
0 new messages