Concurrency in Go in the form of goroutines is a very convenient means for writing modern concurrent software, but how does your Go program run these goroutines efficiently?
In this post, we will peek under the hood to help you understand how the Go runtime scheduler implements this magic by looking into it from the design perspective and how to use it to interpret scheduler trace information from a Go program during performance debugging.

All of the engineering marvels have come out of need, So to understand why there is a need to have a go runtime scheduler and how…


Go has a built-in testing framework provided by the testing package, that makes writing tests easier, but how do we write a more complicated test that requires mocking?

In this post, we will learn how to take advantage of structs and interfaces in Go to mock any service or library you might be using, without using any 3rd party tools and libraries.

We will start by defining our system to understand what we are going to test and mock.

System


With examples in Go (Golang).

Whether you’re just getting started with programming, or you have years of experience, you’ve likely at some point of the time will do or have done some performance test of your application to measure the Latency (Latency is defined as the time it took one operation to happen).

When it comes to latency result analysis, It’s tempting to reach for basic statistics like mean, median or max. But this ignores relevance problems — turning the focus away from latency behavior distribution over time toward others, which often hide the truth.

Actual Vs Mean(Avg), Median, Max report.

The objective of this blog post is to explain the…


A simple and brief introduction to CSP, it’s terminology, and it’s similarities to Go.

Communicating Sequential Processes (CSP) for short, is what we hear whenever a Go concurrency is discussed and how it’s an elixir for concurrent programming. When I heard this term for the first time, I started to think that,

Is CSP some sort of new technique or an algorithm that makes writing concurrent code so simple?

What turned out after reading the CSP original paper was nothing fancy — a simple concept (which was later formulated into the Process calculus to reason about the program correctness) solving concurrency through two primitives of programming.

  1. Input.
  2. Output.

The paper abbreviates the term processes


When I first started trying to understand the memory allocator of Go, it was maddening. Everything seemed like a mystical black box. As almost every technical wizardry is hidden beneath abstractions, you need to peel off those layers one by one to understand it.

In this blog post, we will exactly do that. Do you want to learn everything about Go memory allocator? You’re reading the right article.

Translated by readers into: Russian, Chinese.

Physical and Virtual Memory

Every Memory Allocator needs to work with the Virtual Memory Space that is managed by the underlying Operating System. Let’s see how it works.

A simple illustration of a Physical Memory Cell (Not an exact representation)

A greatly…


A detailed look of the Go type system, with examples

The mascot and logo designed by Renée French.

Let’s begin by asking a fundamental question.

Why we need a type?

Before answering that, we need to look at some of the primitive abstracted layers of programming languages that we don’t usually deal with.

How close can we get to a machine representation of data?


An “ins and out” of the internal implementation of the Golang channels and its related operations.

Concurrency in Golang is much more than just syntax.

It a design pattern.

A pattern that is a repeatable solution to a commonly occurring problem while working with concurrency, because even

Concurrency Needs to be Synchronized.

And Go relies on a concurrency model called CSP ( Communicating Sequential Processes), to achieve this pattern of synchronization through Channel. Go core philosophy for concurrency is

Do not communicate by sharing memory; instead, share memory by communicating.

But Go also trusts you to do the right thing…


Photo by Jeff Griffith on Unsplash

The title may lead you to think that this post is another ranting post about the downside of a “Single Page Application”. It is more about shedding some light on the performance perspective to keep in mind while designing the SPA. Especially if your SPA consumes APIs from different domain services.

If you are designing an SPA which consumes the API from the same domain of the SPA, then great. You should skip this article if your SPA only pulls from the API on the same domain.

Most SPAs involve “microservices.” They consume different endpoints of services serving by different…


The web application uses the browser/server architecture, HTTP as the communication protocol. HTTP is a stateless protocol. Each time the browser requests, the server processes it independently and does not associate with the previous or subsequent request. But it also means that any user can access the server resources through the browser. If you want to protect some resources of the server, you must restrict the browser request; to limit the browser request, you must authenticate the browser request, respond to the legitimate request, ignore Illegal request; to authenticate a browser request, you must be aware of the browser request…


I completely agree with the fact that “premature optimization is the root of all evil (or at least most of it) in programming”. But it makes no harm sometimes to know the bits of your code that you write and how it affects the environment for which you are writing your code.

This post is more about learning some of these bits of JavaScript, especially in Node.js environment with v8 core not to favour this micro-optimization because business code is still more concerned about readability and maintainability.

So what exactly we are looking at?. For the legibility of the remaining…

Ankur Anand

Learning to Learn in Feynman Technique. -https://ankuranand.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store