anuj Archive

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-5ded8ee310a76586415076/] then [crayon-5ded8ee310a94126413062/] After this procedure, I was able to resolve hostnames and [crayon-5ded8ee310aa5927983047/]

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

Kill multiple pid with same process

Sometime back I caught up in a situation where I need to kill multiple pid invoked from same process. So, all process have same name Assume, process invoked for “vim” editor. If I have 20 “vim” process running and I want to kill all of them, what’s the best way to do it? #There are multiple ways:

TCPDUMP examples

Tcpdump is a command-line based packet capture tool like wireshark which is GUI. Capture all traffic on ethernet interface: $tcpdump –i eth0 2. Filter by host IP-address: $tcpdump host 10.0.2.15 3. Filter traffic by source and destination ip-address: TCPDUMP filter by source and destination:             $tcpdump src 10.0.2.15