Crack in ground

Fault-Tolerance and Data Consistency Using Distributed Sagas

While microservices have become the defacto architectural pattern for building modern systems, they come with their own set of challenges. Key among them is ensuring application data consistency when data is spread over multiple databases. This article discusses one solution to this problem, distributed sagas. Distributed sagas provide consistency guarantees for systems spanning multiple databases in the face of failure using a clear and manageable implementation pattern. A saga is highly related to a finite state machines that moves consistently through a set of states, ensuring at each step that some conditions hold. ...

December 6, 2018 · 15 min · Kevin Sookocheff

IaaS, PaaS, SaaS and Infrastructure

Infrastructure is undergoing a significant paradigm shift. At my first job as a software developer, scaling our infrastructure meant buying a physical machine and installing it in a rack, setting up the system images and base software by hand, configuring the network using some shell scripts, and finally, making it available for developers to install software. Now, with the advent of cloud computing, the same capabilities — installing and running software — are available on-demand. ...

October 23, 2018 · 8 min · Kevin Sookocheff

Alpha Conversion

Alpha conversion (also written \(\alpha\)-conversion) is a way of removing name clashes in expressions. A name clash arises when a \(\beta\)-reduction places an expression with a free variable in the scope of a bound variable with the same name as the free variable. — Greg Michaelson, An Introduction to Functional Programming Through Lambda Calculus When we are performing a \(beta\)-reduction it is possible that the variable name in an inner expression is the same as a variable name in an outer expression. For example, consider ...

October 18, 2018 · 3 min · Kevin Sookocheff

Beta Reduction

Formally, beta reduction (also written \(\beta\)-reduction) is the replacement of a bound variable in a function body with a function argument. The purpose of \(\beta\)-reduction is to compute the result of a function by function application using specific rules. More formally, the beta reduction rule states that a function application of the form \((\lambda x.t)s\) reduces to the term \(t[x := s]\). The term \(t[x := s]\) means that all instances of \(x\) in \(t\) are replaced with \(s\). The \(\rightarrow\) syntax is used as a shorthand for beta reduction. We can specify beta-reduction explicitly using the notation \((\lambda x.t)s \rightarrow t[x := s]\), which means that the beta reduction of \((\lambda x.t)s)\) is \(t[x := s]\). The beta reduction removes the \(\lambda\) symbol and resolves to the function’s body with the argument \(s\) substituted into the body. ...

October 4, 2018 · 2 min · Kevin Sookocheff

Building Stateful Services with Kubernetes

The Kubernetes sweet-spot is running stateless microservices that can scale horizontally. By keeping state out of your application, Kubernetes can seamlessly add, remove, or restart pods to keep your service healthy and scalable. Developing a stateless application is, without question, the easiest way to ensure that your app can scale with Kubernetes. However, there are some workloads that do not run effectively in a stateless way, and for that, Kubernetes offers a few tools for developing stateful applications: leader election, StatefulSets and session affinity. ...

October 2, 2018 · 8 min · Kevin Sookocheff

Eta Reduction

The purpose of eta reduction (also written \(\eta\)-reduction) is to drop an abstraction over a function to simplify it. This is possible when there is nothing more that a function can do to its argument. For example, imagine that we have a simple function \( f\ x = g\ x \). Both \(g\) and \(f\) take the same argument, \(x\), and the function application function results in the same value (specified by the equality symbol). Since both \(f\) and \(g\) take the same argument and produce the same result, we can simplify the equation to just \(f = g\). In lambda calculus, this simplification is called \(\eta\)-reduction. ...

September 27, 2018 · 3 min · Kevin Sookocheff

Testing in Production — Building Observable Distributed Systems

Complex systems exhibit unexpected behavior. — John Gall, The Systems Bible One reaction to the myriad failure cases we encounter with distributed systems is to add more testing. Unfortunately, testing is a best-effort verification of system correctness — we simply cannot predict the failure cases that will happen in production. What’s more, any environment that we use to verify system behaviour is — at best — a pale imitation of our production environment. An alternative to adding more tests is to add more monitoring and alerting so we know as soon as possible that a system shows signs of degradation. Unfortunately, monitoring and alerting suffers from the same faults as testing — we monitor for behaviour that is predictable in nature or that we have experienced in the past. Together, monitoring and testing try to enumerate all possible permutations of partial and total system failure. Unfortunately, they only provide a simulation of how you expect a system to actually function in production. ...

September 25, 2018 · 8 min · Kevin Sookocheff

Normal, Applicative and Lazy Evaluation

A lambda expression is said to be in normal form if it cannot be reduced any further, meaning that the expression no longer contains any function applications. More formally, a reducible expression is called a redex, and a lambda expression is in normal form when it contains no more redexes. Redex A reducible function expression. Normal Form A lambda expression that contains no redexes. Given a lambda expression, there are two primary strategies for reducing it to normal form: normal-order evaluation, or applicative-order evaluation. This article discusses both methods, their pros and cons, and an alternative evaluation strategy that combines the pros from both — lazy evaluation. ...

September 18, 2018 · 5 min · Kevin Sookocheff

Representing Pairs and Lists in Lambda Calculus

Having covered types, let’s now turn our attention to lists. Lists are general purpose data structures for storing sequences of items. In lambda calculus, lists are represented using pairs, with the first item of the pair representing the head of the list, and the second item representing the rest of the list. A special value, nil, at as the second item of the pair terminates the list. Pairs Let’s start by focusing on pairs (or tuples). A pair is built from two arguments, \(a\) and \(b\), and returns a function \(f\) enclosing those two arguments: ...

September 7, 2018 · 3 min · Kevin Sookocheff

Typed Lambda Calculus

Lambda calculus is a very simple language. If you take away any syntactic sugar, all you are left with is functions that take arguments and return results. You can use these simple building blocks to construct functions that represent numbers and arithmetic, but there is no way to restrict, for example, arithmetic functions to require numeric operands. This is where types come in. Generally speaking, types allow you to control the use of functions so that only meaningful combinations of inputs and outputs are used. ...

August 21, 2018 · 4 min · Kevin Sookocheff