• Minimise usage of field numbers > 15
  • Use packed option for long repeated fields
  • Embedded Messages are wrapped with metadata of higher level messages


Protobuffers is an encoding mechanism for message sending between servers & services. It is highly popular at many companies mainly because of its great performance in terms of

Part 1 — Message Structure

Let’s look the simplest…

Unheeded warnings from a distant age

8 years ago while in high school, a wise man gave a speech at our founders’ day celebration. His name was Bilahari Kaushikan and he was then the Permanent Secretary of Foreign Affairs. Re-reading his speech from all those years ago brings out many lessons in humility and introspection. I sincerely beseech you to spend the time to contemplate on this magnificent piece of writing.

Raffles Institution — my Alma Mater and that of Bilahari Kaushikan (Source: The Straits Times)

The Speech:

Eighty-five years ago an American writer by the name of Thornton Wilder published a short novel entitled The Bridge of San Luis Rey. …


  • When extending a function, NEVER change the function signature
  • Make sure you have thought about the future uses before exposing an Interface to public, because you’re NEVER gonna change that
  • There’s Backward Compatibility (code can compile) and Behaviour Compatibility (code acts the same way) to consider


In this world, we have two kinds of repositories:

  1. Application Repositories — repositories that is only used & seen by you and your team that contains the business logic of your App
  2. Shared Libraries — Repositories that are used by many other application repositories (think any standard library, SQL package, Redis, any open source…

Background — Spot the Bug!

A few months ago I was given a seemingly simple ticket. A downstream team wanted a simple API with the following logic

Request: Given a list of userIDs

Response: Find the number of conversations by these users with at least 1 unread message

We currently store the data of the unread messages in a redis sorted set with the following schema

║ Key ║ Value ║ Type ║
║ user_id{USER_ID} ║ {convo_id1, convo_id2…} ║ Sorted Set (Z) ║

To answer the query, we can write the following LUA script to retrieve the necessary Data, by inputting the proper key slice into the script

local t = {}
for i, key in ipairs(KEYS) do
table.insert(t,'ZCARD', key))
return t

There is currently a bug in the methodology described above. Can you find it?

Hint: Under some circumstances, it will give a wrong answer but under other…


Golang genetics is being planned for Go2. Here’s a sneak preview!

Here We Go!


A generic method is a function which objects of various types may be input as its argument. Below is an example of a Java generic method:

public static < E > void printArray( E[] inputArray ) {
// Display array elements
for(E element : inputArray) {
System.out.printf("%s ", element);

Above, the method accepts arrays of any type, be it int, string, bool etc etc…

Ng Tze Yang

Core Server Software Engineer @ Shopee

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