<?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 Ashish Joshi on Medium]]></title>
        <description><![CDATA[Stories by Ashish Joshi on Medium]]></description>
        <link>https://medium.com/@ashish15?source=rss-d86f24767bbe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Ashish Joshi on Medium</title>
            <link>https://medium.com/@ashish15?source=rss-d86f24767bbe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 07:19:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashish15/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[“Relation does not exist”- Understanding Pgpool-II Connection pooling]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ashish15/relation-does-not-exist-understanding-pgpool-ii-connection-pooling-25d60aab77fe?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/661/1*LN62b3HxiEpCQMh3Gw0B8A.png" width="661"></a></p><p class="medium-feed-snippet">Recently, we were hit by a puzzling issue that said one of our relations in the public schema does not exist.</p><p class="medium-feed-link"><a href="https://medium.com/@ashish15/relation-does-not-exist-understanding-pgpool-ii-connection-pooling-25d60aab77fe?source=rss-d86f24767bbe------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ashish15/relation-does-not-exist-understanding-pgpool-ii-connection-pooling-25d60aab77fe?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/25d60aab77fe</guid>
            <category><![CDATA[pgpool]]></category>
            <category><![CDATA[postgresql-database]]></category>
            <category><![CDATA[postgresql-tutorials]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Thu, 05 Jun 2025 18:20:51 GMT</pubDate>
            <atom:updated>2025-06-06T04:59:35.570Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding Apache Kafka consumer design]]></title>
            <link>https://medium.com/@ashish15/understanding-apache-kafka-consumer-design-38cb28e79ae2?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/38cb28e79ae2</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[confluent-kafka-js]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 14:35:43 GMT</pubDate>
            <atom:updated>2025-03-31T14:35:43.764Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache Kafka is a powerful event streaming platform but building a well-architected Kafka consumer application requires a deep understanding of its design principles. In this blog post, we’ll explore the Apache Kafka’s consumer design practices and key concepts. We’ll use Node.js-based consumer applications built using the <a href="https://www.npmjs.com/package/@confluentinc/kafka-javascript">Confluent-Kafka-javascript</a> npm package to demonstrate best practices in action.</p><p><strong>Pull vs Push</strong></p><p>Kafka consumer application is a pull based design i.e., the consumer issues pull request to Kafka broker. The main advantage of pull-based approach w.r.t the push based is that it gives more control to consumer. Even if the consumer falls behind during the consumption it can catch up. This allows different consumers to consume messages from the same broker at their own rate and hence shifts the control from broker to consumer.</p><p><strong>Consumer group</strong></p><p>A consumer group is a set of consumers from same application that read from a Kafka topic as a one group. This gives the consumers the ability to process parallelly and the load gets distributed across the consumers based on partition assignment. Let’s consider an example where messages are being consumed from a Kafka topic with three partitions, we would see various consumer assignment scenarios based on the number of consumers in a group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*slg4vxuwu0tnUTUxCEe7Yg.png" /><figcaption>Case 1: Single consumer would consume from all the partitions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*e62Hykcb8P7vNihwZUMtuQ.png" /><figcaption>Case 2: One consumer would consume from two partitions while the other one from single</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*Nlc_HqypPxnVqicvMocTEg.png" /><figcaption>Case 3: Evenly balanced</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*4mHEtKvnh3X9JLEu1GuhQg.png" /><figcaption>Case 4: One Idle consumer</figcaption></figure><p>If the consumer in a group exceeds number of partitions in a topic, the extra consumer would sit idle. This is never desirable because these idle consumers would increase the resource utilization of cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*OLBrnigL1d58k1eLCLtvIA.png" /><figcaption>Case 5: Multiple consumer groups consuming from single partition</figcaption></figure><p><strong>How does Kafka keep track of consumed messages ?</strong></p><p>As consumer consumes messages from broker it either immediately or periodically sends acknowledgement and the broker keeps track of the consumed messages. Kafka uses consumer offset (a sequence of integer value) to keep track of last consumed message by a consumer from a partition. The value of consumer offset persisted in an internal topic called __consumer_offsets.</p><p>Each consumer group has its own set of offsets and that’s how multiple consumer groups can independently consume from same topic.</p><p>If a new consumer adds to a consumer group it would start consuming from a partition (unless number of consumers &gt; number of partitions) or if a consumer crashes, an existing consumer will take responsibility of consumption from the orphaned partition. In all such cases the new /existing consumer would start consuming from the most recent committed offset stored in __consumer_offsets.</p><p><strong>Consumer Rebalancing</strong></p><p>Any change in the assignment to consumer to topic is called rebalancing of consumer group. Consumer group going to rebalancing state is a common phenomenon in a Kafka cluster. A rebalance may happen when a consumer crashes, a broker fails, consumer auto scales or any change in topic partitions etc. During a rebalance the real time message consumption is hampered hence this is less desirable.</p><p><em>Let’s see things working</em></p><p>Created a new Kafka topic named ‘<em>new_topic</em>’ with three partitions.</p><p>We would create two consumer groups with id ‘<em>new-consumer-1</em>’ and ‘<em>new-consumer-2</em>’. We would incrementally add/remove consumers to the group and would observe consumer behavior from consumer logs. Also, we would use Kafka’s consumer group utility to check its status.</p><p>The complete source code can be found <a href="https://github.com/ajdev90/kafka-consumer-group">here</a>.</p><pre>1. Started first consumer with group id &#39;new-consumer-1&#39; =&gt; 3 partitions assigned to this consumer<br>Consumer-1 logs:<br>{<br>  message: &#39;Consumer connected&#39;,<br>  name: &#39;rdkafka#consumer-1&#39;,<br>  fac: &#39;BINDING&#39;,<br>  timestamp: 1743324409507<br>}<br>{<br>  message: &quot;Received rebalance event with message: &#39;Local: Assign partitions&#39; and 3 partition(s), isLost: false&quot;,<br>  name: &#39;rdkafka#consumer-1&#39;,<br>  fac: &#39;BINDING&#39;,<br>  timestamp: 1743324410120<br>}<br><br>kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group new-consumer-1<br>Output:<br>GROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                  HOST            CLIENT-ID<br>new-consumer-1  new_topic       0          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       1          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       2          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br><br>Consumer id is same for all three partitions, whcih means single consumer is consuming from all partitions<br><br>2. Started second consumer with group id &#39;new-consumer-1&#39; =&gt; 2 partitions remained assigned to  first consumer and 1 partition assigned to this new consumer<br>Consumer-1 logs:<br>{<br>  message: &quot;Received rebalance event with message: &#39;Local: Revoke partitions&#39; and 3 partition(s), isLost: false&quot;,<br>  name: &#39;rdkafka#consumer-1&#39;,<br>  fac: &#39;BINDING&#39;,<br>  timestamp: 1743324842265<br>}<br>{<br>  message: &quot;Received rebalance event with message: &#39;Local: Assign partitions&#39; and 2 partition(s), isLost: false&quot;,<br>  name: &#39;rdkafka#consumer-1&#39;,<br>  fac: &#39;BINDING&#39;,<br>  timestamp: 1743324842502<br>}<br>Consumer-2 logs:<br>{<br>  message: &#39;Consumer connected&#39;,<br>  name: &#39;rdkafka#consumer-1&#39;,<br>  fac: &#39;BINDING&#39;,<br>  timestamp: 1743324841111<br>}<br>{<br>  message: &quot;Received rebalance event with message: &#39;Local: Assign partitions&#39; and 1 partition(s), isLost: false&quot;,<br>  name: &#39;rdkafka#consumer-1&#39;,<br>  fac: &#39;BINDING&#39;,<br>  timestamp: 1743324842503<br>}<br>kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group new-consumer-1<br>Output:<br>GROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                  HOST            CLIENT-ID<br>new-consumer-1  new_topic       0          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       1          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       2          -               0               -               rdkafka-dbbe6f89-df22-4c16-9614-b84fd8da16de /172.28.223.33  rdkafka<br><br>Consumer id is same for P0 and P1. P2 has different consumer id<br><br>3. Started third consumer with group id &#39;new-consumer-1&#39; =&gt; All 3 partitions assigned to different consumers<br>kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group new-consumer-1<br>Output:<br>GROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                  HOST            CLIENT-ID<br>new-consumer-1  new_topic       1          -               0               -               rdkafka-c839045d-f83c-4fbc-8570-cc7fa6430a69 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       0          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       2          -               0               -               rdkafka-dbbe6f89-df22-4c16-9614-b84fd8da16de /172.28.223.33  rdkafka<br><br>All the threee partitions have different consumer ids<br><br>4. Started fourth consumer with group id &#39;new-consumer-1&#39; =&gt; Second consumer lost its partition and new consumer is attached to the partition.<br>kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group new-consumer-1<br>Output:<br>GROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                  HOST            CLIENT-ID<br>new-consumer-1  new_topic       2          -               0               -               rdkafka-c839045d-f83c-4fbc-8570-cc7fa6430a69 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       0          -               0               -               rdkafka-49548918-04a0-473c-8f2a-0711c8364ca8 /172.28.223.33  rdkafka<br>new-consumer-1  new_topic       1          -               0               -               rdkafka-538bed99-d3ae-40b5-b971-697857c893a6 /172.28.223.33  rdkafka<br><br>One consumer would sit idle.</pre><p><strong>Consumer Lag</strong></p><p>Any difference in the number of records produced on a particular partition of a topic and the number of records consumed by a consumer (of a consumer group) from that partition of the topic would be considered as a lag on that topic partition.</p><p>In other words, if rate of consumption is less than the rate of production than it would result in a consumer lag.</p><p><strong>Group Coordinator and Heartbeat</strong></p><p>One of the brokers is designated as the group’s coordinator and its responsibility is to manage the members of the consumer group and their partition assignments. Each member in the consumer group must send heartbeats to the coordinator to remain a member of the group. If no heartbeat is received before expiration of the configured session timeout, then the group coordinator will assume the member as dead and reassign its partitions to another member.</p><p>Any Kafka consumer performs two parallel activities of polling and sending heartbeat. Polling is done to fetch messages from broker and a periodic heartbeat is sent to the coordinator for its liveliness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*ikAV7kNyISFUV4DcBSB7xg.png" /><figcaption>Polling and Heartbeat activities of Kafka consumer</figcaption></figure><p><strong>Deciding the offset to consume from</strong></p><p><em>Consume from beginning: </em>Kafka consumer application has a setting to consume from the beginning. Once set to true, the consumer would start consuming from the first offset of the partition it is attached to. This can be helpful in reading historical records. Source code can be found <a href="https://github.com/ajdev90/kafka-consumer-group/blob/master/consumer-group-from-beginning.js">here</a>.</p><pre>const consumer = new Kafka().consumer({<br>    &#39;bootstrap.servers&#39;: &#39;my-broker:9092&#39;,<br>    &#39;group.id&#39;: &#39;new-consumer-3&#39;,<br>    &#39;kafkaJS&#39;: { fromBeginning: true }<br>});</pre><p>By default, this is false, and it means only those messages would be consumed which would be produced after the consumer subscription completed.</p><p><em>Seeking a offset: </em>Kafka consumer provide seek API to move the offset position in a partition. Source code can be found <a href="https://github.com/ajdev90/kafka-consumer-group/blob/master/consumer-seek-offset.js">here</a>.</p><pre>const run = async () =&gt; {<br>    await consumer.connect();<br>    await consumer.subscribe({ topics: [&quot;new_topic&quot;] });<br>    consumer.seek({&#39;topic&#39;: &#39;new_topic&#39;,&#39;partition&#39;: 0,&#39;offset&#39; : &quot;34&quot;});<br>    consumer.seek({&#39;topic&#39;: &#39;new_topic&#39;,&#39;partition&#39;: 1,&#39;offset&#39; : &quot;29&quot;});<br>    consumer.seek({&#39;topic&#39;: &#39;new_topic&#39;,&#39;partition&#39;: 2,&#39;offset&#39; : &quot;32&quot;});<br>    consumer.run({<br>        eachMessage: async ({ topic, partition, message }) =&gt; {}<br>    });<br>}</pre><p><strong>Delivery Semantics of Kafka consumer</strong></p><p>A Kafka consumer polls the broker and receives a bunch of messages. The consumer application may choose to immediately commit the offset or it may first process the bunch of messages it received and then commit the offset. Also, a consumer may or may not choose the auto commit offset option. All these strategies determines whether a message would be skipped or consumed multiple times in case a consumer restarts or crashes and are known as semantic guarantees. Let’s discuss various scenarios one at a time.</p><p><strong>No Guarantee:</strong> Consider the case when offset auto commit is enabled and the consumer is processing the batch of messages asynchronously. With auto commit enabled the consumer would save the offsets in broker periodically. Now consider the scenario if the processing got completed and consumer crashed before auto commit executed, this batch of messages would be read again. Another scenario if auto commit executed and the batch processing was in progress. In this scenario our system would lose these batch of messages. This was an example where there is no guarantee.</p><p><strong>At most once: </strong>This is the best effort semantic i.e., the message would be processed only once or not at all. At most once semantic can be achieved if auto commit is disabled and the consumer commits the offsets before processing the batch of messages. In this case if the consumer crashes the current batch would be lost and the new messages would be read after the last committed offsets. This is suitable for use cases where the system can afford to lose the data.</p><p><strong>At least once: </strong>This semantic means we would always receive a message but in case of crashes or restarts there may happen some duplications. Consider a scenario where consumer is programmed in such a way that after receiving a batch of messages it first completes its processing and then commits the offsets (auto commit is disabled). In such a scenario if there is a crash the consumer would receive and process the messages all over again but there would be no loss. This is suitable for use cases where the system cannot afford any data loss.</p><p>At least once semantic with <em>idempotent </em>processing is a very desirable characteristic. This means processing a duplicate message would not impact the system, the duplicate message would simply update an existing record.</p><p><strong>Exactly once: </strong>Exactly once can be achieved in Kafka when the target system is also in Kafka. Kafka introduced transactions capability in version 0.11.0.0 to achieve exactly once semantics. With transactions enabled the offset data and message data is written to output topics in the same transaction, making this operation as atomic. More on <a href="https://www.confluent.io/blog/exactly-once-semantics-are-possible-heres-how-apache-kafka-does-it">Kafka exactly once semantics</a>.</p><p><strong>References</strong></p><p><a href="https://docs.confluent.io/kafka/design/consumer-design.html">Confluent-consumer-design</a></p><p><a href="https://www.instaclustr.com/blog/a-beginners-guide-to-kafka-consumers/">Instaclustr-a-beginners-guide-to-kafka-consumers</a></p><p><a href="https://medium.com/@andy.bryant/processing-guarantees-in-kafka-12dd2e30be0e">Processing-guarantees-in-Kafka-Andy Bryant-medium</a></p><p><a href="https://learn.conduktor.io/kafka/kafka-consumer-important-settings-poll-and-internal-threads-behavior/">Conduktor-kafka-consumer-important-settings</a></p><p><a href="https://github.com/obsidiandynamics/kafdrop">Kafdrop UI for viewing Kafka topics and browsing consumer groups</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38cb28e79ae2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Kafka Admin API: Nodejs]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ashish15/exploring-kafka-admin-api-nodejs-3332636f3b66?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/2600/0*VtAbxG3gvhaq8H74" width="6000"></a></p><p class="medium-feed-snippet">Exploring Kafka Admin API: Nodejs, confluent-kafka-javascript</p><p class="medium-feed-link"><a href="https://medium.com/@ashish15/exploring-kafka-admin-api-nodejs-3332636f3b66?source=rss-d86f24767bbe------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ashish15/exploring-kafka-admin-api-nodejs-3332636f3b66?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/3332636f3b66</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[confluent-kafka-js]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[confluent-kafka]]></category>
            <category><![CDATA[kafka-administration]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Sun, 23 Feb 2025 10:56:56 GMT</pubDate>
            <atom:updated>2025-02-24T08:11:32.948Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Getting started with Kafka using Confluent-kafka-javascript library : Node.js]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ashish15/getting-started-with-kafka-using-confluent-kafka-javascript-library-node-js-ca6b53514671?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/1792/1*_pSW8Uni7B9SV9hUkKW1LA.png" width="1792"></a></p><p class="medium-feed-snippet">Apache Kafka has become the backbone of modern event-driven applications, enabling real-time data streaming at scale. While Java has been&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@ashish15/getting-started-with-kafka-using-confluent-kafka-javascript-library-node-js-ca6b53514671?source=rss-d86f24767bbe------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ashish15/getting-started-with-kafka-using-confluent-kafka-javascript-library-node-js-ca6b53514671?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca6b53514671</guid>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[confluent]]></category>
            <category><![CDATA[confluent-kafka]]></category>
            <category><![CDATA[confluent-kafka-js]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Sun, 16 Feb 2025 17:23:17 GMT</pubDate>
            <atom:updated>2025-03-31T14:39:01.318Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Exploring Docker networking: The bridge]]></title>
            <link>https://blog.devops.dev/exploring-docker-networking-the-bridge-5cf6685712dd?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cf6685712dd</guid>
            <category><![CDATA[docker-networking]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-network]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Wed, 25 Dec 2024 11:18:58 GMT</pubDate>
            <atom:updated>2024-12-26T17:55:45.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vlnSZD99J5-mfurK" /><figcaption>Photo by <a href="https://unsplash.com/@exdigy?utm_source=medium&amp;utm_medium=referral">Dominik Lückmann</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, we will try to unravel the intricacies of Docker networking with the bridge network driver. Docker has various inbuilt drivers to provide its core functionality: <em>bridge</em>, <em>host</em>, <em>overlay</em>, <em>ipvlan</em>, <em>macvlan</em>, <em>and none. </em>Bridge is the default network driver for Docker.</p><p><strong>Bridge Network</strong></p><p>As the name suggests, it provides a bridge that allows containers to communicate with each other and is also necessary for isolation from containers outside this bridge network. Any new container that has not been specified to be part of any network would connect to the default bridge network.</p><p>If we install docker in a machine and check all the available docker networks then the bridge network should be present by default.</p><pre>docker network ls<br>#default bridge n/w has name bridge while minikube has its own bridge n/w<br><br>NETWORK ID     NAME         DRIVER    SCOPE<br>6ef38f862506   bridge       bridge    local<br>ed1ee85ab940   minikube     bridge    local</pre><p>If we check network interfaces in the machine, there would be an entry for docker0.</p><pre>ifconfig<br># snippet of output<br>docker0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500<br>        inet 10.104.0.1  netmask 255.255.255.0  broadcast 10.104.0.255<br>        inet6 ze80::42:a6zz:ze1b:z4b3  prefixlen 64  scopeid 0x20&lt;link&gt;<br>        ether 02:42:a6:1a:b4:a3  txqueuelen 0  (Ethernet)<br>        RX packets 9839424  bytes 580090759 (553.2 MiB)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 9969106  bytes 1211510384 (1.1 GiB)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0</pre><p>We can change the default docker0 configurations by specifying the configurations in the daemon JSON file. <a href="https://docs.docker.com/engine/network/drivers/bridge/#configure-the-default-bridge-network"><em>More on this.</em></a></p><p>Let&#39;s spin two containers (named c1 and c2) using an alpine Linux image. Shell inside the containers from different terminals.</p><pre>docker run -dit --name c1 alpine<br>docker run -dit --name c2 alpine<br><br>docker exec -it c1 sh<br>docker exec -it c2 sh<br><br>ipconfig // To get ipaddress of the container</pre><p>Now let’s try to ping one another using their IP addresses and container names. The two containers should be able to ping one another using their IP address but would fail to ping using the container name.</p><pre>#ping by container IP<br>ping 10.104.0.4<br>PING 10.104.0.4 (10.104.0.4): 56 data bytes<br>64 bytes from 10.104.0.4: seq=0 ttl=64 time=0.120 ms<br><br># ping by container name<br>ping c2<br>ping: bad address &#39;c2&#39;</pre><p>This happens because when we spin two containers without explicitly specifying any network, both of them become part of the default docker bridge network (docker-0) and hence can ping one another using their IP addresses. However, the default bridge does not provide any way for DNS resolution and hence the ping using the container name fails.</p><p>Let&#39;s inspect our default bridge network.</p><pre># To list networks<br>docker network ls<br># To inspect bridge network<br>docker inspect bridge<br># Snippet from output of above command<br>&quot;Containers&quot;: {<br>            &quot;2ee2453ebb7842d4beed3d7bfdeb4ae4817a28c5c61bcc847b27320d37b831e2&quot;: {<br>                &quot;Name&quot;: &quot;c1&quot;,<br>                &quot;EndpointID&quot;: &quot;0d81c52517f34afd3059fa5b6fee9f592f5d71ce470f4263b96aa6df237eb623&quot;,<br>                &quot;MacAddress&quot;: &quot;02:42:0a:68:00:04&quot;,<br>                &quot;IPv4Address&quot;: &quot;10.104.0.4/24&quot;,<br>                &quot;IPv6Address&quot;: &quot;&quot;<br>            },<br>            &quot;9631b5b4eb5d28f203ab14999ad112eb9a2c6468cc46f23e4b777b1c10fae5af&quot;: {<br>                &quot;Name&quot;: &quot;c2&quot;,<br>                &quot;EndpointID&quot;: &quot;7381078e8d31bb47b5278d497282b0ec526ab71dad59f90d18d6fd0da1c264cc&quot;,<br>                &quot;MacAddress&quot;: &quot;02:42:0a:68:00:02&quot;,<br>                &quot;IPv4Address&quot;: &quot;10.104.0.2/24&quot;,<br>                &quot;IPv6Address&quot;: &quot;&quot;<br>            }<br>        }</pre><p>The output of the inspect command would verify that the newly spawned c1 and c2 containers are part of the default bridge network.</p><p><strong>User-defined Bridge Network</strong></p><p>User-defined bridge networks solve the above problem by providing automatic DNS resolution between two containers.</p><p>Let&#39;s create a new user-defined bridge network, remove our c1 and c2 containers from the default bridge network, and add them to our new user-defined bridge network.</p><pre># To create a new user defined bridge network<br>docker network create -d bridge my_net<br># This should list the newly created network<br>docker network ls<br># Add c1 and c2 to my_net<br>docker network connect my_net c1<br>docker network connect my_net c2<br>#At this moment if we inspect any of the containers c1 or c2, they would be part of two networks (bridge and my_net)<br>#Inspect container c1<br>docker inspect c1<br>#Remove c1 and c2 from bridge network<br>docker network disconnect bridge c1<br>docker network disconnect bridge c2<br>#Inspect network my_net<br>docker inspect my_net<br># Snippet from output of above command<br>&quot;Name&quot;: &quot;my_net&quot;,<br>&quot;Id&quot;: &quot;774bb5fb59700eeb0f7584bdf044743475a0563994352966ae33ec1548493c89&quot;,<br>&quot;Containers&quot;: {<br>            &quot;2ee2453ebb7842d4beed3d7bfdeb4ae4817a28c5c61bcc847b27320d37b831e2&quot;: {<br>                &quot;Name&quot;: &quot;c1&quot;,<br>                &quot;EndpointID&quot;: &quot;792d9d2433c301af8da502c07084e8eefddd5edaa0829fa4bb0e34e6f512bf80&quot;,<br>                &quot;MacAddress&quot;: &quot;02:42:0a:68:04:02&quot;,<br>                &quot;IPv4Address&quot;: &quot;10.104.4.2/24&quot;,<br>                &quot;IPv6Address&quot;: &quot;&quot;<br>            },<br>            &quot;9631b5b4eb5d28f203ab14999ad112eb9a2c6468cc46f23e4b777b1c10fae5af&quot;: {<br>                &quot;Name&quot;: &quot;c2&quot;,<br>                &quot;EndpointID&quot;: &quot;cccf555c8fcc3ecb2c89f943c4e00c58123babde80c4890a64853b73dc26b679&quot;,<br>                &quot;MacAddress&quot;: &quot;02:42:0a:68:04:03&quot;,<br>                &quot;IPv4Address&quot;: &quot;10.104.4.3/24&quot;,<br>                &quot;IPv6Address&quot;: &quot;&quot;<br>            }<br>        },</pre><p>Now let&#39;s shell inside c1 and c2 and ping using the container name.</p><pre>ping c2<br>PING c2 (10.104.4.3): 56 data bytes<br>64 bytes from 10.104.4.3: seq=0 ttl=64 time=0.286 ms<br><br>ping c1<br>PING c1 (10.104.4.2): 56 data bytes<br>64 bytes from 10.104.4.2: seq=0 ttl=64 time=0.041 ms</pre><p>This time the ping should work fine. When we created a new bridge network, docker created a new network interface for us.</p><pre>ifconfig<br># snippet of outout. The number after br- would be the id of my_net<br>br-774bb5fb5970: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500<br>        inet 10.104.4.1  netmask 255.255.255.0  broadcast 10.104.4.255<br>        inet6 fe00::72:7bff:fe57:78c2  prefixlen 64  scopeid 0x20&lt;link&gt;<br>        ether 07:56:7b:55:56:c2  txqueuelen 0  (Ethernet)<br>        RX packets 10  bytes 552 (552.0 B)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 15  bytes 1956 (1.9 KB)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0</pre><p><em>PS</em></p><p>docker network ls // list all the networks</p><p>docker inspect network_name// inspect a network</p><p>docker inspect containter_name/id// shows container config including n/w</p><p>docker network create -d bridge my-bridge-network// create a bridge n/w</p><p>docker network connect network_name container_name // adds connector to a n/w</p><p>docker network disconnect network_name container_name // removes connector to a n/w</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cf6685712dd" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/exploring-docker-networking-the-bridge-5cf6685712dd">Exploring Docker networking: The bridge</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostgreSQL table partitioning]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.devops.dev/postgresql-table-partitioning-9a313480450e?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/2600/0*yIo8B_w9oBJCf3ZQ" width="5472"></a></p><p class="medium-feed-snippet">Non-members can read the full article here.</p><p class="medium-feed-link"><a href="https://blog.devops.dev/postgresql-table-partitioning-9a313480450e?source=rss-d86f24767bbe------2">Continue reading on DevOps.dev »</a></p></div>]]></description>
            <link>https://blog.devops.dev/postgresql-table-partitioning-9a313480450e?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a313480450e</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[partitioning]]></category>
            <category><![CDATA[database-management]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 16:59:37 GMT</pubDate>
            <atom:updated>2025-02-11T14:43:29.614Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Kafka consumer seek operation : kafka.js, node.js]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ashish15/kafka-consumer-seek-operation-kafka-js-node-js-ec127c5c057d?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/2600/0*sXLFC39tapAs1HHd" width="3024"></a></p><p class="medium-feed-snippet">This post explores the seek operation of kafka consumer and how it can be leveraged in a distributed microservice architecture to pull&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@ashish15/kafka-consumer-seek-operation-kafka-js-node-js-ec127c5c057d?source=rss-d86f24767bbe------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ashish15/kafka-consumer-seek-operation-kafka-js-node-js-ec127c5c057d?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec127c5c057d</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[kafkajs]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 12:55:07 GMT</pubDate>
            <atom:updated>2025-03-22T09:12:24.151Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Error handling and retry strategies for kafka application (kafka.js, Node.js).]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ashish15/error-handling-and-retry-strategies-for-kafka-application-kafka-js-node-js-d6468f659891?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/2600/0*4ZqPTPjmWNXGI26V" width="5624"></a></p><p class="medium-feed-snippet">Kafkajs retry and exception handling strategies. Instrumentation event handling. Nodejs application.</p><p class="medium-feed-link"><a href="https://medium.com/@ashish15/error-handling-and-retry-strategies-for-kafka-application-kafka-js-node-js-d6468f659891?source=rss-d86f24767bbe------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ashish15/error-handling-and-retry-strategies-for-kafka-application-kafka-js-node-js-d6468f659891?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6468f659891</guid>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafkajs]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Sat, 24 Aug 2024 17:47:57 GMT</pubDate>
            <atom:updated>2024-08-24T17:47:57.640Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Creating Systemd User Service]]></title>
            <link>https://blog.stackademic.com/creating-systemd-user-service-1035310824f0?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/1035310824f0</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[systemd]]></category>
            <category><![CDATA[systemd-service]]></category>
            <category><![CDATA[linux-service]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Sat, 03 Aug 2024 13:39:36 GMT</pubDate>
            <atom:updated>2025-01-06T08:19:53.507Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a4rfirOFtHUoDV-g" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>What is systemd</strong></p><p>Systemd is a popular init system in Linux distros. An init process runs as PID 1 and provides many capabilities such as service management. In short it is a system and service manager for Linux operating systems. A systemd unit is a configuration file that can define a service, a socket, a device, a mount point or another managed entity that systemd can manage.</p><p><strong>Need of systemd user service</strong></p><p>Starting and managing systemd services requires user to have root access. We can allow non-root users to manage specific systemd services but that requires editing sudoers file or sometimes PolicyKit and this is not always possible.</p><p>Systemd also allows to manage services under the user’s session and hence this does not require root access. A non-root user can start, stop, enable, and disable such services. A user systemd service is started when a user first logins and is killed when all the sessions of that user are closed, however we can enable user lingering which keeps the service running after logouts as well.</p><p><strong>Creating a systemd user service</strong></p><p>We will be using below shell script that we would be running as a service, let’s call this date-time.sh</p><pre>#!/bin/bash<br>echo starting..!!<br>while true;<br>do<br>  echo Current time is $(date) &gt;&gt; ./date-time.log<br>  sleep 30<br>done</pre><p>Now let’s create a new user without root privileges using a root user.</p><pre>sudo useradd newuser #creates a new user<br>sudo passwd newuser #creates password for this new user</pre><p>Login with this new user and create systemd files in context of this user.</p><pre>mkdir -p ~/.config/systemd/user<br>vi ~/.config/systemd/user/datetime.service<br></pre><p>Create a directory ‘date-time’ inside user’s home and copy the date-time.sh script that we had create initially. Also provide the current user the execute permission on this file.<br>Copy the below content into above file.</p><pre>[Unit]<br>Description=My date time service<br>After=syslog.target network.target<br><br>[Service]<br>SuccessExitStatus=143<br><br>WorkingDirectory=/home/newuser/date-time<br>ExecStart=/home/newuser/date-time/date-time.sh<br>ExecStop=/bin/kill -15 $MAINPID<br><br>[Install]<br>WantedBy=default.target</pre><pre># follow the below steps to enable and start the service<br>systemctl --user enable datetime.service  <br># above command to enable the service<br>systemctl --user start datetime.service<br>#above command to start the service<br>systemctl --user status datetime.service<br>#above command to check the status of service and it should log below output<br>datetime.service - My date time service<br>     Loaded: loaded (/home/newuser/.config/systemd/user/datetime.service; enabled; vendor preset: disabled)<br>     Active: active (running) since Sat 2024-08-03 17:50:37 IST; 1s ago<br>   Main PID: 477749 (date-time.sh)<br>      Tasks: 2 (limit: 101961)<br>     Memory: 564.0K<br>        CPU: 9ms<br>     CGroup: /user.slice/user-1005.slice/user@1005.service/app.slice/datetime.service<br>             ├─477749 /bin/bash /home/newuser/date-time/date-time.sh<br>             └─477751 sleep 30</pre><p>The service is up and running and should log current date time in the log file. The below commands can be used to manage this service.</p><pre>systemctl --user restart datetime.service #restart the service<br>systemctl --user stop datetime.service #stop the service<br>systemctl --user daemon-reload <br>#If there is any change in the service unit file, we must use above command to reload the units.</pre><p>At this moment our service is up and running fine but if we log off all the sessions of this newly created user the service will stop. One can verify this by checking the log file, it would have stopped appending the logs.</p><p>Suppose we have a requirement where we need our service to be running even after the user session is closed, this can be achieved using below command.</p><pre>loginctl enable-linger newuser<br>loginctl show-user newuser --property=Linger #check if liger is enabled for a user</pre><p>Once linger is enabled service should keep running even after user sessions are closed. This is can be verified by date-time service logs and also using below command from any other root user session.</p><pre>ps -u newuser # processes running under newuser</pre><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://cofeed.app/"><strong>Check out CoFeed, the smart way to stay up-to-date with the latest in tech</strong></a> <strong>🧪</strong></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1035310824f0" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/creating-systemd-user-service-1035310824f0">Creating Systemd User Service</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka consumer and producer with custom partitioner : (kafkajs, nodejs)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/kafka-consumer-and-producer-with-custom-partitioner-kafkajs-nodejs-8615002b9552?source=rss-d86f24767bbe------2"><img src="https://cdn-images-1.medium.com/max/2600/0*xNCbBBU6XBDF_Re-" width="5917"></a></p><p class="medium-feed-snippet">This article explores the custom partitioning feature of kafka in an nodejs application using kafkajs npm package. We will explore various&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/kafka-consumer-and-producer-with-custom-partitioner-kafkajs-nodejs-8615002b9552?source=rss-d86f24767bbe------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/kafka-consumer-and-producer-with-custom-partitioner-kafkajs-nodejs-8615002b9552?source=rss-d86f24767bbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/8615002b9552</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafkajs]]></category>
            <dc:creator><![CDATA[Ashish Joshi]]></dc:creator>
            <pubDate>Sun, 12 May 2024 11:57:30 GMT</pubDate>
            <atom:updated>2025-01-06T06:11:48.682Z</atom:updated>
        </item>
    </channel>
</rss>