Before launching an application, we recommend that you warm up your database using test data loads to take advantage of Cloud Spanner's parallelization features.
Cloud Spanner is a distributed database, which means that as your database grows, Cloud Spanner divides the key space of your data into chunks called splits. Each split is a range of rows that contains a subset of your table. As Cloud Spanner splits data based on load and size, it dynamically moves individual splits independently of each other and assigns the splits to different server resources to balance the overall load on the database.
When you initially insert data into an empty database, Cloud Spanner writes the data to a single split. The database is still in a "cold" state. As you insert more data, Cloud Spanner starts to split that data to rebalance the load across other available server resources. Now Cloud Spanner is in a "warm" state with splits across available server resources to maximize parallelism and improve performance.
As a best practice, we recommend that you launch your application when Cloud Spanner is in a warm state with splits already created and balanced across server resources. In order to warm up your database and prepare your test data loads, follow these steps:
- Make sure that the primary keys you generate for your test data loads are in the same key space and have the same distribution properties as the keys you are using for production traffic.
- Run a load test no more than two days before your launch. Run the load test for at least one hour at the expected peak load. The load test causes Cloud Spanner to create more splits due to load-based splitting.
- After the load test is complete, you can delete the rows generated by your load test from your tables, but don't delete the tables themselves. This keeps the splits available for your launch window.