What-is-a-Cloud-Spanner

What is a Cloud Spanner?

Google Cloud Spanner is one of great databases offered by Google for refining the organizational application functionalities. Organizations believe that a database is somehow an integral part of almost all applications. And, understandably, proficient apps need high-end databases to operate seamlessly. Cloud Spanner has all enterprise-grade attributes in it to make it a consistent database service by Cloud. The major benefit of using this database service by Google is that it allows combining the structure of a relational database with the non-relational horizontal scale.

It has a unique design that extends its services to support the transaction processing aspects over online medium on a global basis. Apart from that, it also supports SQL semantics and maintains the consistency of transactions. Google Cloud Spanner offers its support for the distributed-SQL queries and also promotes restart of the queries in case of failures. Google Cloud Spanner was first available to the Cloud customers in the month of May 2017. At first, it began offering service as the key-value NoSQL store. But over time, a strong schema has been developed within it, and a SQL processor was introduced as well.

Interested in Google Cloud Certifications ? Check out Whizlabs online courses and practice tests here!

Cloud Spanner has many service facilities that are yet to unveil. But before you can go ahead and get your hands-on experience with Cloud Spanner, it is important for you to get an idea of its detailed concepts. And this article will help you attain all of it!

Working Overview of Cloud Spanner

Within Cloud Spanner, a node is measured as a compute! The node servers are responsible for serving the read & write transactions and the requests without any storing of data. Each of the nodes and the database storage is then replicated across different zones within the region. The nodes will then be used or held responsible for reading or writing to the dedicated storage within their specific zone. 

Want to learn basics of Google Cloud Platform? Read Introduction To Google Cloud Platform now!

All of the data is then stored over the Colossus-distributed-replicated file system. And this brings in a lot of advantages when you intend to implement redistribution of the loads. It is because no data is linked to the individual nodes, for which, if a zone or node fails, the database won’t lose its existence and will remain available. The remaining nodes will be serving the database without any manual efforts. The availability is maintained on an automated note!

Cloud Spanner is all about operating upon transactions! A transaction over Cloud Spanner is a collective set of reads & writes that has the potential to execute automatically, within a single point of time. The execution can be across the tables, rows, and columns within the database. There are three types of transaction modes that are supported by Cloud Spanner, which includes:

1. Read-Only

This type offers consistency over different reads but doesn’t permit the writes. The read-only transactions can be accessed or read at the timestamps that were created in the past. There is no necessity of committing the read-only transactions, and there is no need for taking locks over it.

2. Locking Read-Write

It is the only transaction type that offers support for the writing of data within the Cloud Spanner. The locking transactions reply upon two-phase commit and pessimistic locking potential. The locking read & write transaction may abort or decline the transaction by forcing the application to try it again.

3. Partitioned DML

It is the type of transaction that supports the execution of a DML (Data Manipulation Language) statement in the form of Partitioned DML. It is brought into action for bulk updates/deletes. Moreover, it is preferable for backfilling and periodic clean-up.

Cloud Spanner consists of two types of reads, which include Strong Reads and Stale Reads. Strong reads are used when there is a need for reading the absolute value. Cloud Spanner API first identifies the split and then considers routing of the request to the replicas, which is usually the same zone as per the client. 

The replica then intends to process the request to the leader for getting permission to read the data. It also demands the latest transaction timestamp. If the row has all of the data in it and is up-to-date, then the result will be returned. But if the row is not up-to-date, then it has to wait for the leader to refresh the updates over the row. On completion, the response is then sent back to the client.

Read more on What is BigQuery!

Stale Reads, on the other hand, are useful when there is a low-latency situation. If this amount of latency is crucial, then some staleness of data can be tolerated. While executing over the Stale reads, the client doesn’t intend to request the latest data version. It just demands that the data should be the most recent one. It can work upon the data that is updated just seconds prior to stale read integration. 

In case the staleness factor is a minimum of 15 seconds, then the replica has the clearance to return the data to client without even sending a query to the leader. It is because the internal state of the data will count it as up-to-date to the best means possible. Each of the read requests within Stale read type demanded no row locking. Hence, this potential of nodes responding to reads makes Cloud Spanner a reliable and fast database,

Scenarios that Demand & Prohibit the Use of Locking Read- Write Transactions

The read-write transactions over Cloud Spanner intend to put up a set of reads & writes atomically over the single logical point. A timestamp is selected at the point where there is an execution for the read-write transaction. And this timestamp should match the time over the wall clock, and the serialization order must also match the order as that of the timestamp. 

Read-write transactions are highly preferable for their ACID properties over relational databases. Cloud Spanner offers stronger and efficient transactions in comparison to the traditional ACID attributes. You can check out the semantics section over the official documentation of Google to get a clear idea!

Read more about What is Cloud SQL!

As there is only one transaction mode that allows both reading and writing of data within the Spanner, most of the organizations prefer using it on priority. But there are certain scenarios that you must keep in mind to realize when to use and when not to use the locking read-write transaction.

To begin with, here are the scenarios when you can use locking read-write transactions:

  • When you implement a write-over data, that is, depending upon the results of your reads, then both read & write should take place within the same transaction.
  • In case you are going ahead with more than one writes, then you are demanded to be committed to atomic means. And all of these writes should be done over the same transaction.
  • If your implementation of multiple writes is depending upon the results obtained by the reads, even then, you have to do the reads & writes over the same transaction. You need to carry it out, even if the write(s) do not execute within it.

Apart from these acceptable scenarios, you should also understand the avoidable area where you should not use the locking read-write transaction. The only such scenario is when you are not dealing with any writes but only reads. In such cases, you can always use the read-only mode or single read method, which does not have the attribute of locking, like the read-write transactions.

Pricing of Google Cloud Spanner

Cloud Spanner, used for offering an integral database to organizations, is picking up the pace. And Google has defined an acceptable range of pricing for this dedicated service. There are different factors based upon which the pricing of Cloud Spanner service is decided. Here are the factors upon which you are charged while you implement the Cloud Spanner service:

  • Cloud Spanner works upon keeping track of compute capacity for an instance that is measured in terms of nodes and processing units. You will be billed upon the number of nodes by multiplying with the hourly rates. In precise, the compute capacity amount within the instance is the prime billing factor. As the regional configuration is considered, the lowest billing charge per hour is $0.90/node. For multi-region, you need to pay $3.00/node/hour.
  • The storage that you preferably use for your database is also an integral billing factor. These charges are mostly on a monthly basis. You will be charged a minimum of $0.30/GB per month. The multi-region pricing for storage is $0.50/GB/month.
  • The backup storage consumption is also a billing factor in deciding your overall Cloud Spanner pricing. For regional configurations, you need to pay $0.10/GB per month, whereas, for multi-region configurations, you will have to pay $0.30/GB per month.
  • The amount of network bandwidth used for the process is also a pricing factor. You only have to pay for egress between the regions of US, at $0.01/GB. Apart from that, you need to make the standard payment for inter-continental egress.

You can either prefer to use the pricing calculator of Google Cloud, to get an estimated cost for using Cloud Spanner, tailored to your specification. If not that, you can head out to the pricing page to check up on the pricing of different factors, depending upon regional and multi-regional configurations. Therefore, head out to this pricing documentation and scroll half a way down to get the pricing information.

Global Consistency offered by Cloud Spanner

TrueTime is a feature within Cloud Spanner that makes it work ideally. TrueTime is an ideal way of synchronizing the clocks of all the machines that are situated across diverse data centers. The entire system then makes use of an ideal combination that involves atomic clocks and GPS that intends to correct the failure modes of one another. It provided an accurate time source for the Google applications, but different Clock drifts can be achieved over different machines.

Every 30 seconds, there is a sync in between the server clock and reference clock. The difference between the time in both these clocks can be 2ms at maximum. In case there is any time drift, then the graph will see peaks until the sync stabilizes it. 2ms is considered as a very long distortion in terms of computing. Therefore, TrueTime counts it as uncertain when the time signal is considered. But in this way, TrueTime makes an approach to maintain the global consistency on priority with Cloud Spanner.

Key Conceptual Features of Cloud Spanner

As of now, you have understood how Cloud Spanner works. But now, it is important for you to know why Cloud Spanner used for organizations and enterprises. It is mostly because of its features and service efficacies. Therefore, here are some of the conceptual features that Cloud Spanner has to offer:

1. Relational Database

Cloud Spanner is much like the relational database that consists of schemas, ACID transactions, SQL queries, and everything that you can expect from any relational database. It is tested and is ready to be scaled on global levels. 

2. Automatic Sharding

Cloud Spanner works upon optimizing the performance but automatic-sharding of the data, based upon request load & size of data. Hence, it automates the database scaling attributes and allows you to implement focus upon enhancing your business outcomes. 

3. Transactional Consistency

The major purpose of building Cloud Spanner and making it available to organizations was to offer consistency. Hence, this purposeful built offers strong, external, and global transactional consistency. 

4. Enterprise-Level Security

Cloud Spanner comes with data-layer encryption, IAM integration, and Customer-managed Encryption Keys (CMEK), offering top-notch security to enterprise data. Apart from all of these, you also get comprehensive audit logging aspects for enhanced security of data. 

Bottom Line

Google Cloud Spanner offers multi-language support, as it has client libraries with language, C#, Go, C++, Node.js, Python, Ruby, and PHP. Not just that, but it also has JDBC drivers to ensure connectivity with third-party tools. Hence, Cloud Spanner is stating its proficiency in being flexible and reliable.

It allows you to synchronize the data across diverse databases, applications, and storage systems, with minimalistic latency. It has the potential to capture data in real-time and seek replication as well. So, if you are ready with all theoretical knowledge, then it is time to get your hands on the practical implementations.

About Girdharee Saran

Girdharee Saran has a glorious 13 years of experience transforming the way e-learning and SaaS start-ups approach digital marketing for their organisations. He has successfully chartered tangible results, which have proven beneficial. Working in the spaces of content marketing and SEO for a considerable amount of time, he is well conversant in his art. Having taken a deep interest in content and growth marketing, his urge to learn more is perpetual. His current role at Whizlabs as VP Marketing is about but not limited to driving SEO, conversion optimisation, marketing automation, link building and strategising result driven content.

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top