<?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 Nidhichaudhary on Medium]]></title>
        <description><![CDATA[Stories by Nidhichaudhary on Medium]]></description>
        <link>https://medium.com/@nidhichaudhary2002?source=rss-ff9db7c86e91------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*d9g5J6u1BtQtXvmo</url>
            <title>Stories by Nidhichaudhary on Medium</title>
            <link>https://medium.com/@nidhichaudhary2002?source=rss-ff9db7c86e91------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:59:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nidhichaudhary2002/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[AWS Batch vs EC2 for Batch Processing + How It Actually Works]]></title>
            <link>https://medium.com/@nidhichaudhary2002/aws-batch-vs-ec2-for-batch-processing-how-it-actually-works-edff43e3d36b?source=rss-ff9db7c86e91------2</link>
            <guid isPermaLink="false">https://medium.com/p/edff43e3d36b</guid>
            <dc:creator><![CDATA[Nidhichaudhary]]></dc:creator>
            <pubDate>Mon, 23 Mar 2026 17:18:57 GMT</pubDate>
            <atom:updated>2026-03-23T17:18:57.848Z</atom:updated>
            <content:encoded><![CDATA[<p>While working on writing a cron job when I realized how difficult it would be to scale this approach for larger workloads. That’s when I was suggested an alternative: AWS Batch.</p><p>At that point, I knew nothing about it, so I started exploring.</p><p>This post is my attempt to structure everything I learned:</p><ol><li>AWS Batch vs traditional EC2 approach</li><li>How to set up a batch job in AWS Batch</li><li>Why each component exists (the intuition behind it)</li></ol><h3>1. AWS Batch vs Traditional EC2 Approach</h3><h3>Running Batch Jobs Directly on EC2</h3><p>In a traditional setup, you:</p><ul><li>Launch EC2 instances (manually or via Auto Scaling Groups)</li><li>Use cron jobs or workers to process tasks</li><li>Maintain a queue (SQS / DB / Kafka)</li><li>Handle retries, failures, and logging yourself</li><li>Manage dependencies via scripts or AMIs</li></ul><h3>Pros:</h3><ul><li>Full control over infrastructure</li><li>Simple for small workloads</li><li>Flexible customization</li></ul><h3>Challenges:</h3><p><strong>You build your own scheduler</strong><br>You need to decide:</p><ul><li>Which job runs first</li><li>How jobs are distributed</li><li>How to prioritize</li></ul><p>This often leads to reinventing orchestration.</p><p><strong>Scaling is not job-aware</strong><br>Auto Scaling reacts to CPU or memory, not:</p><ul><li>Queue size</li><li>Job complexity</li></ul><p>This can lead to over or under provisioning.</p><p><strong>Poor resource utilization</strong></p><ul><li>Idle servers increase cost</li><li>Overloaded servers cause failures</li></ul><p><strong>Dependency issues</strong></p><ul><li>Manual installs or custom AMIs</li><li>Version mismatches across environments</li></ul><p><strong>Retry and failure handling</strong></p><ul><li>Requires custom logic</li><li>Becomes complex at scale</li></ul><h3>AWS Batch Approach</h3><p>With AWS Batch:</p><ul><li>You define jobs</li><li>AWS handles compute, scheduling, and scaling</li></ul><h3>What you get:</h3><ul><li>No server management</li><li>Job-aware scaling</li><li>Built-in retries</li><li>Containerized workloads (via ECR)</li><li>Better cost efficiency (including Spot instances)</li></ul><h3>Mindset Shift</h3><p>EC2: “I have servers, let me run jobs.”<br>AWS Batch: “I have jobs, give me compute when needed.”</p><h3>2. How to Set Up a Batch Job (Step-by-Step)</h3><h3>Step 1: Create a Docker Image</h3><ul><li>Package your application and dependencies</li><li>Ensure it can run independently</li></ul><p>This ensures environment consistency.</p><h3>Step 2: Push Image to ECR</h3><ul><li>Store your container image in AWS</li></ul><p>This acts as a central registry for execution.</p><h3>Step 3: Create a Job Definition</h3><p>Define:</p><ul><li>Docker image</li><li>CPU and memory requirements</li><li>Environment variables</li></ul><p>This serves as your job template.</p><h3>Step 4: Create a Compute Environment</h3><p>Configure:</p><ul><li>EC2 or Spot instances</li><li>Minimum and maximum vCPUs</li><li>Instance types</li></ul><p>This defines where jobs will run.</p><h3>Step 5: Create a Job Queue</h3><ul><li>Submit jobs here</li><li>Assign priority</li></ul><p>This acts as a buffer between jobs and compute.</p><h3>Step 6: Submit Jobs</h3><ul><li>Jobs enter the queue</li><li>AWS Batch schedules them</li><li>Spins up EC2 instances if needed</li><li>Runs jobs and terminates resources afterward</li></ul><h3>3. Why Each Component Exists (Intuition)</h3><h3>Job Definition — What to run?</h3><p>Without this:</p><ul><li>Every job would require custom configuration</li></ul><p>With this:</p><ul><li>Standardized execution</li><li>Reusable templates</li></ul><h3>Job Queue — When to run?</h3><p>Without a queue:</p><ul><li>No buffering</li><li>No prioritization</li><li>Difficult to handle traffic spikes</li></ul><p>With a queue:</p><ul><li>Smooth handling of large workloads</li><li>Decouples job submission from execution</li></ul><h3>Compute Environment — Where to run?</h3><p>Without abstraction:</p><ul><li>You manually manage EC2 instances</li></ul><p>With this:</p><ul><li>AWS dynamically provisions resources</li><li>Scales based on demand</li></ul><h3>ECR — How to ensure consistency?</h3><p>Without containers:</p><ul><li>Dependency issues</li><li>Environment mismatch</li></ul><p>With ECR:</p><ul><li>Same environment every time</li><li>Portable and reproducible</li></ul><h3>Scheduler (AWS Batch) — How to run efficiently?</h3><p>This component:</p><ul><li>Matches jobs to resources</li><li>Scales compute based on demand</li><li>Handles retries and failures</li></ul><p>This is the layer you would otherwise need to build manually on EC2.</p><h3>Final Takeaway</h3><p>You can run batch jobs on EC2.</p><p>But then you are responsible for:</p><ul><li>Scheduling</li><li>Scaling</li><li>Failure handling</li><li>Resource optimization</li></ul><p>AWS Batch abstracts all of this into a single system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edff43e3d36b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is a Cron Job? [Things I Googled this week]]]></title>
            <link>https://medium.com/@nidhichaudhary2002/what-is-a-cron-job-things-i-googled-this-week-c7f26ca86ddd?source=rss-ff9db7c86e91------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7f26ca86ddd</guid>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Nidhichaudhary]]></dc:creator>
            <pubDate>Sun, 15 Mar 2026 09:28:38 GMT</pubDate>
            <atom:updated>2026-03-15T09:28:38.015Z</atom:updated>
            <content:encoded><![CDATA[<p>A cron job is simply a <strong>scheduled task</strong> that runs automatically at specific times or intervals.</p><p>Instead of manually running scripts like backups, analytics generation, or sending email digests, cron allows the system to do it automatically.</p><p>A typical cron entry looks like this:</p><pre>0 2 * * * /path/to/script.sh</pre><p>This means:</p><p>Run script.sh <strong>every day at 2:00 AM</strong>.</p><p>Each field represents a time component:</p><ul><li>minute</li><li>hour</li><li>day of month</li><li>month</li><li>day of week</li></ul><p>Cron reads these schedules and runs the command when the time matches.</p><h3>How Cron Works at the OS Level</h3><p>Cron works through a <strong>background process called a daemon</strong>.</p><p>In Linux, the daemon is usually called:</p><pre>crond</pre><p>It starts when the system boots and continues running in the background. Its job is simple:</p><ol><li>Load all scheduled tasks from configuration files.</li><li>Wake up every minute.</li><li>Check if any job matches the current time.</li><li>If yes, spawn a process to run the command.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*FI3bYu0H5VlzmRZt.png" /></figure><p>Cron monitors files such as:</p><pre>/etc/crontab<br>/etc/cron.d/<br>/var/spool/cron/crontabs/</pre><p>These contain scheduled jobs for both system and individual users. (<a href="https://linuxcommandlibrary.com/man/crond?utm_source=chatgpt.com">Linux Command Library</a>)</p><p>Once a job’s time matches, cron <strong>creates a new process and executes the script</strong>, letting the OS handle it like any other program.</p><p>What’s fascinating is how simple this design is. Cron basically loops forever:</p><pre>while true:<br>    check time<br>    if job matches:<br>        run command<br>    sleep until next minute</pre><p>Despite its simplicity, this mechanism powers <strong>millions of automated tasks across servers worldwide</strong>.</p><h3>Why Cron Only Checks Every Minute</h3><p>One interesting design choice is that cron checks schedules <strong>once per minute instead of every second</strong>.</p><p>This dates back to early Unix systems where computing resources were limited. Running a scheduler every second would consume unnecessary CPU cycles.</p><p>Most scheduled tasks — backups, cleanup jobs, analytics pipelines — do not require second-level precision.</p><p>So the cron daemon simply wakes up <strong>once every minute</strong>, making it extremely lightweight.</p><h3>The Distributed System Problem</h3><p>Cron works perfectly on a <strong>single machine</strong>.</p><p>But modern applications rarely run on just one server.</p><p>Imagine a system with four servers:</p><pre>Server A<br>Server B<br>Server C<br>Server D</pre><p>If each server has the same cron job to send email to 10k users at 10 AM:</p><pre>0 10 * * * send_daily_emails.sh</pre><p>At <strong>10:00 AM</strong>, every server will run the job.</p><p>Which means the job runs <strong>four times</strong>.</p><p>If that script sends emails to <strong>10,000 users</strong>, each user might receive <strong>four identical emails</strong>.</p><p>This happens because cron works <strong>at the operating system level</strong>. Each machine runs its own scheduler independently.</p><p>It has <strong>no awareness of other servers</strong>.</p><h3>Cron in Distributed Systems</h3><p>To handle scheduling in distributed environments, engineers usually introduce coordination mechanisms.</p><p>Instead of every server executing the job, systems use approaches like:</p><p><strong>1. A dedicated scheduler node</strong></p><p>Only one server runs cron jobs.</p><p><strong>2. Distributed locks</strong></p><p>All servers attempt the job, but only the one that acquires a lock (Redis, database, etc.) executes it.</p><p><strong>3. Message queues</strong></p><p>Cron only creates tasks, and worker processes handle execution.</p><p><strong>4. Cluster schedulers</strong></p><p>Tools like Kubernetes CronJobs or Airflow coordinate scheduling across multiple machines.</p><p>These approaches ensure that <strong>a job runs exactly once across the system</strong>.</p><h3>Avoiding Traffic Spikes with Cron Jitter</h3><p>Another interesting issue appears when many machines schedule jobs at the same time.</p><p>Imagine thousands of servers all executing tasks exactly at <strong>10:00:00</strong>.</p><p>This can cause sudden spikes in:</p><ul><li>database traffic</li><li>API calls</li><li>email services</li></ul><p>To avoid this, engineers introduce <strong>cron jitter</strong>.</p><p>Instead of executing immediately, the job waits for a random delay.</p><p>Example:</p><pre>0 10 * * * sleep $((RANDOM % 300)) &amp;&amp; run_job.sh</pre><p>This spreads execution over <strong>0–5 minutes</strong>, preventing synchronized spikes.</p><p>The timeline becomes:</p><pre>10:00:03  Server A runs job<br>10:00:17  Server B runs job<br>10:00:41  Server C runs job<br>10:02:02  Server D runs job</pre><p>The workload becomes smoother and systems remain stable.</p><h3>The Beauty of Cron</h3><p>What surprised me the most about cron is how <strong>simple the core idea is</strong>.</p><p>At its heart, cron is just:</p><ul><li>a background daemon</li><li>reading schedule files</li><li>checking the time every minute</li><li>spawning processes to execute commands</li></ul><p>Yet this tiny system utility has automated tasks across Unix systems since the early days of computing.</p><p>And once you start noticing it, cron jobs appear everywhere — from simple log cleanup scripts to complex data pipelines.</p><p>If you’re early in your engineering journey like me, cron is a great reminder that <strong>many powerful systems are built on surprisingly simple ideas</strong>.</p><p>Sometimes all it takes is a small background process that wakes up once a minute and asks:</p><blockquote><em>“Is it time to run something?”</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7f26ca86ddd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I’m Starting a “Things I Googled This Week as an SDE” Series]]></title>
            <link>https://medium.com/@nidhichaudhary2002/why-im-starting-a-things-i-googled-this-week-as-an-sde-series-53067a34f672?source=rss-ff9db7c86e91------2</link>
            <guid isPermaLink="false">https://medium.com/p/53067a34f672</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[entry-level]]></category>
            <category><![CDATA[big-tech]]></category>
            <dc:creator><![CDATA[Nidhichaudhary]]></dc:creator>
            <pubDate>Sun, 15 Mar 2026 08:56:56 GMT</pubDate>
            <atom:updated>2026-03-15T08:56:56.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9go1qLIM6jZft4P3mL2xA.png" /></figure><p>Software engineering is full of words that sound mysterious the first time you hear them.</p><p>Idempotency. Circuit Breakers. Eventual Consistency. Message Queues. Feature Flags.</p><p>The first time I heard some of these in conversations at work, they felt like jargon — the kind of words everyone else seemed to understand immediately while I only had a vague idea of what they meant.</p><p>But over the past few months of working as a software engineer, I’ve started noticing something interesting. Most of these terms aren’t just fancy vocabulary engineers like to throw around. They represent really important ideas about how real systems are designed and how they behave at scale.</p><p>And the funny thing is, once you spend a little time exploring them, they often turn out to be much simpler than they initially sounded — and far more powerful than you expected.</p><p>So I’m starting a small habit. Every weekend I’ll write about a concept that intimidated me at work during the week. Since I’m in my first year of working with real systems, I come across many terms that initially sound complex but turn out to be powerful technologies that play an important role in building and running large systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53067a34f672" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>