All blogs

8 mins

Google Cloud Spanner: Everything You Need to Know

Piyush-Kalra

    Ready to start optimizing on your cloud spend?

    By submitting your email, you agree to opt in to marketing emails.

    Building a modern application comes with a unique set of challenges, especially when it comes to scaling. Traditional databases often struggle as your user base grows across the globe. You might find yourself dealing with complicated global database complexity, frustrating downtime, and consistency problems that keep your engineering team awake at night.

    Google Cloud Spanner is a globally distributed relational database designed to solve these exact problems. It gives you the power to handle massive workloads without sacrificing the reliability of a traditional relational database.

    In this article, we cover everything developers, database administrators, and business leaders need to evaluate whether Google Cloud Spanner is the right fit for their organization. By the end, you'll understand what Cloud Spanner is, how its architecture works, its pricing structure, and when it makes sense for your next project.

    What Is Google Cloud Spanner?

    Google Cloud Spanner, a fully managed relational database, spans the globe and can grow horizontally while maintaining high consistency.

    You could say that it's like getting the best of both worlds. You get the structured schema and easy-to-use SQL queries of a traditional relational database, along with the ability to scale horizontally like a NoSQL database. You can easily deploy your database in multiple regions with little extra work because it runs on Google's global infrastructure.

    Key Features of Google Cloud Spanner

    Spanner is packed with powerful capabilities to support your most demanding applications. Here is a breakdown of what makes it stand out:

    Core Features

    • Global multi-region deployment: For minimal latency, you can deploy and access your data from your users anywhere across the globe.

    • Horizontal scaling: You may seamlessly add or remove resources as needed without downtime.

    • Strong consistency: Immediate and most up-to-date data is available for each read, regardless of the geographical location of the request.

    • Automatic sharding: There is a self-management system that automatically distributes and balances data to alleviate strain on the system.

    • High availability: You can have your applications active and online with a remarkable availability of up to 99.999%.

    • SQL support: Data can be queried using the well-established Google SQL or PostgreSQL.

    • Vector search: Google Cloud Spanner is especially suited for AI-related applications, as it supports vector embeddings.

    • Spanner Graph: You can also use your operational database to build knowledge graphs and to query complex relationships.

    • Multi-model database support: All of your relational, graph, key-value, and search data can exist on one and the same platform.

    • AI integration: Access built-in integrations with Vertex AI to create smart and generative AI applications.

    • Spanner Editions: Choose from Standard, Enterprise, and Enterprise Plus editions depending on your budget and operational requirements.

    How Google Cloud Spanner Works

    To understand how Spanner does the impossible, let us use an everyday analogy. Imagine a huge, global train system. Every station master needs an accurate and perfectly in-sync clock to ensure that trains do not crash into one another and arrive at their destinations at the exact same time.

    Spanner employs a similar idea. TrueTime. TrueTime uses cutting-edge technology such as atomic clocks and GPS to create a system of global, synchronized clocks at every Google data center. This enables Spanner to give worldwide strong consistency and precise timestamps to transactions without needing the database nodes to constantly sync and check with each other.

    Here is a brief overview of its architecture.

    • Distributed architecture: Storage and compute are separated. Nodes are responsible for processing while a distributed file system.

    • Sharding: As your tables grow, Spanner will automatically split and balance them across different servers.

    • Replication: Your data will always be available and synchronized across different regions and zones using the Paxos consensus algorithm.

    • Multi-region deployment: Spanner can be used to serve data to different continents and will automatically route user requests to the nearest replica.

    Google Cloud Spanner vs Traditional Databases

    How does Spanner stack up compared to other existing databases, such as PostgreSQL or MySQL? While traditional databases have their own merits, they typically require a considerable amount of manual effort to create read replicas, custom sharding, etc., at the time of global scale.

    Feature

    Google Cloud Spanner

    Traditional Database

    Scaling

    Horizontal

    Vertical

    Availability

    Global (up to 99.999%)

    Single region

    Consistency

    Strong

    Often eventual (across replicas)

    Sharding

    Automatic

    Manual

    Downtime

    Minimal to zero

    Possible during upgrades

    When Should You Use Google Cloud Spanner

    Google Cloud Spanner is suitable for specific use cases where data is required to have strong consistency and geographical data distribution.

    • Global SaaS applications: Provide services to users globally and with low latency.

    • Financial systems: Process ledgers, banking transactions, and payment gateways, where strong consistency eliminates expensive mistakes.

    • E-commerce platforms: Design and provide a seamless experience with real-time inventory management during business spikes.

    • Gaming platforms: Management of real-time concurrent players, especially for infrastructure like flexible matchmaking, player profiles, and leaderboards.

    • AI applications: Use built-in vector and graph search for recommendation systems and generators.

    When Not to Use Google Cloud Spanner

    We believe in simplifying complex processes to guide companies in making the right choices. Spanner is a premium enterprise service and not suitable for all use cases.

    • You have small workloads: If a single PostgreSQL instance can sufficiently manage your workloads, Spanner will be an over-engineered solution.

    • You are a budget-constrained startup: For projects that require basic SQL databases in the cloud, Spanner has a significantly higher entry cost.

    • You build simple, single-region apps: If your users are all located in the same city, have stable and predictable traffic, and use other relational databases.

    Google Cloud Spanner Pricing

    Spanner uses a transparent, pay-as-you-go pricing model based on five main categories:

    Processing Units (PUs)

    Compute capacity is defined by Processing Units (PUs), where 1 node is 1,000 PUs. Since billing starts, your compute capacity should be at least 100 PUs. This is also true for hourly fees. Since a standard node costs roughly $0.90 per hour, a 100 PU instance would be $0.09. Spanner compute capacity is also flexible, so your capacity can automatically scale based on your current workload.

    Storage pricing


    Cloud Spanner evaluates the kind of storage you have for billing purposes. SSD storage is the most expensive at $0.30 per GB per month. HDD storage is $0.06 per GB per month. SSD storage is the storage of choice for most production workloads, as its performance is better. The bill covers your database data, as well as indexes and metadata.

    Network pricing

    Ingress data is free, while egress data is chargeable based on its destination. You incur costs due to open internet data transfer, cross-region data transfer, and multi-region deployment data transfer.

    Backup and Recovery Costs 

    Along with a standard charge for backup storage of about $0.10 per GB, Spanner provides automated backup as well as a contained Point-in-Time Recovery (PITR), which is continuous backup at a storage cost. This backup is better than most for disaster recovery.

    Multi-Region Pricing 

    Multi-region deployments are typically more expensive than single-region setups due to the additional replicas, cross-region infrastructure, and higher availability SLAs involved. However, the value they provide is substantial. Multi-region deployments provide up to 99.999% availability, are more resilient to outages within individual regions, and provide better performance worldwide.

    Cost Examples:

    • Small deployment: Running a granular instance at 100 PUs (1/10 of a node) in Standard edition is a few dollars a day, making it very pocket-friendly for small testing and app deployments.

    • Medium deployment: A standard 1-node regional configuration with average storage is estimated to cost $650 to $700 per month.

    • Enterprise deployment: A multi-region Enterprise Plus deployment configuration with several nodes and multiple terabytes of data will cost several thousands per month and will scale down via committed use discounts (CUDs) for 1-year or 3-year terms.

    Benefits of Google Cloud Spanner

    When you choose Spanner, you are investing in peace of mind. Here is how your business benefits:

    • Faster scaling: Instantly add compute nodes during Black Friday sales or game launches without modifying your application code.

    • Less downtime: Hardware failure is a commonplace occurrence. Spanner will detect and resolve the failure and will remain available with zero changes.

    • Reduced DevOps workload: Spanner is a fully managed service, so your DevOps team will not lift a finger to manage, shard, or set up the service.

    • Enterprise reliability: Spanner is the same, proprietary technology that Google utilizes for its business operations.

    Is Google Cloud Spanner Right for You?

    Your database architecture is normally a very critical decision, so here is a simple structure to guide your decision-making.

    Use Spanner if:

    • You will be able to easily scale your business globally.

    • You need robust ACID consistency across various geographic regions.

    • You will be able to integrate vector search and graph searches with relational data.

    Avoid Spanner if:

    • You only need a small, singular database located within a single region.

    • Your budget is highly constrained.

    • You prefer utilizing a vertically scalable PostgreSQL or MySQL for your current traffic levels.

    Conclusion

    Google Cloud Spanner offers global reach and the benefits of NoSQL data storage and retrieval, along with a high level of control and regulatory alignment similar to traditional relational database systems. Your team will have the ability to build highly globally available systems, like applications, with minimal inputs. It is a marvelous system.

    If you're experiencing rapid growth, volatility in traffic, or need to serve a worldwide clientele while ensuring data accuracy, Spanner is a solution that will benefit you for years to come.

    Assess your current workload and then start a free 90-day trial of Google Cloud Spanner to witness boundless scale for yourself.

    Join Pump for Free

    If you are an early-stage startup that wants to save on cloud costs, use this opportunity. If you are a start-up business owner who wants to cut down the cost of using the cloud, then this is your chance. Pump helps you save up to 60% in cloud costs, and the best thing about it is that it is absolutely free!

    Pump provides personalized solutions that allow you to effectively manage and optimize your Azure, GCP, and AWS spending. Take complete control over your cloud expenses and ensure that you get the most from what you have invested. Who would pay more when we can save better?

    Are you ready to take control of your cloud expenses?

    Similar Blog Posts

    Get The Pump Digest delivered straight
    to your inbox each week.

    Unsubscribe anytime

    Looking ahead

    As Usergems continues to scale, Pump remains part of the foundation that supports sustainable growth and operational clarity across teams.

    Looking ahead

    As Usergems continues to scale, Pump remains part of the foundation that supports sustainable growth and operational clarity across teams.

    Looking ahead

    As Usergems continues to scale, Pump remains part of the foundation that supports sustainable growth and operational clarity across teams.