<?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 kiran vemula on Medium]]></title>
        <description><![CDATA[Stories by kiran vemula on Medium]]></description>
        <link>https://medium.com/@kiranwelcomesu?source=rss-99618ae95a9b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*G20rKjrtV16EQx6S.jpg</url>
            <title>Stories by kiran vemula on Medium</title>
            <link>https://medium.com/@kiranwelcomesu?source=rss-99618ae95a9b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:57:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kiranwelcomesu/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[Distributed lock]]></title>
            <link>https://medium.com/@kiranwelcomesu/distributed-lock-d297714936ba?source=rss-99618ae95a9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d297714936ba</guid>
            <category><![CDATA[cronjob-scheduler]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[distributed-locking]]></category>
            <dc:creator><![CDATA[kiran vemula]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 07:20:37 GMT</pubDate>
            <atom:updated>2026-09-09T07:20:37.796Z</atom:updated>
            <content:encoded><![CDATA[<p>Lets see how pods run the schedular</p><p>Basically in the App, as we all know main will initiate/start all the config , services and Kafka producers and schedulers.</p><p>Assume we have a service which fetch data from external API Every 5 mins and publish to Kafka event</p><p>And created a scheduler and assigned a job of fetching data in every 5 mins</p><p>Lets say we are deploying this application in Kubernetes and running instance in 3 pods</p><p>Application is running on the 3 pods , the schedular job runs once in 5 mins not once per pod .</p><p>pod1- starts schedular</p><p>pod2 — starts schedular</p><p>pod3 starts schedular — now all of my 3 pods try to run the same job every 5 mins</p><p>why because pod knows only its own memory ,timer and process. It has no idea about other pods process</p><p>If the application running in one pod, it works fine (pod 1 starts and run schedular job every 5 mins)</p><p>its creates duplicate api calls and duplicate events. We need to ensure only 1 pod executes the job at a time</p><p><strong>Solution </strong>: shared lock/distributed lock</p><ol><li>All three pods starts the schedular during application start-up — means all three pods initialize the schedular instance</li><li>But Schedular job is protected by the Distributed lock — all the pods host the schedular but one pod executes the scheduler job<br>every pod is allowded to initilize the schedular<br>before running the job , the scheduler acquires the shared lock which is stored in shared database</li></ol><p>only the pod acquires lock can run the job</p><p>this give us the leader style execution without implementing the separate leader election components<br> out of my 3 pods, 1 pod acquires a lock and runs the job, other 2 remains do nothing for that tick</p><p>Important Note in this approach<br>scheduler is not just a in memory cron, it should be configured with the DB backed distributed lock which is shared by all pods , means schedular decision should be coordinated across the replicas</p><p>this design only works if all pods works same database and same lock</p><p><strong>Trade-offs to keep in mind<br>1.Db </strong>becomes the part of scheduling, if DB is down, the schedular may not able to co-ordinate safely</p><p>2. Lock behaviour should be monitored — Need to have much more logs to see</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d297714936ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>