Posts

Code Simplicity Takeaways

Code Simplicity is a good book if you are wondering how to simplify a new or existing software so it is more maintainable and easier to develop. In a nutshell, only-as-needed design and incremental development are the two foundations of simplicity. Only-as-needed design By designing based on what is known now , the design can be created as simple as it needed to be. Simple design where components are broken down to its minimal requirement also tends to be simpler to extend, change, fix, or remove from a system. Simple design also eases new programmers into the system and speeds up their time to start contributing. Simple design might come from re-using existing solutions that might only fit most of the requirements rather than creating new ones that fit all requirements. When a system is using a maintained library or technology, it outsources a complex part that is not part of its purpose. However, be careful of libraries or technologies that lock the system into their environment t

Better Call Saul Character Review: Saul and Kim

Heads up, this review contains spoilers of Better Call Saul and, to some extent, Breaking Bad. As usual of Vincent Gilligan and his team, Better Call Saul (BCS) is brilliant. Surely it is a pleasant surprise for people who thought this prequel is just trying to milk the success of Breaking Bad. Let’s be real. Even I personally decided to watch it because of how much I was blown away by Breaking Bad, especially with those two last episodes. *chef’s kiss* For those of you who have watched Breaking Bad and had no or minimal interest in our criminal lawyer, I am with you. Watching Saul helping our meth-cooking duo always seems to be a plot convenience. My initial thought of Saul: Oh, there is this crooked lawyer that helps criminals smoothen things out legally (loosely speaking). It is not surprising at all. Walter White is a genius, but only in the scientific field. So, it is a pleasant and welcomed change that BCS shows how Saul complements Walt as a legal genius. Of course, talking abou

Slack’s 2021 Outage Postmortem Takeaways

Slack had an outage at 4 January 2021 for about ~1 hour on their web application (they mentioned it as “tier” but I am assuming that it relates to their client-facing application). This Slack blog post discusses about how the problem was discovered (it also had a neat timeline diagram) and the cause of the problem. This is my takeaway of Slack’s start of year 2021 outage. Monitoring services should be made reliable. One major hinderance that Slack faced during the incident was the monitoring services were unable to be used. As a result, they reverted to manual ways (such as querying directly to their backends) to troubleshoot and recover the impacted systems. Balance between upscaling and downscaling of instances. The article does not go deep dive about this but it seems this scaling have a major part. It only mentioned about disabling downscaling and adding 1200 servers for the upscaling. Now, from what I know, these scalings are usually handled by the cloud provider. My best gu

Gitlab’s 2017 Database Outage Postmortem Takeaways

The complete article of the postmortem can to read here: Postmortem of database outage of January 31 . In summary, Gitlab.com has a database outage occurred that on 31 January 2017. This outage resulted in the lost of data spans over +6 hours. There are several takeaways that I learned from this postmortem. Setup several recovery mechanism that works in case the first choice cannot be relied . Gitlab have 3 ways of database backup: running scheduled pg_dump to S3, disk snapshots using Azure, and LVM snapshot that usually used to copy data from production to staging environment. The pg_dump cronjob failed because of a different version used for pg_dump (for PostgreSQL 9.2) and the database version (PostgreSQL 9.6). The Azure disk snapshot is used to only backup NFS server (I am guessing data for their application and others..?). Moreover, this is a disk recovery data which means if Gitlab needed to only restore database data. I imagine they should manually to choose which part of

Experiment #1: Can JavaScript run something like a concurrent thread/process? No.

So, I know it is stated frequently that JavaScript is "a single-threaded" language. But it is non-blocking thanks to Web APIs. However, I was thinking whether it means that we can run something concurrently like in some other languages like Java, Go, or Python. I mean ES6 includes Promises and it was enhanced by async-await. So, is it possible to make use of Promises to run multiple things in the same time? It was fairly a simple experiment. All you need is A function that acts as a Promise (an async function), A method that will be run as a Promise and as a synchronous function, and A "container" function that holds both async function and plain function. With that three method in mind, this is the code that I came up with. function timelapse ( id ) { for ( let i = 1 ; i <= 1 _000_000; i++) { if (i % 500 _000 === 0 ) { console .log( ` ${ new Date ().getTime()} ${id} ` ); } } } async function asyncFunction ( id ) {