GCP Cloud Spanner

GCP Cloud Spanner is a fully managed, globally distributed, and horizontally scalable database service that offers strong consistency, high availability, and seamless scalability for modern applications.

By - Manish Kumar Barnwal
Updated on
-
October 12, 2023

Overview

What is GCP Cloud Spanner?

GCP Cloud Spanner uses a unique architecture that combines the benefits of traditional relational databases with the advantages of horizontally scalable NoSQL databases. It is a globally consistent and distributed database that automatically handles data sharding, replication, and failover without any manual intervention. Cloud Spanner's architecture relies on the TrueTime API, which provides a globally synchronized clock to ensure strong consistency and accurate timestamp ordering across regions.

When to use GCP Cloud Spanner?

GCP Cloud Spanner is an ideal choice for applications that require the following:

  • Global Reach: When your application needs to serve users across the globe with low-latency access and high availability.
Cloud Spanner, How does it work?, Pricing, Cost Optimization
Image Source: Online Banking architecture diagram
  • Strong Consistency: When maintaining strong consistency across distributed transactions is crucial for data integrity.
  • Scalability: When your application's workload may fluctuate significantly, and you need an auto-scaling solution to handle varying demands.
  • Relational Model: When your application relies on a relational data model, but you also need the scalability of a NoSQL database.

How does GCP Cloud Spanner work?

GCP Cloud Spanner is a cloud-native, horizontally scalable, and globally distributed database service provided by Google Cloud Platform (GCP). It is designed to meet the requirements of modern, globally distributed applications that demand high availability, strong consistency, and automatic scaling. Cloud Spanner is built on top of Google's infrastructure, utilizing Google's global network and advanced technologies to ensure low-latency access and seamless replication of data across regions.

Features & Advantages

Features of GCP Cloud Spanner

  1. Horizontal Scalability: Cloud Spanner can automatically distribute data across multiple nodes and regions, providing virtually limitless horizontal scaling.
  2. Strong Consistency: Cloud Spanner offers externally consistent reads and writes, ensuring that data is always up-to-date across regions.
  3. Global Replication: Data is automatically replicated across multiple regions to ensure high availability and data durability.
  4. Automatic Sharding: Cloud Spanner automatically shards data to distribute the workload and improve performance.
  5. SQL Support: Developers can use familiar SQL queries to interact with Cloud Spanner, making it easier to integrate with existing applications.
  6. ACID Transactions: Cloud Spanner supports ACID (Atomicity, Consistency, Isolation, Durability) transactions, ensuring data integrity in complex operations.
  7. NoSQL Features: While following a relational model, Cloud Spanner also offers NoSQL features like schema flexibility and horizontal scaling.

Advantages of GCP Cloud Spanner

  • Global Availability: With data automatically replicated across regions, Cloud Spanner provides global availability and fault tolerance.
  • High Performance: Cloud Spanner offers low-latency access to data, making it suitable for real-time applications.
  • Scalability: Cloud Spanner's horizontal scaling ensures that it can handle large-scale workloads and grow with the application's demands.
  • Fully Managed Service: As a fully managed service, Cloud Spanner takes care of tasks like backups, patches, and infrastructure maintenance, allowing developers to focus on building applications.
  • Seamless Integration: Cloud Spanner integrates with various GCP services like BigQuery, Dataflow, and App Engine, providing a complete ecosystem for data processing and analytics.
  • Strong Security: Cloud Spanner offers robust security features, including encryption at rest and in transit, IAM-based access control, and audit logs.

Pricing

GCP Cloud Spanner Pricing Factors

GCP Cloud Spanner is a paid service, and its pricing is based on several factors:

  1. Compute Capacity: You are charged for the amount of compute capacity (processing units or nodes) provisioned for your Cloud Spanner instance. The pricing varies based on the chosen configuration, and you can opt for on-demand pricing or commit to 1-year or 3-year committed use discounts for cost savings.
  2. Database Storage: Cloud Spanner charges you for the average amount of data stored in your Spanner databases, including tables, secondary indexes, and metadata. The pricing is based on the storage used over a one-month period.
  3. Backup Storage: You are billed for the storage used by your Cloud Spanner backups over a one-month period.
  4. Network Bandwidth: Some types of network egress traffic, such as application reads of Spanner databases, are subject to bandwidth charges. There are specific rates for egress between regions within the same continent.

Is GCP Cloud Spanner Free or Paid?

GCP Cloud Spanner is not available for free. It is a paid service, and you are billed based on your usage of compute capacity, database storage, backup storage, and network bandwidth.

GCP Cloud Spanner Pricing Tiers

Regarding pricing tiers, Cloud Spanner does not have explicit "tiers" like some other services. Instead, the pricing is based on the resources you provision and the amount of data you store. You can choose between different configurations, such as regional or multi-region setups, and you can also commit to long-term contracts for discounted pricing.

1. Compute Capacity Pricing: The pricing for compute capacity varies based on the instance's regional or multi-region configuration and whether you choose on-demand or committed use discounts.

Regional Configuration: Iowa (us-central1)

  • Hourly Cost per node (including all replications): $0.9
  • Monthly Cost per node with 1-year committed use discounts (including all replications): $0.72 per hour
  • Monthly Cost per node with 3-year committed use discounts (including all replications): $0.54 per hour

Multi-Region Configuration: North America 3 (nam3)

  • Hourly Cost per node (including all replications): $3
  • Monthly Cost per node with 1-year committed use discounts (including all replications): $2.4 per hour
  • Monthly Cost per node with 3-year committed use discounts (including all replications): $1.8 per hour

2. Database Storage Pricing: The pricing for database storage depends on the instance's regional or multi-region configuration.

Regional Configuration: Iowa (us-central1)

  • Hourly Cost per GB (including all replicas): $0.00041
  • Monthly Cost per GB (including all replicas): The monthly cost would be $0.00041 per GB * 24 hours * 30 days = $0.2952 per GB

Multi-Region Configuration: North America 3 (nam3)

  • Hourly Cost per GB (including all replicas): $0.00068
  • Monthly Cost per GB (including all replicas): The monthly cost would be $0.00068 per GB * 24 hours * 30 days = $0.4896 per GB

Database storage pricing for adding optional read-only replicas:

  • Cost per GB for each additional read-only replica: $0.00014 per hour
  • Monthly Cost per GB for each additional read-only replica: The monthly cost would be $0.00014 per GB * 24 hours * 30 days = $0.1008 per GB

As an example, let's say you create a custom instance configuration with 1000 GB of storage and add one read-only replica (us-east1) to the base multi-region instance configuration (nam7). Your total database storage cost would be as follows:

  • Base configuration nam7: $0.00068 per GB per hour * 1000 GB = $0.68 per hour
  • Additional read-only replica us-east1: $0.00014 per GB per hour * 1000 GB = $0.14 per hour

In total, your database storage cost for the custom instance configuration would be $0.82 per hour.

3. Backup Storage Pricing: The pricing for backup storage is based on the instance's regional or multi-region configuration.

Regional Configurations:

  • Hourly: $0.00014 per GB
  • Monthly: $0.1008 per GB

Multi-region Configurations:

  • Hourly: $0.00041 per GB
  • Monthly: $0.2952 per GB

4. Network Pricing: Ingress traffic is free, while egress traffic between regions within the same continent incurs a specific cost per GB.

  • Ingress: Free
  • Egress within the same region: Free
  • Egress between regions within the same continent (per GB): $0.01
  • Inter-continental egress: At Internet egress rate

5. Cloud Spanner Data Boost Pricing:

Data Boost provides on-demand, isolated compute resources for Spanner instances. It measures usage in Serverless Processing Units (SPU) on a per-second basis, with a 1-minute minimum charge. You only pay for actual SPU usage, and there are no fixed costs or resources to manage.

Pricing per SPU per hour:

Americas:

  • São Paulo (southamerica-east1): $0.00176

US Regions:

  • Iowa (us-central1): $0.00117
  • Northern Virginia (us-east4): $0.00129

Asia Pacific:

  • Tokyo (asia-northeast1): $0.00153
  • Mumbai (asia-south1): $0.00164

Europe:

  • Belgium (europe-west1): $0.00117
  • London (europe-west2): $0.00141
  • Frankfurt (europe-west3): $0.00141

Cost Optimization

How to Optimize GCP Cloud Spanner Costs?

To optimize GCP Cloud Spanner costs, consider the following strategies:

  1. Choose the Right Node Configuration: Select an appropriate node configuration based on your application's workload and performance requirements. Provisioned capacity can be cost-effective for stable workloads, while on-demand is more flexible for fluctuating workloads.
  2. Effective Data Sharding: Efficiently shard your data to ensure even distribution and balanced workloads across nodes. Avoid hotspots by distributing read and write operations evenly.
  3. Data Archiving and Retention: Implement data archiving and retention policies to store only necessary data in Cloud Spanner, reducing storage costs.
  4. Optimize Data Transfer: Minimize outbound data transfer by optimizing your application's data access patterns and leveraging caching mechanisms where possible.
  5. Automated Lifecycle Management: Use automated lifecycle management features to scale resources up or down based on demand, allowing cost optimization without sacrificing performance.
  6. Monitor and Analyze Usage: Regularly monitor your Cloud Spanner usage and analyze performance metrics to identify areas for optimization and resource utilization improvements.

Key Points to Remember

  • GCP Cloud Spanner is a globally distributed, horizontally scalable database service.
  • It offers strong consistency, high availability, and seamless scaling for modern applications.
  • Cloud Spanner pricing is based on node hours, storage usage, and outbound data transfer.
  • There is no free tier for Cloud Spanner; it is a paid service.
  • Choose the right node configuration and sharding strategy to optimize costs.
  • Leverage automated lifecycle management and performance monitoring for cost-effective scaling.

Check out related guides

The missing piece of your cloud provider

Why waste hours tinkering with a spreadsheet when Economize can do the heavy lifting for you 💪

Let's upgrade your cloud cost optimization game!

Get Started Now