I got a question in a recent interview about locking in Database. I found that I actually lack insufficient knowledge of this essential part of building a robust application. I would like to share my finding on this topic here.

Photo by Chris Barbalis on Unsplash


It’s all about race condition.

A big part of most web applications is used to store some data, probably in a database. Imagine in a simple case of updating a user credit in an online book shop. A user can spend this credit earned by the previous purchase.

defmodule BookOrdering do def purchase_book_with_credit(user_id, book_id) do with {:ok, book} <…

If you are been working on Elixir or Erlang, you will not be unfamiliar with processes. They are the most important building block of highly concurrent system in BEAM. We will look into it in this article in order to understand how it make fault-tolerant and scalable.

Photo by Suzanne D. Williams on Unsplash

Process is just memory

A Vector(array with adjustable size) is a collection of values indexed by contiguous integers and it is a very commonly used collection data structure in most languages. However, it’s not available natively in Elixir.

Let’s have a brief understanding of List first.


The most commonly used data structure in Elixir is a list, more specifically singled-linked list. In fact, the list is heavily used in almost all functional programming languages because of its simple definition. A linked-list consist of a head and a tail which is also a list with a special case of an empty list. When you write…

Encryption consists of two components, an algorithm(cipher) and a secret value(key). The term symmetric means the key used for encryption and decryption is the same. They can be represented by mathematical-like notation as follow:

C = E(P, K)

P = D(C, K)

P = D(E(P, K), K) where P is plaintext, K is the key, C is the ciphertext, E is the encryption function and D is decryption function.


One of the most famous and simple ones is the Caeser Cipher. It basically works by substituting the original letter are replaced with other letters based on some rules. …

Cryptography is essential in making our Internet secure and private. Its usages are all over the places, like online payment, messaging, digital signature and the hottest topic, cryptocurrency or better called as decentralized ledger technology.

Even though I have been coding professionally for more than 4 years, I am an absolute noob in cryptography and yet I decided to start learning it on a regular basis and will start this blogging series. Hopefully, it could be helpful for others, especially web developers. And the first episode will be about HTTPS.

TCP/IP Networking 101

In our web development, we will have our server that…

Concurrency, Intentional Programming Style


In Erlang, we use message passing concurrency model. There is no shared memory between each Erlang process and they communicate each other by sending Erlang term to another mailbox. And because there is an only immutable data structure in Erlang. We don’t need to avoid about state get mutated by another process.

In Erlang, a process is like an object in OOP. The creator of Erlang even once said Erlang is the most object-oriented programming language. They are very lightweight and used extensively.

And with OTP framework which provides lots of common abstraction like GenSever which…

KaFai C

Coding, Weightlifting, Veganism, Society, Cat | http://bruteforcecat.com/

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