Colopl open sourced a Cloud Spanner driver for Laravel framework
Today, I would like to share about the work done by one of our most important customer in Japan called Colopl. Outside of Japan, you might not know that company but Colopl is one of the major mobile gaming company in Japan. They released multiple hit mobile games like Shironeko Project (Action RPG) or The World of Mystic Wiz (Quiz RPG) that are ranked in the Top 20 of Google Play store.
As a context, Colopl decided to migrate all their games to GCP starting September 2017 and ended that migration back in November 2018. We just published on the GCP Japan blog their use case today (only in Japanese) but to summarize the article, they migrated to GCP to use Google Kubernetes Engine (GKE) and Cloud Spanner (Horizontally scalable strongly consistent relation DB) in order to reduce infra and operational cost (they actually decreased that by up to 30%).
Talking about Cloud Spanner, Colopl is been using this database for a year with their backend app written in PHP. And today, they just open sourced a Cloud Spanner driver for Laravel framework, one of the most popular framework for PHP. The Github repo is in English so don’t worry, you will find your way to use the driver :) (the lead engineer working on this project is also fluent in English)
Laravel database driver for Google Cloud Spanner. Contribute to colopl/laravel-spanner development by creating an…github.com
Below is the original article.
株式会社コロプラの粟田です。前回は PHP ではじめる Cloud Spanner という記事を書き、Cloud Spanner に接続する最小限のコードを紹介しました。medium.com
- Offers most of the Laravel database features for Cloud Spanner
- Supports Eloquent
- Supports Interleaved tables and indexes creation
- Proven track record on their latest game servers
Please follow the README on the Github repo which includes all the steps to make the driver work.
Take a look at the limitations section on the Github repo to understand what are the limitation of this driver related to how Cloud Spanner should be used.
I will just mention one in this article. And this is about AUTO_INCREMENT. Cloud Spanner doesn’t offer AUTO_INCREMENT because this represent an anti-pattern (see this document to understand the underlying reasons) and could result in hotspots. For this reason, the driver itself doesn’t offer any Laravel feature that would use AUTO_INCREMENT.
As mentioned in the repo:
Most functions of
Blueprint) can be used. However,
artisan migratecommand does not work since AUTO_INCREMENT does not exist in Google Cloud Spanner.
If you have any request or find any bug, don’t hesitate to report them in the Github issues. Colopl will continue to maintain this project while Cloud Spanner gets new features.
Hope this driver for Laravel will help PHP developers using Cloud Spanner in a more developer friendly way!