anuj Archive

Strong Consistency Models and HTTP

In a wonderfully-written article, Kyle Kingsbury explores different models of strong consistency and I thought it would be interesting to consider how to apply some of these concepts in the context of the HTTP protocol given the prevalence of web APIs in modern architectures. HTTP is an amazingly expressive protocol, especially for caching semantics, yet in my experience

Zombie vs Orphan process

When a process terminates, its resources are deallocated by the operating system. However, its entry in the process table must remain there until the parent calls wait(), because the process table contains the process’s exit status. A process that has terminated, but whose parent has not yet called wait(), is known as a zombie process. All

Protocol fundamentals

Source: OSI 7 layer model Hypertext transfer protocol (HTTP) HTTP is a method for encoding and transporting data between a client and a server. It is a request/response protocol: clients issue requests and servers issue responses with relevant content and completion status info about the request. HTTP is self-contained, allowing requests and responses to flow

Asynchronism

Source: Intro to architecting systems for scale Asynchronous workflows help reduce request times for expensive operations that would otherwise be performed in-line. They can also help by doing time-consuming work in advance, such as periodic aggregation of data. Message queues Message queues receive, hold, and deliver messages. If an operation is too slow to perform

Caching Fundamentals

Cache Source: Scalable system design patterns Caching improves page load times and can reduce the load on your servers and databases. In this model, the dispatcher will first lookup if the request has been made before and try to find the previous result to return, in order to save the actual execution. Databases often benefit

Database Notes

  Relational database management system (RDBMS) A relational database like SQL is a collection of data items organized in tables. ACID is a set of properties of relational database transactions. Atomicity – Each transaction is all or nothing Consistency – Any transaction will bring the database from one valid state to another Isolation – Executing transactions concurrently has the same

Multithreading and Multiprocessing in Python

To begin with, let us clear up some terminlogy: Concurrency is when two or more tasks can start, run, and complete in overlapping time periods. It doesn’t necessarily mean they’ll ever both be running at the same instant. Eg. multitasking on a single-core machine. Parallelism is when two or more tasks are executed simultaneously. A

Temporary failure resolving – sudo apt-get update in ubuntu

If you are trying to update ubuntu respository and getting error: W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg  Temporary failure resolving ‘us.archive.ubuntu.com’ just check the DNS. Set the Google DNS (8.8.8.8) in /etc/resolvconf/resolv.conf.d/base [crayon-5bf2fca96fdbb283110491/] then [crayon-5bf2fca96fdc7042560460/] After this procedure, I was able to resolve hostnames and [crayon-5bf2fca96fdcd483956040/]

Bash script to get average time from logs

What if we have logs of a server like apache or syslog server and we want to get average time from timestamps of all rows. How can we do it? Basically, we need to filter timestamp (column-8) from each row and just find its average. Below is the screenshot of the problem. (click on the