Gossips in Distributed Systems: Physalia

Reading Time: 6 minutes

I often take notes and jot down observations when I read academic/industry papers.   Thinking of a name for this series ‘Gossips in Distributed Systems’ seemed apt to me, inspired by the gossip protocol with which peers in these systems communicate with each other which mimics the spread of ideas and technologies among practitioners and people alike. The goal of this series would be to do a round-up of any new concepts or papers in computer science (often in distributed systems but not always) and share my thoughts and observations.

Today, we are going to talk about the Physalia paper from AWS: “Millions of Tiny Databases”.  This is inspired by Physalia or  Portuguese man-of-war (pictured), a siphonophore, or a colony of organisms.   Overall, the paper, even though slightly on the longer side, is chock full of details and best practices pertaining to design, architecture, and testing of distributed systems.

Given the size of the paper and the wide gamut of topics that it touches, we will be discussing only a few aspects of the paper in this post along with some observations. In subsequent sequels, we will go into others in further detail. 

Before proceeding ahead, the present EBS architecture with Physalia has a primary EBS volume (connected to EC2 instance) and a secondary replica, and data flowing from instance to primary and replica in that order. Also, this chain replication is strictly within an Availability Zone (AZ) mainly due to inter-AZ latencies being prohibitive. The pre-Physalia architecture had a similar replication chain but with the control plane also being part of EBS itself rather than a separate database (which we will soon find out was not a good idea).

Credits: Screenshot of figure in the Physalia paper

Raison d’être

All good-to-great systems have a story that necessitated their existence. In this case, it was an outage of the us-east-1 region in 2011 caused by overload and subsequent cascading failure which necessitated a more robust control plane for failure handling. The postmortem of that outage is here, it is quite long and wordy, so I will summarize it here. 

Continue reading “Gossips in Distributed Systems: Physalia”

Circuit Breakers: Stock Markets and Distributed Systems

Reading Time: 4 minutes

There are many parallels between the stock markets and the distributed systems in computer science. This post, in particular, is about circuit breakers prevalent in them for better resilience against irrational exuberance and upstream service errors respectively. In particular, this is about exploring breakers in stock markets from a distributed systems perspective. 

Of late, the US stock market (and the non-US ones too) has been quite volatile, to say the least. CBOE VIX index  (also known as the ‘fear index’) which measures implied volatility in the S&P 500 index, has traversed a wide range between highs and lows, fluctuating several points on many of the days in March and April, peaking at 82.69 on 16th March (stock market bottomed out on 23 March, both as of May 10, 2020).  

Continue reading “Circuit Breakers: Stock Markets and Distributed Systems”

Haiku and Muffin Top

Reading Time: 3 minutes

My interest in haikus was recently rekindled by James May’s Our Man in Japan series in which he frequently bookends the episodes with a haiku of his own. Accordingly, I started searching for a haiku ebook on Libby (which if you are not using, you should give it a try!) and I found Haiku: Classic Japanese Short Poems.  The book has haikus in Romaji, English, and vertical Japanese. The book is spartan in its use of graphics and has a very simple structure much like the subject matter it deals with. There are about 60-70 haikus in it from the four great haiku masters.

Haiku, for those hearing about it for the first time, is a form of Japanese poetry conforming to certain constraints on syllables (5-7-5) and split over three lines. The book itself does not delve sufficiently enough into the history of haiku, though the Wikipedia page on Haiku proves more than sufficient here. Listing haikus often commence with the famous Matsuo Bashō’s old pond haiku which goes like: 

As it should be evident at this point, they are remarkably short, and often involve nature and seasons. They behoove the reader to invoke their imagination and experience the verses prima facie.  To help with this, the haiku verses are often read slowly, more akin to sipping tea gently. A tabula rasa-esque mindset, for that short period, helps. As a result, the haiku focuses as much on the material as the reader too, a dichotomy similar to an artwork in a gallery and a keen observer. 

Continue reading “Haiku and Muffin Top”

Debugging docker containers with gdb and nsenter.

Reading Time: 3 minutesMany a time you feel the need to debug a process running inside the container with gdb (or anything that uses ptrace). It is not as straightforward (at least for now) as attaching gdb to host pid of the container process or to docker client/daemon.


You can go about in following ways:

  • If you try to attach gdb to the hostpid (let us call it HPID) of the container process (ie. PID in host namespace), it gives following warning:

  • You can install gdb in container beforehand or with docker exec and attach to the process. However, for a non-privileged container or one which doesn’t have CAP_SYS_PTRACE capability this won’t work. You will get ‘Permission denied’ otherwise. More info on capabilities with docker here.

    Any of the following will do:

    docker run   -d  -i  --cap-add sys_ptrace ---name box centos:centos7 sleep 100000
    docker run   -d  -i  --privileged  --name box centos:centos7 sleep 100000

Continue reading “Debugging docker containers with gdb and nsenter.”

Slides from PLMCE 2014 breakout session

Reading Time: 2 minutesAs many of you already know, PLMCE is an annual MySQL
community conference and Expo organized by Percona in the month of April
(usually). It is a great conference, not only to meet new and eminent people in
MySQL and related database fields, but also to attend interesting talks, and
also to give some.

This year I spoke about synchronous replication at a higher level. The talk was
titled “ACIDic Clusters: Review of current relational databases with synchronous replication”. Having previously given talks with boring titles (but interesting content), this time I decided to go with an interesting title, and it seemed to fit well with topic being discussed.
Continue reading “Slides from PLMCE 2014 breakout session”

My twitter setup

Reading Time: 3 minutesI have been using Twitter for a while under the handle randomsurfer.
I tend to use web interface sometimes, but regularly I use the command-line/ncurses interface.

There are two main clients that I use regularly. One is ttytter
which is a nice command-line client which offers advanced functionality such as
creating/editing lists and scripting. Refer to the linked page for more scoop. I
would say ttytter is one of the best implementations of Twitter API. It allows
for advanced scripting like:

The above invocation can be used to get the list of everyone you follow and
populate the configuration file to allow auto-completion at ttytter prompt. You
can also run ttytter as a daemon.
Continue reading “My twitter setup”

Annoying access keys on web pages

Reading Time: 2 minutes5463604427_8e7998ddcc_b
HTML access keys were introduced to improve web accessibility and
they still seem to serve that purpose. Wikipedia defines them
as “In a web browser, an access key or accesskey allows a computer user to
immediately jump to a specific part of a web page via the keyboard.”
If you
view hover over the link, it should show up in tooltip; for a wikipedia page,
for instance, the ‘view history’ is mapped to ‘alt-shift-h’ by default. In HTML
source, you can see them as accesskey attribute.

Having said that, they can be really annoying many a time. This is true
primarily when you have bound that access key to a mapping in the browser or in
a plugin or even to a global binding (say, with xbindkeys). What makes it even
more worse is that on almost every site it is impossible to disable them.
Continue reading “Annoying access keys on web pages”

MySQL file limit, table cache and max_connections

Reading Time: 4 minutes

MySQL variables open_files_limit, table_open_cache and max_connections are
inter-related, and this is for obvious reasons: all deal with file descriptors
one way or another.

If one of the value is provided but others are left out, mysqld calculates
others using a formula and in some cases, emits a warning if not possible.

The whole calculation behind obtaining the final file descriptor limit is a bit
byzantine and is as follows (for Linux):

EDIT: This applies to MySQL 5.5, in 5.6, as Daniël in comments pointed out,
few things have changed, check comment for details. I will probably make a
followup post on the differences.

  1. First it tries to calculate a minimum requirement based on max_connections
    and table_open_cache. As for other variables, if it is not provided in cnf or
    on command line it uses defaults.

    <br />    /* MyISAM requires two file handles per table. */
        wanted_files= 10+max_connections+table_cache_size*2;

    Continue reading “MySQL file limit, table cache and max_connections”

Saving form data in firefox

Reading Time: 2 minutesWhen commenting on sites, I have sometimes, seen that the commenting system just swallows the comment, or there is a browser crash, or a system one. In these cases it would be great if you can recover it somehow, particularly when you typed quite a bit.

There are plugins for firefox and other browsers for this. But since I use Pentadactyl(site), I thought not to use any external plugin but write one for dactyl. But then, I realized a plugin may not be needed.

Following is what I use:
Continue reading “Saving form data in firefox”