Colopl open sourced a Cloud Spanner driver for Laravel framework

Samir Hammoudi
Feb 23, 2019 · 3 min read

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%).

Image for post
Image for post

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)

A backend engineer from Colopl, Hiroki Awata has just published an article about their work (again in Japanese) so I thought I could help and summarize their article here in English :)

Below is the original article.

colopl/laravel-spanner features

  • 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

Installation

Please follow the README on the Github repo which includes all the steps to make the driver work.

Limitations

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 SchemaBuilder (eg, Schema facade, and 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!

Google Cloud community articles and blogs

Samir Hammoudi

Written by

Gaming Technical Specialist, Google Cloud. All views and opinions are my own. @ksimir

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Samir Hammoudi

Written by

Gaming Technical Specialist, Google Cloud. All views and opinions are my own. @ksimir

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store