Cloud Spanner Overview Google Professional Data Engineer GCP
- A fully managed service
 - relational database service
 - offers transactional consistency at global scale
 - automatic synchronous replication for high availability
 - Has interleaved schema – Group primary key and foreign keys together for faster access
 - Cascade on delete can be done with interleave.
 - Primary keys don’t have sequential keys and make sure its distributed
 - Secondary indexes make the query efficient
 
CAP Theorem
The CAP theorem is for distributed system and they can guarantee at most two qualities only:
- Consistency: All observers see the most recent data and order of events is guaranteed
 - Availability: The system is always online and able to handle all requests
 - Partition tolerance: The system continues to operate during network disruptions
 
- RDBMS can best provide CP
 - NoSQL can provide AP
 - Spanner provides all three – CAP.
 
Comparison with other data models
| Cloud Spanner | Traditional Relational | Traditional Non-Relational | |
| Schema | Yes | Yes | No | 
| SQL | Yes | Yes | No | 
| Consistency | Strong | Strong | Eventual | 
| Availability | High | Failover | High | 
| Scalability | Horizontal | Vertical | Horizontal | 
| Replication | Automatic | Configurable | Configurable | 
TrueTime
- Used For strong consistency
 - Google datacenters have atomic clocks
 - It gives Spanner nodes to determine the current time down to a very fine resolution. the margin of error in system time is about 7 ms.
 
Paxos consensus algorithm
- Allows consensus to be reached in very unreliable environments
 - ideal for maintaining consensus across large bodies of data.
 
Read / Write
- queries are performed using strong reads that guarantee the most recent results
 - queries may result in a slight performance hit.
 - Clients can specify an exact staleness in queries
 - the client provides a timestamp and Spanner executes the query on the most recent data relative to that timestamp.
 - Spanner APIs provide write operation
 - For write give a number of mutations to be executed,
 - each mutation affects a single cell
 - Spanner supports up to 20,000 mutations in a single transaction, and affected indexes are also counted.
 - Cloud Spanner offers two types of transaction
 
- read-only transactions – non-locking operations and it ensures that the data being read is not updated from the observer’s point of view over the course of one or many reads. Any update during a read-only transaction are ignored
 - read-write transactions – locking operations so, data will be blocked until the transaction is committed. It supports rollbacks.
 
Google Professional Data Engineer (GCP) Free Practice TestTake a Quiz
		