39

I am novice in GCP stack so I am so confused about amount GCP technologies for storing data:

https://cloud.google.com/products/storage

Although google cloud spanner is not mentioned in the article above I know that it is exist and iti is used for data storage: https://cloud.google.com/spanner

From my current view I don't see any significant difference between cloud sql(with postgres under the hood) and cloud spanner. I found that it has a bit different syntax but it doesn't answer when I should prefer this techology to spring cloud sql.

Could you please explain it ?

P.S.

I consider spring cloud sql as a traditional database with automatic replication and horizontal scalability managed by google.

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

4 Answers4

48

There is not a big difference between them in terms on what they do (storing data in tables). The difference is how they handle the data in a small and big scale

Cloud Spanner is used when you need to handle massive amounts of data with an elevated level of consistency and with a big amount of data handling (+100,000 reads/write per second). Spanner gives much better scalability and better SLOs.

On the other hand, Spanner is also much more expensive than Cloud SQL.

If you just want to store some data of your customer in a cheap way but still don't want to face server configuration Cloud SQL is the right choice.

If you are planning to create a big product or if you want to be ready for a huge increase in users for your application (viral games/applications) Spanner is the right product.

You can find detailed information about Cloud Spanner in this official paper

Soumitri Pattnaik
  • 3,246
  • 4
  • 24
  • 42
Chris32
  • 4,716
  • 2
  • 18
  • 30
  • 1
    could you explain what is SLO ? – gstackoverflow Feb 26 '20 at 11:47
  • 2
    [SLO (Service-Level Objective)](https://cloud.google.com/blog/products/gcp/sre-fundamentals-slis-slas-and-slos) it's basically the reliability of a product. The SLA (Service Level Agreement) is the compromise of the minimun service that you can expect from a product. [For Spanner](https://cloud.google.com/spanner/sla) is >= 99.999% montlhy. [For Cloud SQL](https://cloud.google.com/sql/sla) is > 99.95% Montlhy – Chris32 Feb 26 '20 at 11:53
  • Could you explain phrase "handle the data in a small and big scale" ? – gstackoverflow Feb 27 '20 at 16:45
  • What I mean is that Cloud SQL is intended for a much smaller amount of data and transactions than Spanner. The key when you are choosing between Spanner and Cloud SQL is Scalability, Reliability, and Price. If you go deeper into the small details you will find many difference i.e. Spanner requires 1 processing node for each 2TB of data. [Here](https://static.googleusercontent.com/media/research.google.com/en//archive/spanner-osdi2012.pdf) you can find a detailed paper describing the spanner in more deep – Chris32 Feb 27 '20 at 18:35
30

The main difference between Cloud Spanner and Cloud SQL is the horizontal scalability + global availability of data over 10TB.

Spanner isn’t for generic SQL needs, Spanner is best used for massive-scale opportunities. 1000s of writes per second, globally. 10,000s - 100,000s of reads per second, globally.

Above volume is extremely difficult to achieve with NORMAL SQL / MySQL without doing complex sharding of the database. Spanner deals with all this AND allows ACID updates (which is basically impossible with sharded databases). They accomplish this with super-accurate clocks to manage conflicts.

In short, Spanner is not for CRM databases, it is more for supermassive global data within an organisation. And since Spanner is a bit expensive (compared to cloud SQL), the project should be large enough to justify the additional cost of Spanner.

You can also follow this discussion on Reddit (a good one!): https://www.reddit.com/r/googlecloud/comments/93bxf6/cloud_spanner_vs_cloud_sql/e3cof2r/

Jofre
  • 3,718
  • 1
  • 23
  • 31
gruby
  • 900
  • 6
  • 13
5

Previous answers are correct, the main advantages of Spanner are scalability and availability. While you can scale with Cloud SQL, there is an upper bound to write throughput unless you shard -- which, depending on your use case, can be a major challenge. Dealing with sharded SQL was the big problem that Spanner solved within Google.

Ozan Bellik
  • 483
  • 2
  • 6
2

I would add to the previous answers that Cloud SQL provides managed instances of MySQL or PostgreSQL or SQL Server, with the corresponding support for SQL. If you're migrating from a MySQL database in a different location, not having to change your queries can be a huge plus.

Spanner has its own SQL dialect, although recently support for a subset of the PostgreSQL dialect was added.

Paul
  • 1,939
  • 1
  • 18
  • 27