In this video, explore the GCP Cloud SQL product offering and learn key terms. It's beneficial to first understand the pros and cons of using Cloud SQL in your Java Spring application to make an educated decision as to whether it makes sense for you and your application.
- [Instructor] The objective of this video is to understand what Spring Data Cloud SQL is. To do that, let's start by understanding where it sits in the Spring project hierarchy. Spring provides a variety of projects to applications like Spring Data, REST, HATEOAS and so on. Within Spring Projects or a group of projects called Spring Cloud, that support cloud capabilities from popular cloud providers like Azure, Amazon Web Services, Google Cloud Platform and more. For this course, we are particularly interested in the Spring Cloud GCP projects, which makes the Spring framework a first class citizen of Google Cloud platform. This Spring Cloud GCP project provides a variety of dependencies for core features in GCP, including pubsub, storage, SQL and more. Within Spring Cloud GCP, we have Spring Data Cloud SQL, which is a group of particular dependencies that provides support for interacting with GCP Cloud SQL. These dependencies are the focus of this course. Which specific Spring Data Cloud SQL dependency we use depends on the SQL database we would like to use. The database used for this course is PostgreSQL. In summary, Spring Data Cloud SQL is a dependency we can pull into any Spring app to interact with our Cloud SQL database on the Google Cloud Platform. Now that we know what Spring Data Cloud SQL is why should we consider using Cloud SQL in conjunction with this dependency? As with most cloud providers, using GCP Cloud SQL shifts the maintenance of a database to GCP, which I find particularly appealing. Now, any engineer can work with the database without being a database expert. Another pro is that there is a significant amount of support, a large community, and ample documentation making use of Cloud SQL easier. This may differ from Cloud provider to Cloud provider. Next, I find it easy to integrate with Cloud SQL with my Java Spring app, which we'll see later in this course. This is easy due to the use of Spring Data Cloud SQL and Spring Data Java persistence API. The last pro I am going to cover and know that there are probably many more, is cost. With GCP, you can pay for what you use. You can be charged by the hour, depending on CPU, memory, storage, and networking usage. Now over to cons. The first one I want to mention is cost. Yes, it is both a pro and a con. For an average developer, working on a side project, they will have to be mindful of their budget with GCP. For instance, the database instance we will create during this course can cost about $40 USD a month, when in frequently use. For a company, this is nothing. For me, I regret it leaving the instance running for a side project that was not making any revenue. Having to depend on Google and their infrastructure is the last con I will cover. With your own hosted database, you're responsible for its uptime and if any issues were to arise, the resolution of those problems is up to you. With using Cloud SQL, depending on the issue, resolving the problem for you may look like submitting a ticket to Google and simply waiting. If this is a problem, then this approach is not for you. There are other pros and cons than those listed here, but these were the ones I wanted to highlight. How should we use Spring Data Cloud SQL within application? First, we need to create a project in a database instance in GCP with the desired configurations. After that, we will update our application configurations to communicate with the new GCP Cloud SQL instance, using the Spring Data Cloud SQL library.