Xing

First Adventures with NoSQL

« Back to Blog

I've been meaning to start playing with NoSQL databases in my own projects for quite some time now, but never actually got around to it. My original plan was to set up some simple serverless Google Cloud Functions just to get a feel for them, but unfortunately it looks like my Google Cloud project is configured to use Datastore instead of the newer Firestore, and it doesn't look like Functions natively supports Datastore. So instead I just wrote some PHP endpoints that would talk to Datastore, and it seems to work fine. In fact, it was super simple to set up once I flipped the switch that allowed my Compute Engine instance to talk to Datastore.

With the basic infrastructure set up, I decided to implement a feature that some friends had asked for - a high score table in Tetris. This came with its own set of challenges, namely with validating scores. After all, the game runs entirely on the client; what would stop someone from modifying their client to claim that they got 40 quadrillion points? In reality, nothing. I took a couple steps to try to make it harder to fake, but it's nowhere near foolproof. Please don't intentionally break it. Thanks.

On a related note, I had forgotten how terrible these old codebases were. Dipping back into my freshman year projects really was not fun. I barely got the table working and then just pushed it to production and closed it as quickly as I could. It's not pretty, but I don't intend to spend any more time maintaining it than I need to.

Posted By: Michael Xing

« Back to Blog