<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aniruddha Chakraborty on Medium]]></title>
        <description><![CDATA[Stories by Aniruddha Chakraborty on Medium]]></description>
        <link>https://medium.com/@anichakraborty?source=rss-c11d1a723851------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KzLOI40zZWDyoB3W.</url>
            <title>Stories by Aniruddha Chakraborty on Medium</title>
            <link>https://medium.com/@anichakraborty?source=rss-c11d1a723851------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:46:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anichakraborty/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to resolve connection timeout issue in Kubernetes Ingress]]></title>
            <link>https://anichakraborty.medium.com/how-to-resolve-connection-timeout-issue-in-kubernetes-ingress-a64caf2f311e?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/a64caf2f311e</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[time-out]]></category>
            <category><![CDATA[connection]]></category>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 00:05:53 GMT</pubDate>
            <atom:updated>2023-08-26T07:21:36.527Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TOh5LciQ152aDY731OqMOQ.jpeg" /></figure><p>When building infrastructure at scale and you have to handle billions of data, there are a lot of places where we need to optimize it, for better performance and lower server costs.</p><p>We had similar problems after deploying our multi-regional infrastructure. In DigitalOcean we use load-balancers service in order to forward requests to clusters. In user-based services, we don’t have to worry about connection timeout because in most cases 30 seconds timeout isn’t a problem.</p><p>But in ad tech, maintaining a connection from a browser for that long stresses out load balancers. Because even no-brainer network load balancers also have limitations. For example in DigitalOcean load balancers can handle 10,000 connections concurrently per node, which is a lot! But in AdTech you have to finish serving ads within milliseconds time. So holding on to a connection for 30,000 milliseconds on default where you don’t really need more than 60 milliseconds is just nasty.</p><p>We engineers when try to solve using already defined values, or options that might be provided by nginx ingress. But I think going back to basics can solve this. Just we need to add, how we used to write configuration as snippets in nginx config.</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: cluster-ingress<br>  annotations:<br>    kubernetes.io/ingress.class: &quot;nginx&quot;<br>    service.beta.kubernetes.io/do-loadbalancer-name: &quot;load-balancer&quot;<br>    service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: &quot;true&quot;<br>    nginx.ingress.kubernetes.io/server-snippet: &quot;keepalive_timeout 1s; client_body_timeout 1s;&quot;</pre><p>Add config to nginx.ingress.kubernetes.io/server-snippet just like I did and you can control your session timeouts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0oYcD3ZM_CDTY4lUDPgh0A.png" /></figure><p>This is a result that I’ve produced in tests, instant connection drop. Hopefully, this helps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a64caf2f311e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform remote state backup with Digital Ocean Spaces]]></title>
            <link>https://anichakraborty.medium.com/terraform-remote-state-backup-with-digital-ocean-spaces-697e35128a6a?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/697e35128a6a</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[remote]]></category>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[digitalocean]]></category>
            <category><![CDATA[space]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Sun, 08 Jan 2023 07:48:06 GMT</pubDate>
            <atom:updated>2023-01-14T17:19:02.510Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ZbR1zhd4Jzv2aCChvUuLvA.jpeg" /></figure><p>We all are so used to AWS nowadays, so terraform decides to make it a default to use AWS as terraform backup backend. Not everyone uses AWS in their daily lives, for cost-effectiveness people choose Digital Ocean. We’re are one of them.</p><p>As I maintain the whole infrastructure myself as an SRE it’s my job to do as much automation as possible. After converting our whole infrastructure to IAC. I’ve got a little bit worried about the state file that terraforms creates and is modified every time I change something in the infrastructure. As I was writing an automation script for terraform script deployment as multiple people started to work on IAC, I found our Digital Ocean is a bit different. You kind of have to trick terraform into believing that it is still using AWS as a backend.</p><p>First, create a bucket &amp; then generate the DigitalOcean API key &amp; Secret to use on terraform. You can go to API on DigitalOcean and create those like those shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwQkquCpOOU_uljFTLfM8g.png" /></figure><p>Then, install AWS <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">CLI</a> on your machine. Then you have to create a profile</p><pre>aws configure --profile digitalocean</pre><p>Put key &amp; secret. It will create a profile of the DigitalOcean with its access keys.</p><p>Then change AWS_PROFILE to your created “Digital Ocean” Profile.</p><pre>export AWS_PROFILE=digitalocean</pre><p>Then, just like shown in the code you have to add a backend code block.</p><p>There are a few things you might need to notice:</p><ul><li>where the region is from AWS because terraform doesn’t recognize DigitalOcean regions, even after adding endpoints.</li><li>You don’t need to use the original URL that is given in the bucket. You can just use the part after the bucket name.</li><li>The bucket name should be the one you want to put the state files in.</li></ul><pre>terraform {<br>  required_providers {<br>    digitalocean = {<br>      source = &quot;digitalocean/digitalocean&quot;<br>      version = &quot;~&gt; 2.0&quot;<br>    }<br>  }<br>  backend &quot;s3&quot; {<br>    endpoint                    = &quot;sgp1.digitaloceanspaces.com&quot;<br>    key                         = &quot;terraform.tfstate&quot;<br>    bucket                      = &quot;bucketname&quot;<br>    region                      = &quot;ap-southeast-1&quot;<br>    skip_credentials_validation = true<br>    skip_metadata_api_check     = true<br>  }<br>}</pre><p>And that’s it. This is nothing complicated but just you need to where you need to do the changes in order to make this thing work. Adios!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=697e35128a6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-regional Infrastructure deployment on Kubernetes with Docker, Jenkins, and GitHub]]></title>
            <link>https://anichakraborty.medium.com/multi-regional-infrastructure-deployment-on-kubernetes-with-docker-jenkins-and-github-be41e5a20f36?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/be41e5a20f36</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[multi-region]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Thu, 09 Sep 2021 13:21:41 GMT</pubDate>
            <atom:updated>2021-09-09T16:47:21.510Z</atom:updated>
            <content:encoded><![CDATA[<p>I am working for a tech company for the last 2 years and our team goal was to make our whole infrastructure handle a minimum of 200–400 billion requests per month across multiple countries and multiple data centers. I’m learning a lot about how to handle this insane amount of requests with smart and painless deployment. This is a blog about how you should handle multi-regional deployment with minimal complexity. I won’t go into how to set up things from scratch in this blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5-LJw8RG96qMMxPZeKcV5w.png" /></figure><p><strong>Problem:</strong></p><p>First Lets discuss the situation here. Say, we have 6 micro-services and every microservice is stateless and it scales infinitely but Not all regions need all the services and also you need to control the deployment of services to specific regions for specific microservices. There is also a twist for every Kubernetes cluster you have to maintain multiple namespaces for like testing, staging, and production. They all have different configurations how will you handle that? and the last problem is while testing on namespaces other than production or running JMeter application to test you shouldn’t mess up with production allocated CPU/RAM.</p><p><strong>Manage multiple environment configurations in Github:</strong> You can create a repository to store multiple microservice environments from here. Every microservice config will be a file and every namespace can be a config file name.</p><p><strong>Building Docker image by pulling configuration from GitHub raw on the fly:</strong> When you’re building a docker image for a particular microservice on Jenkins you can pass for which namespace you’re building the image by passing argument using the ARG feature of docker. While pulling the configuration you can use single line fetch using GitHub raw. For example, let&#39;s say we have a Dockerfile like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3a4aeff52682d38ee669bebb30b7423/href">https://medium.com/media/c3a4aeff52682d38ee669bebb30b7423/href</a></iframe><p>You need to change few things like ARG, install curl to fetch the required config and save it as .env and work with it. You can build your docker image by passing an argument on shell script like this:-</p><pre>docker build -t org/service:$BRANCH_NAME . --build-arg BRANCH_NAME=$BRANCH_NAME</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bd0c08c4f6fabd3c287a6de783dbbbe/href">https://medium.com/media/8bd0c08c4f6fabd3c287a6de783dbbbe/href</a></iframe><p>Now you have a docker container ready to ship to all the Kubernetes clusters available for a particular namespace.</p><p><strong>Push new images and replace previous ones in dockerhub.io:</strong> You can push to specific tags every time if you don’t need the previous one.</p><p><strong>Ping to Kubernetes clusters:</strong> It’s like shouting to everyone in the room “Hey! Food is ready!”. So when you ping Kubernetes clusters using this command by using configuration from Github. You need to store different cluster access files to another repository which helps you to access the clusters that you want to ping.</p><pre>kubectl --kubeconfig=&quot;cluser-key.yaml&quot; -n staging rollout restart deployment.apps/service-name</pre><p>You can write a Jenkins file for every service and specify which region you want to push this service into. Your Jenkins file should look like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1147951bf2129309cbfa49d16680729/href">https://medium.com/media/a1147951bf2129309cbfa49d16680729/href</a></iframe><p>For controlling resources on a cluster level you should use Kubernetes in case you put too much load while testing using the ResourceQuota feature from Kubernetes which helps to limit resources for a particular namespace.</p><p>And you’re done! You can use ansible in a deployment process and there are more complex and cooler ways you can deploy on a multi-regional level which we’re working on it but let’s discuss in another blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be41e5a20f36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Horizontally Scaling NoSQL data across multiple servers with MongoDB sharded clustering for High…]]></title>
            <link>https://anichakraborty.medium.com/horizontally-scaling-nosql-data-across-multiple-servers-with-mongodb-sharded-clustering-for-high-11076ce7ec17?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/11076ce7ec17</guid>
            <category><![CDATA[sharding]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[shard]]></category>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Sat, 28 Nov 2020 18:48:14 GMT</pubDate>
            <atom:updated>2020-11-28T18:56:21.148Z</atom:updated>
            <content:encoded><![CDATA[<h3>Horizontally Scaling NoSQL data across multiple servers with MongoDB sharded clustering for High availability.</h3><p>When we start dealing with too much data our current system can handle we have 2 options, scale horizontally or Vertically. Vertically scaling is often way more expensive because we have to put too much power in a single machine. it also became vulnerable for a term called a single point of failure. Adtech firms like ours needs MongoDBs clustering with HA for better data reliability and blazing fast speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*W5gOYGFVYLyNPSC_tzkN5g.png" /></figure><p>Most of the example in the web show example using a single machine, it means they setup everything in the single machine but here I&#39;ll explain everything how to setup in actual production using multiple cloud servers that communicate between private but mongos router is open to the public to receive connections from anywhere in the world. Our Setup will look like the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*I5P1sM5nrzWTIoRKJ-REgg.png" /></figure><p>I’ll do the MongoDB clustering on multiple servers in digital ocean. In “mongo-shard-01” I’ll setup 3 shard replica sets and in each replica set, there will 3 replica servers running, In “mongo-config-server” I’ll put my configuration of all my shards. and “mongo-router-01” will have mongos setup for data routing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dCiY9jC5vWGBViK6uNwYVw.png" /></figure><p>Now first lets setup mongo in all the servers first by following <a href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/">this</a> instruction.</p><p><strong>Step 1- Setting up the Sharding server</strong></p><p>We will setup 9 replica or 3 replica sets and start them as 3 shards in “mongo-shard-01” using the below commands.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1150250ba0f849524d06b2e06381457e/href">https://medium.com/media/1150250ba0f849524d06b2e06381457e/href</a></iframe><p>After executing this command check using “<strong>ps -ef | grep mongod</strong>”. You’ll see 9 replica is running. Now we have 3 shards every shard is consist of 3 replicas now we have to configure every shard.</p><p>I chose 27017,37017,47017 as primary replicas, where shard1 primary replica is 27017, for shard2 37017, and for shard3 is 47017.</p><p>login into mongodb with port 27017 and run these codes. i’ve commented out which code executes where.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c99f293ad92e61d4eb7cd8c44fe95327/href">https://medium.com/media/c99f293ad92e61d4eb7cd8c44fe95327/href</a></iframe><p>After every primary shard setup you’ll have something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*_uZVILZHriaAzcIu_aajYw.png" /></figure><p>And after a few seconds, the node will become primary and other nodes will become secondary. Just like the next image. Do this for all 3 ports mentioned and you’ll get results like mentioned in screenshots. using <strong>rs.status()</strong> you’ll can you’re connected to other nodes as well all the nodes send each other heartbeat so that each node knows which one is alive and which isn’t. And don’t forget to run <strong>rs.secondaryOk()</strong> in all other secondary nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*WJtldyAEKEtOHPNnpYTeKA.png" /></figure><p>Now You finally Completed setting up the hard part all you have to do now is to setup a config server cluster for three shards and connect them to mongos router.</p><p>Config servers are the backbone of this clustered structure, they seem to do nothing but they actually control and know everything about available shards, that’s why I put the config instances in a different machine. In “Config-server” the machine I executed the below command to spawn new 2 new config servers 1 primary and the other is secondary.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35dda9cc68e36ac88a58c2cc3f33aef3/href">https://medium.com/media/35dda9cc68e36ac88a58c2cc3f33aef3/href</a></iframe><p>Check using “<strong>ps -ef | grep mongod</strong>” command that 2 instances are running. Then run this below config in 57040 mongo port. Your config server setup will be done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce48bbf56372e7fd10447a8a5160ef13/href">https://medium.com/media/ce48bbf56372e7fd10447a8a5160ef13/href</a></iframe><p>Now let move into the Mongos which is mongo data router. Lets execute this so you’ll have your mongo</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4732083b156d7791d446c79c5471c4d5/href">https://medium.com/media/4732083b156d7791d446c79c5471c4d5/href</a></iframe><p>And There you go! mongos is connected and configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iSyLjOa2ChQxeOUQi-lMPQ.png" /></figure><p>After adding all the shards into the mongos router you’ll get something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*BNItowa8-OW-2qV3mRqeZA.png" /></figure><p>To see full data of shards including their replica set you can check using “db.adminCommand({listShards:1})”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*X0FZ5dcVipl1z9_AwsvtIA.png" /></figure><p>Congratulations! We finally setup a multi-server clustering with 2 replication servers on standby!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11076ce7ec17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a replica cluster with MongoDB 4.2]]></title>
            <link>https://anichakraborty.medium.com/setting-up-a-replica-cluster-with-mongodb-4-2-598141762652?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/598141762652</guid>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Sat, 28 Nov 2020 05:53:16 GMT</pubDate>
            <atom:updated>2020-11-28T07:36:58.263Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up a replica cluster with MongoDB 4.4</h3><p>I’ve been working with a very optimization hungry application that will handle a huge amount of important ( approx50 billion read and writes ) data that requires replication and sharing at the same time. Here I’ll explain how you’ll set up multiple replications to your MongoDB 4.4 database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ru2WBaCBZ7kjgxD7dCNb0g.png" /></figure><p>Follow <a href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/">this</a> instruction for installing MongoDB on your server on ubuntu. I’m using the ubuntu cloud server for this demo.</p><p>First, let’s make our MongoDB server available to the public, run this command bellow. go to “/etc/mongod.conf” and change the bind IP from 127.0.0.1 to 0.0.0.0 and restart MongoDB</p><pre>sudo service mongod restart</pre><p>We’ll have 4 mongo replica instances where 1 will be used as primary and others will use as secondary. In order to do that let’s create 4 directories where individual replica sets will store their data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4680b9477d65c071c4d293210b0c088/href">https://medium.com/media/e4680b9477d65c071c4d293210b0c088/href</a></iframe><p>Now with <strong>ps -ef | grep mongod</strong> command you can see all your replica MongoDB instances are running then we’ll log in to one of the replica servers I’ll log into the replica that is running in port 27018.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a95726d27f32931104ab5d005189345/href">https://medium.com/media/9a95726d27f32931104ab5d005189345/href</a></iframe><p>Run this code inside in the replica server of 27018 and wait some time for turn itself into the primary node. You can put any IP instead of “localhost”. Now go to 27017,27109,27020 mongo replica instances and execute rs.secondaryOk() . This means other nodes accepted themselves as a secondary node. you can tweak their priority and voting rights with rs config also from the primary.</p><p>And That’s it! this is how you setup replica servers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=598141762652" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Laravel like service container in Go in 10 minutes]]></title>
            <link>https://anichakraborty.medium.com/building-a-laravel-like-service-container-in-go-in-10-minutes-45d610c8bcf0?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d610c8bcf0</guid>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Sat, 13 Jun 2020 19:47:12 GMT</pubDate>
            <atom:updated>2020-06-14T18:31:28.759Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Laravel like simple service container in Go in 10 minutes</h3><p>I’ve worked on a project that needs to be written in Golang for various reasons. but our discussion is how we would write a simple yet effective and efficient service container in GO.</p><p>We know the service container term from the book “Gang of Four”. But most of the developers learned about this code structure from Laravel Or Ruby on rails. The word service container explains itself “it contains the services ”. So depending on the use, we can access the entire application using a very simple access structure. This helps to gain full control of every single corner of your codebase from every single corner of your code.</p><p>Seems easy but pretty confusing right? Let’s try to explain with some Go code. Though you can build a service container using reflect module, as you know reflect is very expensive in Go. For us, We would use our knowledge of struct and type assertation.</p><p>Our Code Folder structure should look like this.</p><figure><img alt="Simple service container Folder structure." src="https://cdn-images-1.medium.com/max/304/1*FCtU8J9I0gmLfZ2CSEpLgg.png" /></figure><p>As you know every folder here represents a package in Golang. So in here container, controllers, providers, and services are different modules.</p><p>In the container module let’s write container.go</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a94a91e5780228de8f056815d153335/href">https://medium.com/media/1a94a91e5780228de8f056815d153335/href</a></iframe><p>As you know In Golang interface{} slightly works like Object in javascript. Almost everything means interface{} in Golang but when you need to work with them you might have to use type assertation. Though Go is a functional programming language, here I’m using a singleton design pattern, but you can introduce a factory pattern here if you need it.</p><p>Now let’s write a service and put it into the service module.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b710d263eb05756c2b820833e6c13e1c/href">https://medium.com/media/b710d263eb05756c2b820833e6c13e1c/href</a></iframe><p>This is a very simple struct that has a single method in it.</p><p>Now I have to register this provider into the provider</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83bd548f361b95d3299b40cb5bb3ee60/href">https://medium.com/media/83bd548f361b95d3299b40cb5bb3ee60/href</a></iframe><p>We imported the service module and put it into the container.</p><p>Now the main magical part.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8291c3cc5f53eebb5c838e3f06a88317/href">https://medium.com/media/8291c3cc5f53eebb5c838e3f06a88317/href</a></iframe><p>Here I’m creating a global container first so that I can inject to every provider that needs it, this will be making my container a central controlling ground where I can access anything. Now I’ll initialize the provider struct followed by a function call with container argument. Now When we need those services we must you need to use type assertation, to define which type of service you’re accessing and THAADAAA!</p><p>you wrote a mini Laravel in Golang in just 10 minutes. The power of a service container is you can load any connection anywhere anytime. The code will be slightly complex but the control over your code is enormous. This means as far you have the global container variable in your codebase you can access anything anywhere from your codebase anytime.</p><p>Note: I tried to explain this in a very simplistic manner so that everyone understands the underlying concept of it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d610c8bcf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[আচ্ছা ভাই, টিউটোরিয়াল দেখে কিছু বুঝিনা, কিভাবে বুঝবো টিউটোরিয়াল থেকে?]]></title>
            <link>https://anichakraborty.medium.com/%E0%A6%9F%E0%A6%BF%E0%A6%89%E0%A6%9F%E0%A7%8B%E0%A6%B0%E0%A6%BF%E0%A7%9F%E0%A6%BE%E0%A6%B2-%E0%A6%8F%E0%A6%B0-%E0%A6%AE%E0%A6%BE%E0%A6%A7%E0%A7%8D%E0%A6%AF%E0%A6%AE%E0%A7%87-%E0%A6%95%E0%A7%8B%E0%A6%A8-%E0%A6%95%E0%A6%BF%E0%A6%9B%E0%A7%81-%E0%A6%87%E0%A6%AB%E0%A7%87%E0%A6%95%E0%A7%8D%E0%A6%9F%E0%A6%BF%E0%A6%AD-%E0%A6%AD%E0%A6%BE%E0%A6%AC%E0%A7%87-%E0%A6%95%E0%A6%BF%E0%A6%AD%E0%A6%BE%E0%A6%AC-%E0%A6%B6%E0%A6%BF%E0%A6%96%E0%A6%AC%E0%A7%87%E0%A6%A8%E0%A7%87-f455c51884ee?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/f455c51884ee</guid>
            <category><![CDATA[project-based-learning]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Wed, 14 Mar 2018 00:12:58 GMT</pubDate>
            <atom:updated>2018-03-14T01:31:08.364Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*Qcmi3sw_9aP-3XlToCYN1g.jpeg" /></figure><p>যারা প্রথমে প্রোগ্রামিং শিখতে চান তারা অনেক উচ্চাখাঙ্খা নিয়ে শুরু করেন , কেউ টিউটোরিয়াল দেখে , কেউ বা বই পড়ে । কিন্তু বিগিনার লেভেলে প্রায় মানুষই টিউটোরিয়াল দেখে শুরু করে । কিন্তু পরে কমপ্লেইন শোনা যায় যে তারা কিছুই মনে রাখতে পারছেন না বা মনে হচ্ছে যেনো তিনি কিছুই বুঝতে পারছেন না । এটা সাধারণত প্রজেক্ট বেইজ টিউটোরিয়াল গুলোর ক্ষেত্রে বেশী হয় ।</p><p>এর সল্যুশন কিন্তু অনেক সিম্পল । একটা প্রজেক্ট বেইজ টিউটোরিয়াল টা ৪ বার একটু ভিন্ন উপায়ে শেষ করলে আপনি নিজেই বুঝে যাবেন কোথা থেকে কি হচ্ছে । প্রথম বার মূলত টিউটোরিয়াল গুলো একবার দেখে যাবেন। প্রথমেই ফলো করে কিছু কোড করার দরকার নেই , টেনে টেনে দেখে গেলেই হবে অনেকটা ফিল করার মত , খাওয়ার আগে খাবারের গন্ধ নেয়া টাইপ এর। কিন্তু প্রথমে আপনার অবশ্যই আপনার ব্যাসিক ক্লিয়ার করে নিবেন আগে ।</p><p>এরপর ২য় বার যখন টিউটোরিয়াল সিরিজ দেখা শুরু করবেন তখন একদম হুবহু স্ক্রিনে টিউটোরিয়াল এর টিউটর যা লেখছেন ঠিক সেটাই নিজের কোড ইডিটর এ চালানো শুরু করবেন একদম অন্ধের মত ফলো করা যাকে বলে কিন্তু হাল্কা বুঝে যেহেতু ছোট খাটো বাগ হলে ফিক্স করতে হবে আপনারই ।</p><p>এরপর আসি ৩য় লুপ এ এবার আপনি আস্তে আস ভালোমত বুঝে বুঝে টিউটর এর মত কোড লেখে প্রজেক্টটিকে আবার বানাবেন , কোথাও ঠেকে গেলে নানা গ্রুপে জিজ্ঞাসা করবেন বা এক্সপার্ট এর সাহায্য নিবেন ।</p><p>চতুর্থ বার আর টিউটোরিয়াল ফলো করবেন না । আপনার সেই আগের লেখা কোড টাই ফলো করবেন । কখনো ঠেকে গেলে আগের লেখা কোড থেকেই রেফারেন্স নিবেন ।</p><p>এটা অনেক টাইম কন্সিউম করে শেখার উপায় কিন্তু এটা প্রথম ২-৩ টা প্রজেক্টের ক্ষেত্রেই প্রযোজ্য । প্রজেক্ট কিভাবে বানাতে হয় এর উপর অনেক গভীর ধারনা হওয়া শুরু করবে । এরপর আপনি নিজে নিজেই ডিসিশন নিতে পারবেন কিভাবে নিজে নিজে প্রজেক্ট বানানো শিখে যাবেন । কিন্তু এটাই শেখার শেষ না এরপর প্রতিটা কোড ব্লক কোনটা কিভাবে কাজ করে , ক্যামন সিপিউ কমসিউম করছে এগুলো আপনার খেয়াল রাখতে হবে ।</p><p>এই ব্লগ লেখার মুল উদ্দেশ্য হলো যারা প্রথম বার এর মত প্রজেক্ট বানানো শিখতে যাচ্ছেন , শুধু তাদের জন্য । যখন একবার জিনিসটা আয়ত্তে এসে যাবে তখন আপনার আর কখনোই পিছে ফিরে তাকাতে হবেনা । প্রসেস টা বেশ টাইম কন্সিউমিং তাই একটু ধৈর্য রাখতে হবে আর কিছুনা।</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f455c51884ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Story of Struggles: 2017 Edition]]></title>
            <link>https://anichakraborty.medium.com/reasons-behind-i-was-deactivated-for-last-6-months-646be131e305?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/646be131e305</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[reason]]></category>
            <category><![CDATA[depression]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 14:31:12 GMT</pubDate>
            <atom:updated>2017-07-11T14:37:26.997Z</atom:updated>
            <content:encoded><![CDATA[<p>From a distance, it may seem like 2017 was probably not one of the best years in my life. Due to stress and workload, my academics got hit pretty bad; which showed up as a clear down-slope in my grades. It wasn’t quite easy for me to cope with this. I constantly have been pressured to stop working professionally from my family. Mainly because they place a lot of importance in academics and grades — for good reasons! My family was under the impression that I have been neglecting studies due to the work I took pride in doing, felt passionate about achieving.</p><p>I have been working on a project named “IPDC”, which was my first project written in python that was actually production-grade! I was having a great time working on it — learning, enjoying and exploring the wonderful world of Python programming.</p><p>However, I wasn’t ready for what was about to come. No one of my family had ever foreseen, or even imagined this. It hit us like a thunder-strike. It was the news of my grandmother getting diagnosed with a form of cancer.</p><p>I had to take responsibility as a grandson, I had to step in. My mother and I took up the task of arranging for the treatment of my grandmother. Tests after tests, biopsies after biopsies — I had no other choice but to start missing classes, quizzes and exams. It came to the point where I had to actually write applications requesting for permission to attend finals, with zero presence in the course!</p><p>This was official. I could not get a passing grade in three courses.</p><p>Surprises were not done with me, not at least then. One of my very close ones fell terribly ill, and during her illness I couldn’t just ignore that friend. I had act like a responsible person, I was obliged to.</p><p>My productivity took a U-turn. It looked like the valley of a sine wave. It didn’t skip the peripherals of my work; I was notified of my unusually strange lack of productivity! No one at my work every imagined my productivity going so downhill.</p><p>The last few months took a toll on me, my family, my loved ones, my academics and my perception of living. I have decided to devote the following year to exploring, learning and improving myself along with regaining my energy. As of now, I am planning to spend my time primarily working on open source projects and competitive programming. I want to get back to my track, and your best wishes are essential. Thanks for being by my side!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=646be131e305" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Generating PDF in Backend is a bad idea!]]></title>
            <link>https://anichakraborty.medium.com/why-generating-pdf-in-backend-is-a-bad-idea-15c089a67196?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/15c089a67196</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[generator]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Wed, 05 Jul 2017 11:05:48 GMT</pubDate>
            <atom:updated>2017-07-05T11:30:19.409Z</atom:updated>
            <content:encoded><![CDATA[<p>Generating PDF for balance sheets is a common thing, but it becomes painful for developers to generate a pdf with a proper unicode support even if libraries have proper unicode support. A lot of problem pops up out of nowhere during development.</p><p>I was building an account management system where client gets all kinds of information in pdf which the client can then print and work with.</p><p>I used a python version of wkhtmltopdf but that failed miserably to generate a pdf with bangla characters, so I started to generate using shell commands of wkhtmltopdf using an node.js’ command executor library.</p><p>It was working fine on my development server and laptop until moved the whole codebase into the production server instead of showing bangla fonts production server started to show joke. Pretty little cubes were printed instead of words. It felt like rain and sunshine hitting my lovely shaved head at the same time.</p><p>Then it dawned on me that the browser have a functionality called “print to pdf”, which you can just invoke by a “window.print();”. Browsers like Google Chrome, Mozilla Firefox and others have a pretty awesome pdf generation engine which generates pdfs like a champ.</p><p>So let’s finish up with a scenario how much will cost to generate a lot of pdf files from html.</p><ul><li>450,000 HTML files</li><li>95% of the files were one page in length</li><li>generally containing 2 images (relative path, local system)</li><li>tabular data (sometimes contained nested tables)</li><li>simple markup elsewhere (strong, italic, underline, etc)</li></ul><p><strong>PC capacity</strong></p><ul><li>8GB RAM</li><li>2.4GHz Dual Core Processor</li><li>7200RPM HD</li></ul><p>It took 2.5 days to complete. My reaction was “Hahahahaha”, “LOL”, “huhhuhuhu”, “huehuehuehue”.</p><p>So the reason behind this writing is to tell developers who will be building a backend pdf generating system in the future where you can do with a single function call . Please don’t waste your CPU capacity where you don’t need to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*jaNc6Zv7YgHzN-_E1cc2Rw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15c089a67196" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing Matplotlib with python 3.4 and pip]]></title>
            <link>https://anichakraborty.medium.com/installing-matplotlib-with-python-3-4-and-pip-f663859085fd?source=rss-c11d1a723851------2</link>
            <guid isPermaLink="false">https://medium.com/p/f663859085fd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[matplotlib]]></category>
            <dc:creator><![CDATA[Aniruddha Chakraborty]]></dc:creator>
            <pubDate>Wed, 07 Sep 2016 07:59:48 GMT</pubDate>
            <atom:updated>2016-09-07T08:06:44.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4RdZV1fShV_R_hR9rYREVg.png" /></figure><p>In recent times people are having problem with installing matplotlib using pip with python 3.4</p><p>Because there is a bug in the handling of searching for a <a href="http://www.freetype.org/">freetype</a> installation.</p><p>If you install the Linux package freetype-dev, you will avoid this bug and be able to compile matplotlib</p><p>So you need to run</p><p><strong>sudo apt-get install libfreetype6-dev libxft-dev</strong></p><p>and then you’re ready to install matplotlib with <strong>pip</strong></p><p><strong>pip3 install matplotlib</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f663859085fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>