Category: tech

MongoDB Majority Read Concern

One common misconception of mongos read concern: majority is that it’s reading from a majority of nodes. This is understandable because it’s counterpart write concern: majority requires acks from the majority of nodes. But that’s not at all what read concern does. Reads always get submitted to a single node using a server selection process […]

SAML and OAuth Purposes

Lets assume you’re the owner of COOL WEB APP. Typical authentication with a web services involves the user providing specific credentials for your app like email and password. This information gets transmitted in a HTTP request and your backend verifies the credentials and grants access to user. Hopefully you also store the user credentials in […]

There is no such thing as “non-relational” data

In data modeling discussions I often hear the phrase “non-relational data”. It’s usually someone making a case for why data should be in a NoSQL store or just denormalized in general. The argument is usually that the data itself is somehow inherently “non-relational” and so it should be put in a non-relational database. Calling data […]

How two phase locking prevents lost updates

Two phase locking is an old method of ensuring serializable transactions using locks. A common issue with non-serializable isolation in the fact of concurrent writes is the lost update problem. Here’s an example of a lost update, lets assume: Some databases will detect a write conflict like this and raise an error and others may […]

MongoDB Read Preferences

MongoDB read preferences give you control over read behavior when using replicasets. Writes in every environment go to primary, but reads can be configured to read from secondary or primary based on various criteria. In most versions of mongo, the read preference defaults to primary in the client but you should check your version for […]

Why the words in “CAP theorem” are so confusing!

Consistency The word “consistency” is extremely overloaded in the realm of distributed systems. In CAP, consistency means (informally) that every read reflects the most recent write. This is also known as single-copy consistency or strict / strong consistency. Data is replicated to multiple nodes in these systems, but any reads to this storage system should […]

SICP Exercise 1.11 – Recursive & Iterative

Prompt A function f is defined by the rule that f(n) = n if n < 3 and f(n)=f(n-1) + 2*f(n-2) + 3*f(n-3) if n >= 3. Write a procedure that computes f by means of a recursive process. Write a procedure that computes f by means of an iterative process. Hint: for iteration, think about how you might code this using a for-loop in a language like […]

SICP Exercise 1.9 – Process Illustration

Prompt Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements its argument by 1 Using the substitution model, illustrate the process generated by each procedure in evaluating (plus-v1 4 5) and (plus-v2 4 5). Are these processes iterative or […]

SICP Exercise 1.6 – Cond as If?

Prompt Alyssa P. Hacker doesn’t see why if needs to be provided as a special form. “Why can’t I just define it as an ordinary procedure in terms of cond” she asks. Alyssa’s friend Eva Lu Ator claims this can indeed be done, and she defines a new version of if: Eva demonstrates the program for Alyssa: Delighted, Alyssa […]

Difference between Docker ENTRYPOINT and CMD

ENTRYPOINT and CMD are two docker commands that sound interchangeable, but there are important differences that I’ll cover in this post. I suspect CMD is probably the more familiar instruction, so I’ll go over what that does and how it differs from ENTRYPOINT. Here’s the purpose of CMD, taken straight from the docker manual: The […]