Sunday, November 11, 2018

Malaysian Restaurants are not Thread Safe

One of my favorite software related posts is Starbucks Does Not Use Two-Phase Commit. Its amazing because it boils down a technical topic into real world terms. Its much more easy for us to grasp when we see it in some form that we can relate to (we all are familiar with Starbucks). And just seeing it in a different form helps our understanding.

I noticed one so far over my trip in Malaysia. I'll sit down in a restaurant and a server will take my drink order. After that server has left, another one might notice that I have no drink and ask for my order. I simply tell them that I have already ordered and they go on their way.

This system is much different than what you get in almost every restaurant in the United States. In the US the waiters synchronize between themselves. Usually one is assigned per table. In Malaysia, its anything goes. If there is a person that looks like they haven't ordered yet. Then take their order.

If you think about this in terms of worker threads. In the US the waiters keep the state and coordinate between each other (using various other protocols) but in Malaysia they rely on the customer to keep state and filter out duplicate requests.

The downside to this is that my experience is a negligibly worse as I get redundant requests and have to explain that I already ordered. However, there are some good benefits to this as well.

1) Its more efficient and faster. I get my order in from the waiter that notices first.

2) Its simple for the waiters. They really don't have to communicate with each other

I only noticed this because I very infrequently have seen it back at home but now it seems to happen to me all the time. There's nothing wrong with this strategy for me as I'm not annoyed with the second request. I just think its interesting how regional this system design seems to be.