Sunday, March 29, 2020

[google-cloud-sql-discuss] Is it feasible to connect modern Java webapps (e.g. Vert.x) from Cloud Run to Cloud SQL?

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.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/84a6ba20-7677-4dcb-98b3-9f2a9bfb9411%40googlegroups.com.

No comments:

Post a Comment