Overview of Google Cloud Spanner: Fully managed relational database with unlimited scale

  1. Home
  2. Google
  3. Overview of Google Cloud Spanner: Fully managed relational database with unlimited scale

Google Cloud Spanner is a fully managed relational database with limitless scalability, robust consistency, and up to 99.999 percent availability, giving all the benefits of relational semantics and SQL with an unbounded scale. This service can begin at any size and scale up or down as your needs change. Is this the reason this service is so popular among major corporations? Join us on this blog to find out the solution to this. We’ll go over all of the major features of Cloud Spanner as well as how to get started with it. So, let’s begin!

What is Google Cloud Spanner?

Google Cloud Spanner is a fully managed relational database with high availability, zero planned downtime, and the flexibility to change schemas remotely. This service provides high-performance transactions across regions and continents with a high level of consistency. It will also place a strong innovation, with features like autonomous sharding completely eliminating the need for manual work. Further, this comes with various benefits:

  • First and foremost, it isa globally distributed, ACID-compliant database manages replication, sharding, and transaction processing automatically, allowing you to grow swiftly to match any use pattern and assure product success.
  • Then, Cloud Spanner is based on Google’s dedicated network and has been combat tested by billions of people who utilise Google services. For scheduled maintenance and schema updates, it provides up to 99.999 percent availability with zero downtime.
  • Lastly, operating databases exist for IT administrators and DBAs. Creating or growing a globally replicated database now takes just a few clicks with Cloud Spanner, lowering your database maintenance costs.
Use cases:

A. Enterprise applications: Google Cloud Spanner can be used for large-scale enterprise applications that require high throughput, low latency, and global consistency. For example, it can be used for financial trading systems, supply chain management, customer relationship management, and online transaction processing.

B. Financial services: Google Cloud Spanner is a good fit for financial services that require real-time data processing and analysis, such as trading platforms, risk management systems, and fraud detection systems. It also provides strong security and compliance capabilities, which are essential for financial institutions.

C. Gaming and e-commerce: Google Cloud Spanner can be used for gaming and e-commerce applications that require high availability, low latency, and global consistency. It can handle large volumes of transactions and provide a seamless user experience across different regions. For example, it can be used for online marketplaces, inventory management systems, and real-time bidding platforms.

D. Healthcare and life sciences: Google Cloud Spanner is also suitable for healthcare and life sciences applications that require high availability and reliability, as well as compliance with regulatory requirements. It can be used for electronic medical records, clinical trials management, and genomic data processing. Its global consistency feature allows for easy collaboration and sharing of data across different locations.

Features of Cloud Spanner

1. Relational database, built for scale
  • Schemas, SQL queries, and ACID transactions—everything you’d expect from a relational database—are battle-tested and ready to grow internationally.
2. Availability
  • For multi-regional instances, Cloud Spanner guarantees industry-leading 99.999 percent availability—10x less downtime than four nines—as well as transparent, synchronous replication across the region and multi-region setups.
3. Automatic sharding
  • Cloud Spanner improves performance by sharding data based on the number of requests and the amount of the data. As a consequence, you can focus on growing your business rather than worrying about how to extend your database.
4. Strong transactional consistency
  • Cloud Spanner is built with the goal of providing industry-leading external consistency without sacrificing scalability or availability.
5. PostgreSQL interface (Preview)
  • Combine Spanner’s scalability and dependability with PostgreSQL’s familiarity and mobility. Use the skills and technologies that your teams are already familiar with to future-proof your investment and give yourself peace of mind.
6. Regional and multi-regional configurations
  • Spanner-powered apps can read and write up-to-date, globally consistent data no matter where your users are. Furthermore, when you use a multi-region instance, your database is protected against regional failure and has an industry-leading availability.
7. Federated queries with BigQuery
  • Query data from BigQuery in Spanner in real-time without transferring or copying it, bridging the gap between operational and analytical data and providing a single data life cycle.
8. Built on the Google Cloud network
  • Cloud Spanner is built on Google’s dedicated network, which offers low latency, security, and dependability to customers all around the world.
9. Enterprise-grade security and controls
  • CMEKs (customer-managed encryption keys), data-layer encryption, IAM integration for access and controls, and extensive audit logging are all available. VPC-SC, Access Transparency, and Access Approval are all supported.
cloud leader exam
10. Backup and Restore, point-in-time recovery (PITR)
  • Back up your database to save a consistent copy of your data and restore it whenever you need it. PITR offers continuous data protection and the capacity to retrieve data down to the microsecond level.
11. Rich application and tool support
  • Native client libraries for Java/JDBC, Go, Python, C#, Node.js, PHP, Ruby, and C++, as well as the most popular ORMs, such as Hibernate and Entity Framework, meet development teams where they are.
12. Real-time change data capture and replication (Preview)

With Datastream, you can safely and quickly synchronize data across heterogeneous databases, storage systems, and applications. Deliver change streams from Oracle and MySQL databases to Spanner in a seamless manner for up-to-date data.

Beginning with Google Cloud Spanner

This section demonstrates how to use the Google Cloud Console to conduct basic operations in Cloud Spanner. In this, you’ll learn the process of:

  • Creating a Cloud Spanner instance, database, and table.
  • Adding a schema.
  • Inserting and editing data.
  • Running a query.
1. Create an instance

When you initially start using Cloud Spanner, you’ll need to establish an instance, which is a resource allocation for Cloud Spanner databases in that instance.

  • Firstly, in the cloud console, go to the Cloud Spanner Instances page.
  • Secondly, click Create instance.
  • Thirdly, enter Test Instance, for the instance name.
  • Then, enter test-instance, for the instance ID.
  • Next, utilize Regional configuration.
  • Now, from the drop-down menu select any regional configuration.
    • The geographic location where your instances are stored and replicated is determined by your instance settings.
  • After that, use the default compute capacity of 1000 processing units.
    • Your instance creation page now looks like this:
Screenshot of the instance creation window
Image Source: Google Cloud
  • Lastly, click Create.
2. Creating a database
  • Firstly, in the cloud console, go to the Cloud Spanner Instances page.
  • Secondly, select the instance of the Test Instance.
  • Thirdly, select Create database.
  • Next, enter example-db as the database name.
    • This is how your database creation page now looks:
Screenshot of the database creation window
Image Source: Google Cloud
  • Then, choose a database dialect.
  • Next, leave the Define your schema text area blank for now if you choose Google Standard SQL. In the following phase of this quickstart, you’ll define your schema.
  • Lastly, select Create.
    • The Overview page for the database you created appears in the Cloud Console.
3. Creating a schema for your database
  • Firstly, click Create table at the top of the list of tables on the example-db Overview page.
  • The Write DDL Statements page appears in the Cloud Console.
  • Enter:
Google Cloud Spanner
Image Source: Google Cloud
  • Lastly, click Submit.
  • The Cloud Console returns to the Overview page of example-db and displays that Schema modifications are in progress.
4. Inserting data
  • Firstly, click the Singers table in the list of tables on the Overview page of example-db.
  • The Schema page for the Singers table is displayed in the Cloud Console.
  • Secondly, click Data in the side menu to see the Data page for the Singers table.
  • Thirdly, click Insert.
    • The Singers table’s Query page is displayed in the Cloud Console, with a new query tab containing the template. You alter the INSERT and SELECT commands to insert a record in the Singers table and observe the result:
Google Cloud Spanner
Image Source: Google Cloud
  • After that, edit the VALUES clause in the INSERT statement and the WHERE clause in the SELECT statement:
query
Image Source: Google Cloud
  • Next, click Run.
    • The statements are executed by Cloud Spanner. When you’re done, the Results tab shows that the first statement added one row to the database and offers a link to the table’s data.
  • Then, click the table link on the Results tab. One row has been added to the Singers table:
Screenshot of Singers table data with one row
Image Source: Google Cloud
  • Next, to add another row, click Insert.
    • You can see the Singers table’s Query page again in the Cloud Console, with a new query tab containing the identical template INSERT and SELECT queries.
  • Edit the VALUES clause in the INSERT statement and the WHERE clause in the SELECT statement:
Google Cloud Spanner
Image Source: Google Cloud
  • Now, click Run button.
    • The Results tab shows that the first statement inserted one row after Cloud Spanner performs the statements.
  • Lastly, select the table from the drop-down menu. Two rows in the Singers table:
Screenshot of Singers table data with two rows
Image Source: Google Cloud
5. Editing data
  • Firstly, check the box next to the row with the primary key value of 3 on the Singers table’s Data page, then click Edit.
    • The Query page in the Cloud Console now has a new tab with editable template UPDATE and SELECT statements. It’s worth noting that both statements’ WHERE clauses specify that the row to update is the one with the primary key value of 3.
query
Image Source: Google Cloud
  • Secondly, to update only the birth date, modify the SET clause in the UPDATE statement:
cloud spanner
Image Source: Google Cloud
  • Thirdly, press the Run button.
  • The statements are executed by Cloud Spanner. When you’re done, the Results tab shows that the first statement modified one row and gives you a link to the table’s data.
  • Then, click the table link on the Results tab.
    • The birth date now has a value in the updated row.
Screenshot of Singers table data with an updated row
Image Source: Google Cloud

Deleting data

  • Firstly, check the box next to the record with 2 in the first column in the Singers table’s Data page, then click Delete.
  • Then, click Confirm in the resulting dialogue box.
6. Running a query
  • Firstly, to access example-Query db’s page, go to the Overview page and choose Query on the side menu.
  • Secondly, to make a new inquiry tab, click New tab. Then type in the following query:

Google Standard SQL

SELECT * FROM Singers;

  • Click Run.
7. Cleaning up

Delete the database and instance you created to avoid extra costs to your Cloud Billing account.

Deleting the database

  • Firstly, in the Google Cloud Console, go to the Cloud Spanner Instances page.
  • Secondly, select Test Instance.
  • Thirdly, select example-db.
  • Then, DELETE DATABASE from the Database Details page.
  • Lastly, click Delete once you’ve confirmed you want to delete the database.

Deleting the instance

When an instance is deleted, any databases created in that instance are also deleted.

  • Firstly, in the Google Cloud Console, go to the Cloud Spanner Instances page.
  • Secondly, select Test Instance.
  • Then, click DELETE INSTANCE.
  • Lastly, click delete once you’ve confirmed you want to delete the instance.

Cloud Spanner Pricing

Cloud Spanner’s pricing is simple and predictable. Only the number of nodes in your instance, the quantity of storage required by your tables and secondary indexes (not pre-provisioned), and the amount of network bandwidth consumed are charged. However, you will be charged for the following when you utilize Cloud Spanner:

1. The amount of your instance’s computing capability.
  • Over time, Cloud Spanner maintains track of an instance’s computing capacity (measured in processing units or nodes). The number of nodes multiplied by the hourly fee is what you’ll be paying for.
  • Secondly, this value may be a fraction since an instance’s compute capacity might be less than 1 node (1000 processing units). For example, 1.2 node hours would be paid for a 200 processing unit instance that lasted for 6 hours (200 processing units x 6 hours x 1000 processing units per node).
  • Thirdly, you will be charged for a minimum of one hour of compute capacity that you provide. Moreover, you will be paid for one hour even if you temporarily scale up your instance for only 30 minutes.
  • Lastly, after the one-hour minimum, compute capacity billing is prorated. If you create a 5-node instance at 1:00 p.m. and subsequently delete one node at 2:01 p.m. (more than an hour later), the 5th node gets billed for 61 minutes.
2. The amount of storage that your databases use.

Cloud Spanner charges you based on the monthly price multiplied by the average amount of data in your Cloud Spanner databases over a month, including tables, secondary indexes, and metadata.

3. The amount of storage that your backups use.

Cloud Spanner bills you for the monthly subscription multiplied by the average amount of storage utilized by your Cloud Spanner backups over a month.

4. The amount of network bandwidth used.

As indicated here, bandwidth costs apply to some forms of network egress traffic, such as application reads of Cloud Spanner databases. Cloud Spanner replication and network ingress traffic are free of charge in terms of bandwidth.

Final Words

Above we have gone through the core areas of Google Cloud Spanner service by understanding its uses, features, pricing, and steps to begin with this service. As we already know Google Cloud Spanner is a manageable relational database with limitless scalability, robust consistency, and up to 99.999 percent availability, giving all the benefits of relational semantics and SQL with an unbounded scale. And, as a result, this service has gained the trust of many top organizations such as Niantic, LL bean, ShareChat, and more. So, if you want to start using this service then, just go through the details, take help from Google documentation, match your requirements, and start using Cloud Spanner.

cloud leader practice tests
Menu