<?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 Alember Shreesh on Medium]]></title>
        <description><![CDATA[Stories by Alember Shreesh on Medium]]></description>
        <link>https://medium.com/@gosucode?source=rss-15b372fad854------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lJxvrOLQ0eHMJe8MJQlacA.jpeg</url>
            <title>Stories by Alember Shreesh on Medium</title>
            <link>https://medium.com/@gosucode?source=rss-15b372fad854------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:33:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gosucode/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[Managing a scalable microservices API Gateway using KrakenD]]></title>
            <link>https://medium.com/@gosucode/managing-a-scalable-microservices-api-gateway-using-krakend-7d90ab7dbb57?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d90ab7dbb57</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[krakend]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 08:33:05 GMT</pubDate>
            <atom:updated>2026-07-22T11:43:02.905Z</atom:updated>
            <content:encoded><![CDATA[<h4>The fastest API Gateway in the market, ready to run on premises, cloud, or hybrid.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*nUBAzBsXBBzta2sI.png" /><figcaption>Image by KrakenD</figcaption></figure><blockquote>The gateway sits in front of your microservices to provide access control, security, throttling, analytics, and much more. KrakenD is not only a proxy but a Backend for Frontend that can aggregate and transform multiple calls simultaneously, avoiding network traffic and reducing bandwidth consumer to the end-user.</blockquote><p>KrakenD can be set up in a single krakend.json file. A single, massive krakend.json with hardcoded backends is an anti-pattern. Pros treat gateway configurations like clean, modular code.</p><h3>1. The Directory Structure</h3><p>Instead of one file, we’re splitting gateway configuration by domain, environments, and general settings which keeps it dynamic and organized as well.</p><pre>├── .env<br>├── .gitignore<br>├── docker-compose.yml<br>└── config/<br>    ├── krakend.tmpl<br>    ├── settings/<br>    │   ├── dev<br>    |   |   ├── hosts.json<br>    │   └── prod<br>    |       └── hosts.json<br>    └── endpoints/<br>        ├── products.tmpl<br>        └── users.tmpl</pre><h3>2. Step-by-Step Implementation</h3><h4>Step 1: Container Orchestration (docker-compose.yml)</h4><p>Instruct KrakenD to enable <strong>F</strong>lexible <strong>C</strong>onfiguration (FC_ENABLE), declare the directory where your modular endpoint templates live (FC_TEMPLATES), and point to your environment variables (FC_SETTINGS).</p><pre>services:<br>  gateway:<br>    container_name: api-gateway<br>    image: krakend:2.13.8<br>    ports:<br>      - &quot;3000:3000&quot;<br>    volumes:<br>      - ./config:/etc/krakend:ro<br>    environment:<br>      - FC_ENABLE=1<br>      - FC_TEMPLATES=/etc/krakend/endpoints<br>      - FC_SETTINGS=/etc/krakend/settings/dev<br>    command: [&quot;run&quot;, &quot;-c&quot;, &quot;/etc/krakend/krakend.tmpl&quot;]<br>    restart: unless-stopped</pre><p><strong>FC_ENABLE=1</strong>: Tells KrakenD to turn on the template engine.</p><p><strong>FC_TEMPLATES</strong>: Points to the directory containing your modular template files (like your endpoints/ folder).</p><p><strong>FC_SETTINGS</strong>: Points to the file or directory containing your environment variables (like hosts.json).</p><h4>Step 2: Environment Settings (config/settings/dev/hosts.json)</h4><p>Use this file to store microservice host URLs and environment-specific strings, keeping them out of your main routing logic.</p><pre>{<br>  &quot;hosts&quot;: {<br>    &quot;product_service&quot;: &quot;http://product-api:5001&quot;,<br>    &quot;user_service&quot;: &quot;http://user-api:5002&quot;<br>  }<br>}</pre><h4>Step 3: Modular Endpoints (config/endpoints/users.tmpl)</h4><p>Define template configurations using standard Go templating.</p><pre>{<br>  &quot;endpoint&quot;: &quot;/api/auth/register&quot;,<br>  &quot;method&quot;: &quot;POST&quot;,<br>  &quot;backend&quot;: [{<br>    &quot;url_pattern&quot;: &quot;/api/auth/register&quot;,<br>    &quot;host&quot;: [&quot;{{ .hosts.user_service }}&quot;]<br>  }]<br>},<br>{<br>  &quot;endpoint&quot;: &quot;/api/auth/login&quot;,<br>  &quot;method&quot;: &quot;POST&quot;,<br>  &quot;backend&quot;: [{<br>    &quot;url_pattern&quot;: &quot;/api/auth/login&quot;,<br>    &quot;host&quot;: [&quot;{{ .hosts.user_service }}&quot;]<br>  }]<br>}</pre><blockquote>Notice how we reference <strong>&quot;{{ .hosts.user_service }}&quot;</strong>? At build time, KrakenD compiles this template and automatically swaps that placeholder with the URL from your environment settings file <strong>(hosts.json)</strong>.</blockquote><h4>Q. What is “endpoint” and “backend”?</h4><ul><li><strong>“endpoint”</strong> = public route on KrakenD (POST /api/auth/register).</li><li><strong>“backend”</strong> = which internal microservice handles it (user-svc:4001).</li></ul><p>KrakenD proxies the request from<strong> endpoint → backend</strong>, applying rate limiting, JWT auth, and circuit breakers along the way.</p><h4>Q. what is this .tmpl file?</h4><p><strong>A:</strong> <strong>.tmpl</strong> (Template) file is a plain text blueprint containing static configuration mixed with dynamic placeholders (like {{ .hosts.user_service }}).</p><p>It leverages Go’s templating engine to act as a flexible skeleton before the final configuration is compiled.</p><h4>Example:</h4><ol><li><strong>Template (</strong><strong>users.tmpl):</strong></li></ol><pre>&quot;host&quot;: [ &quot;{{ .hosts.user_service }}&quot; ]</pre><p><strong>2. Variables (</strong><strong>hosts.json):</strong></p><pre>{ <br>  &quot;product_service&quot;: &quot;http://localhost:5001&quot;,<br>  &quot;user_service&quot;: &quot;http://localhost:5002&quot;<br>}</pre><p><strong>3. What KrakenD actually runs in memory:</strong></p><pre>&quot;host&quot;: [ &quot;http://localhost:5002&quot; ]</pre><h4>Q. &quot;host&quot;: [ &quot;{{ .hosts.user_service }}&quot; ] how is it getting the user service url with that?</h4><p>It works via KrakenD’s <strong>Flexible Configuration(</strong>FC) engine during container startup. It executes in two quick steps:</p><ol><li><strong>The Flag:</strong> In your docker-compose.yml, you set FC_SETTINGS=/etc/krakend/settings/dev. This forces KrakenD to load your hosts.json file into memory as the core data dictionary.</li><li><strong>The Evaluation:</strong> As KrakenD compiles the configuration, it encounters the template syntax {{ .hosts.user_service }}. The dot (.) represents the root of your loaded hosts.json file. It navigates down the keys: hosts <strong>→</strong>user_service, extracts the string &quot;http://user-api:5002&quot;, and replaces the placeholder entirely before compiling the route.</li></ol><h4>Step 4: The Entrypoint (config/krakend.tmpl)</h4><p>Tie everything together into the main skeleton. KrakenD will pull the files from your FC_TEMPLATES (defined in docker compose file) directory and compile them here.</p><pre>{<br>  &quot;version&quot;: 3,<br>  &quot;port&quot;: 8080,<br>  &quot;timeout&quot;: &quot;3s&quot;,<br>  &quot;endpoints&quot;: [<br>    {{ template &quot;products.tmpl&quot; . }},<br>    {{ template &quot;users.tmpl&quot; . }}<br>  ]<br>}</pre><h3>Now let’s go a little bit further: <strong>extra_config</strong></h3><p>extra_config helps to enable and configure plugins, middleware, and extended features. It unlocks advanced capabilities such as security, rate limiting, logging and metrics.</p><h4>krakend.tmpl</h4><pre>{<br>  &quot;version&quot;: 3,<br>  &quot;port&quot;: 8080,<br>  &quot;timeout&quot;: &quot;3s&quot;,<br>  &quot;endpoints&quot;: [<br>    {{ template &quot;products.tmpl&quot; . }},<br>    {{ template &quot;users.tmpl&quot; . }}<br>  ],<br>  &quot;extra_config&quot;: {<br>    &quot;telemetry/logging&quot;: {<br>      &quot;level&quot;: &quot;INFO&quot;,<br>      &quot;prefix&quot;: &quot;[KRAKEND]&quot;,<br>      &quot;stdout&quot;: true<br>    },<br>    &quot;security/cors&quot;: {<br>      &quot;allow_origins&quot;: [&quot;*&quot;],<br>      &quot;allow_methods&quot;: [&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;, &quot;PATCH&quot;, &quot;DELETE&quot;],<br>      &quot;allow_headers&quot;: [&quot;Authorization&quot;, &quot;Content-Type&quot;]<br>    }<br>  }<br>}</pre><p>In krakend.tmpl we are using it for logging and security(to handle cors).</p><h4>user.tmpl</h4><pre>{<br>  &quot;endpoint&quot;: &quot;/api/auth/register&quot;,<br>  &quot;method&quot;: &quot;POST&quot;,<br>  &quot;output_encoding&quot;: &quot;no-op&quot;,<br>  &quot;extra_config&quot;: {<br>    &quot;qos/ratelimit/router&quot;: { &quot;max_rate&quot;: 200, &quot;capacity&quot;: 200, &quot;every&quot;: &quot;1s&quot; }<br>  },<br>  &quot;backend&quot;: [{<br>    &quot;url_pattern&quot;: &quot;/api/auth/register&quot;,<br>    &quot;host&quot;: [&quot;{{ .hosts.user_service }}&quot;],<br>    &quot;encoding&quot;: &quot;no-op&quot;,<br>    &quot;extra_config&quot;: {<br>      &quot;qos/circuit-breaker&quot;: { &quot;max_errors&quot;: 10, &quot;interval&quot;: 60, &quot;timeout&quot;: 30, &quot;name&quot;: &quot;cb-users-post-register&quot;, &quot;log_status_change&quot;: true }<br>    }<br>  }]<br>},<br>{<br>  &quot;endpoint&quot;: &quot;/api/auth/login&quot;,<br>  &quot;method&quot;: &quot;POST&quot;,<br>  &quot;output_encoding&quot;: &quot;no-op&quot;,<br>  &quot;extra_config&quot;: {<br>    &quot;qos/ratelimit/router&quot;: { &quot;max_rate&quot;: 200, &quot;capacity&quot;: 200, &quot;every&quot;: &quot;1s&quot; }<br>  },<br>  &quot;backend&quot;: [{<br>    &quot;url_pattern&quot;: &quot;/api/auth/login&quot;,<br>    &quot;host&quot;: [&quot;{{ .hosts.user_service }}&quot;],<br>    &quot;encoding&quot;: &quot;no-op&quot;,<br>    &quot;extra_config&quot;: {<br>      &quot;qos/circuit-breaker&quot;: { &quot;max_errors&quot;: 10, &quot;interval&quot;: 60, &quot;timeout&quot;: 30, &quot;name&quot;: &quot;cb-users-post-login&quot;, &quot;log_status_change&quot;: true }<br>    }<br>  }]<br>}</pre><p>configs used in the .tmpl file</p><ul><li><strong>qos/ratelimit/router:</strong> 200 request per sec allowed</li><li><strong>qos/circuit-breaker: W</strong>e’ll talk in detail below.</li><li><strong>output_encoding: “no-op” (endpoint level) </strong>: controls how KrakenD merges and returns the response to the client after gathering data from all backends.</li><li><strong>encoding: “no-op” (backend-level) </strong>: controls how KrakenD parses/decodes the response coming from that specific backend.</li></ul><h4>Q. What if i don’t provide output_encoding: “no-op”? how will this affect the response that i’ll get from the backend to api-gateway?</h4><p>Without <strong>output_encoding: “no-op”</strong>, KrakenD applies its default JSON response wrapping. The response gets reformatted into KrakenD’s standard envelope.</p><p><strong>Example — backend returns:</strong></p><pre>{ “token”: “abc123”, “user”: { “id”: 1, “email”: “a@b.com” } }</pre><p>With <strong>“no-op” </strong>— client gets exactly that, raw:</p><pre>200 { “token”: “abc123”, “user”: { “id”: 1, “email”: “a@b.com” } }</pre><p>Without it (default) — KrakenD wraps it:</p><pre>200 { “content”: { “token”: “abc123”, “user”: { “id”: 1, “email”: “a@b.com” } } }</pre><h4>Circuit Breaker</h4><p>It’s job is to <strong>STOP</strong> KrakenD from sending requests to a failing service, giving that service time to recover and preventing a total system crash.</p><pre>&quot;extra_config&quot;: {<br>      &quot;qos/circuit-breaker&quot;: { <br>        &quot;max_errors&quot;: 10, <br>        &quot;interval&quot;: 60, <br>        &quot;timeout&quot;: 30, <br>        &quot;name&quot;: &quot;cb-users-post-login&quot;, <br>        &quot;log_status_change&quot;: true <br>      }<br>}</pre><p>How above specific setting works</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*l6wB44QXWI7-ju6iN7rbag.png" /><figcaption>Circuit breaker State — Image by Author</figcaption></figure><p><strong>Closed:</strong> Closed is a healthy state, it means circuit breaker is close and requests can pass normally.</p><p><strong>Open:</strong> If KrakenD counts max_error(10 errors)<strong> </strong>within time interval(60s), it blocks all the requests to the backend server.</p><p><strong>Half Open:</strong> After the 30-second timeout expires, the circuit breaker enters the Half-Open state. In that state, it allows to pass limited number of requests to test if the backend is actually stable. If the test passes, Circuit Breaker goes in <strong>Close state</strong> else goes in <strong>Open state.</strong></p><p>Some unexplained configs in the circuit breaker</p><p><strong>name : </strong>A friendly name to follow this circuit breaker’s activity in the <strong>logs</strong>.</p><p><strong>log_status_change</strong>: Whether to log the changes of state of this circuit breaker or not. Default to false .</p><h3>More features provided by KrakenD</h3><p><strong>Data Manipulation &amp; Aggregation:</strong> Merge multiple microservice responses into a single JSON object.</p><p><strong>Authentication Offloading:</strong> Native JWT validation plugins allow the gateway to reject unauthorized requests at the edge before they even touch your internal networks.</p><p><strong>Response Caching:</strong> In-memory or Redis caching options.</p><p><strong>Comprehensive Metrics:</strong> Native integration with Prometheus, Jaeger, OpenTelemetry, and ELK stack for plug-and-play system visibility.</p><blockquote>As I implement more features, I’ll update this setup. How are you currently managing your API Gateway configurations? Let me know in the comments!</blockquote><h3>Have a nice day!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d90ab7dbb57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What the heck is Redis???]]></title>
            <link>https://medium.com/codetodeploy/what-the-heck-is-redis-a67ac3a9f1f5?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/a67ac3a9f1f5</guid>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 16:30:31 GMT</pubDate>
            <atom:updated>2026-04-13T16:30:31.521Z</atom:updated>
            <content:encoded><![CDATA[<h4>Questions I asked when learning Redis.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*za0PBVGiyXHY3ihDz9lDcA.png" /><figcaption>Image by Author</figcaption></figure><h4>Q: What is Redis?</h4><p><strong>A:</strong></p><p>At first, I got this answer from AI:</p><blockquote>“Redis (Remote Dictionary Server) is an open-source, in-memory, NoSQL data structure store used primarily as a database, cache, message broker, and streaming engine.”</blockquote><p>And honestly… I was like<em>, &quot; What???</em> I said it to tell me shortly and simply.</p><blockquote>Redis is a super fast storage system that keeps data in memory (RAM) instead of disk.</blockquote><h4>Stores data in a key -&gt; value pair</h4><pre>&quot;name&quot; → &quot;Golden&quot;<br>&quot;user:1&quot; → { id: 1, name: &quot;Alember&quot; }</pre><blockquote><em>🚨 </em><strong><em>Hiring Tech Talent (Remote + Onsite)</em></strong><br>💰 $3K–$10K/Month</blockquote><blockquote>Apply once — get your profile in front of <strong>thousands of hiring companies in minutes</strong><br> and increase your interview chances.</blockquote><blockquote><a href="https://optimhire.com/?ref_code=codetodeploy"><strong>👉 Apply in 60 seconds</strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkQFf0NUnzoFbVEVQCF5WQ.png" /></figure><h4><strong>Q:</strong> Isn’t checking Redis before DB an extra operation that slows things down?</h4><p><strong>A:</strong> Redis check (~1 ms) is much faster than DB (~50 ms). Most requests hit cache, so overall it speeds things up despite the small extra step.</p><h4><strong>Q:</strong> Should I use local Redis or an online (managed) Redis?</h4><ul><li><strong>Local Redis</strong> → best for development (simple, free)</li><li><strong>Managed Redis</strong> → best for production (scalable, reliable)</li></ul><h4><strong>Q:</strong> How do we know which data to store in Redis and how much data to store?</h4><p><strong>A:</strong> Store data that is frequently read, slow or costly to fetch, and <strong>does not change too often</strong>. Store only the minimum useful data, preferably with an expiry time. Cache hot data, not everything.</p><h4><strong>Q:</strong> If DB data changes, what happens to cached data? Will server use cache or DB? What to do?</h4><ul><li>Cache may become <strong>stale</strong> (old data).</li><li>Server will still return <strong>cache</strong> until it expires or is cleared.</li></ul><h4><strong>Solutions:</strong></h4><ol><li><strong>TTL (expiry):</strong> Auto refresh after some time</li><li><strong>Cache invalidation:</strong> Delete/update cache when DB changes</li><li><strong>Write-through / write-back:</strong> Update cache + DB together</li></ol><blockquote><strong>Rule:</strong> Always handle cache invalidation, otherwise you’ll serve outdated data.</blockquote><h4><strong>Q:</strong> What is write-through vs write-back?</h4><ul><li>Write-through → save to DB + cache together (safe)</li><li>Write-back → save to cache first, DB later (risky)</li></ul><p>Write-back → faster but risky (data loss if cache crashes before DB write)</p><h4><strong>Q:</strong> If I save data to both DB and cache in middleware, is it write-back or write-through?</h4><p><strong>A:</strong> It is <strong>write-through</strong>, because both DB and cache are updated immediately.</p><h4><strong>Q:</strong> If I invalidate cache on create/update/delete, can I increase TTL?</h4><p><strong>A:</strong> Yes. With proper invalidation, you can safely use longer TTL since freshness is maintained by invalidation, not expiry.</p><h4><strong>Q:</strong> Does accessing cached data reset TTL?</h4><p><strong>A:</strong> No. TTL is based on when the cache was set. It only resets if the key is updated again.</p><h4><strong>Q:</strong> What is BullMQ used for?</h4><p><strong>A:</strong> It’s used to run background jobs (like emails, reports, notifications) using Redis, so your app stays fast.</p><h4><strong>Q:</strong> Can BullMQ be used without Redis?</h4><p><strong>A:</strong> No. BullMQ depends on Redis and is not a part of Redis — it runs on top of it.</p><h4><strong>Q:</strong> Can I cache only selected fields, like only amount from invoice/expense/purchase summaries?</h4><p><strong>A:</strong> Yes. You should cache only the minimum useful data needed, not the whole object.</p><h4><strong>Q:</strong> My backend is using Docker, so what should be the Redis URL?</h4><p><strong>A:</strong> If your backend is running inside Docker and Redis is running on the AWS server host machine, use:</p><h4><strong>Case 1: Redis outside Docker</strong></h4><pre>REDIS_URL=redis://host.docker.internal:6379</pre><p>host.docker.internal does <strong>NOT work by default on Linux</strong> (works on Mac/Windows only). And in docker-compose.yml, add:</p><pre>extra_hosts:<br>  - &quot;host.docker.internal:host-gateway&quot;</pre><p><strong>Why?</strong><br>Because inside a Docker container, 127.0.0.1 points to the container itself, not the server host. So the backend container cannot reach host Redis through 127.0.0.1.</p><p><strong>Do not use: </strong>REDIS_URL=redis://127.0.0.1:6379</p><h4><strong>Case 2 (Recommended): Redis inside Docker</strong></h4><p>if Redis is outside Docker and backend is inside Docker.</p><blockquote>Better long-term (cleanest architecture) — Run Redis in Docker too</blockquote><pre>REDIS_URL=redis://redis:6379</pre><p>And in compose:</p><pre>redis:<br>  image: redis:alpine<br>  container_name: test-redis<br>  restart: unless-stopped<br>  healthcheck:<br>    test: [&quot;CMD&quot;, &quot;redis-cli&quot;, &quot;ping&quot;]<br>    interval: 10s<br>    timeout: 5s<br>    retries: 5<br> #ports:<br> #  - &quot;6379:6379&quot;</pre><blockquote>I didn’t put the port to avoid a conflict with the Redis service already running on my host machine’s port 6379, while still allowing the backend to connect internally within the Docker network.</blockquote><h4><strong>Q:</strong> Will Redis cache be cleared when I redeploy/restart server?</h4><p><strong>A:</strong> No, unless Redis itself restarts or is not persistent. Cache usually survives app restarts.</p><h4><strong>Q:</strong> Without a Redis volume in Docker Compose, will cache reset on rebuild/redeploy?</h4><p><strong>A:</strong> Yes, if the Redis container is recreated, the cache will be lost. Only backend restart usually won’t clear it.</p><p>For <strong>cache use case</strong>, losing Redis on deploy is often acceptable. Because cache is temporary by nature.</p><h4><strong>Q:</strong> How to check how much RAM Redis cache is using?</h4><p><strong>A:</strong> Run redis-cli info memory (or via Docker exec) and check used_memory_human.</p><p>If using Docker:</p><pre>docker exec -it container-name redis-cli info memory</pre><h4><strong>Q:</strong> Should I set a memory limit for Redis?</h4><p><strong>A:</strong> Yes. For production caching, set a memory limit so Redis does not consume too much RAM.</p><h4><strong>Q:</strong> How do I set it?</h4><p><strong>A:</strong> In Docker Compose, use Redis command options like --maxmemory 256mb --maxmemory-policy allkeys-lru.</p><pre>redis:<br>  image: redis:alpine<br>  container_name: test-redis<br>  restart: unless-stopped<br>  command: redis-server --appendonly yes --maxmemory 128mb --maxmemory-policy allkeys-lru<br>  healthcheck:<br>    test: [&quot;CMD&quot;, &quot;redis-cli&quot;, &quot;ping&quot;]<br>    interval: 10s<br>    timeout: 5s<br>    retries: 5</pre><ul><li>maxmemory 256mb → Redis can use up to 256 MB RAM</li><li>allkeys-lru → when full, remove least recently used keys</li></ul><h4>Q: Which size to choose?</h4><p><strong>A:</strong> Rough simple rule:</p><ul><li>small app → 128mb</li><li>medium app → 256mb or 512mb</li><li>larger usage → higher after monitoring</li></ul><h4><strong>Q:</strong> What did developers use before Redis?</h4><p><strong>A:</strong> In-memory app cache, database optimizations, file-based caching, and tools like Memcached.</p><h4><strong>Q:</strong> Is there a problem with the cache if Redis says the eviction policy is allkeys-lru but expected noeviction?</h4><pre>IMPORTANT! Eviction policy is allkeys-lru. It should be &quot;noeviction&quot;</pre><p><strong>A:</strong> Not necessarily for cache. allkeys-lru is good for caching. But if the same Redis is also used for BullMQ or critical job data, it can be a problem because Redis may evict important keys.</p><h4><strong>Q:</strong> Can I keep Redis at 256MB with allkeys-lru?</h4><p><strong>A:</strong> Yes. It’s fine for caching and won’t fill too quickly for typical ERP usage. Just avoid using the same Redis for critical jobs like queues.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9QTaaaxboQP_gKSLedW_w.png" /></figure><p>👉 Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></p><p>👉 Follow us: <a href="https://www.linkedin.com/in/bhumika-ch-3784391b9/"><strong>Linkedin</strong></a>| <a href="https://medium.com/codetodeploy"><strong>Medium</strong></a></p><p>👉 CodeToDeploy Tech Community is live on Discord — <a href="https://discord.gg/ZpwhHq6D"><strong>Join now!</strong></a></p><p><strong>Disclosure:</strong> This post includes affiliate and partnership links.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a67ac3a9f1f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codetodeploy/what-the-heck-is-redis-a67ac3a9f1f5">What the heck is Redis???</a> was originally published in <a href="https://medium.com/codetodeploy">CodeToDeploy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NodeJS: Event Loop(Short Version)??]]></title>
            <link>https://medium.com/@gosucode/nodejs-event-loop-short-version-2475d6a4fef2?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/2475d6a4fef2</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[event-loop]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Sat, 07 Feb 2026 06:47:17 GMT</pubDate>
            <atom:updated>2026-02-07T06:47:53.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>Where does the Event Loop live?</h3><p>The Event Loop is a design pattern (a set of rules) implemented by the environment to coordinate how code is executed. It isn’t just “in” the environment; it <em>is</em> the mechanism that allows the environment to handle asynchronous tasks.</p><h4>Where it “lives”</h4><ul><li><strong>In the Browser:</strong> The Event Loop is part of the <strong>Web Browser APIs</strong>. Each tab usually has its own event loop to keep things isolated.</li><li><strong>In Node.js:</strong> The Event Loop is provided by <strong>libuv</strong>, which is a C library that Node.js uses to handle “non-blocking I/O” (like reading files or talking to a database).</li></ul><p>That runtime includes:</p><ol><li><strong>V8 Engine:</strong> To execute the JS.</li><li><strong>libuv:</strong> To provide the Event Loop and Thread Pool.</li><li><strong>Core Modules:</strong> (like fs, http, path) which are the tools you use to interact with the computer.</li></ol><h4>The Engine (e.g., V8, SpiderMonkey)</h4><p>The engine’s job is strictly to take JavaScript code and turn it into machine code that the processor can understand.</p><ul><li><strong>What it has:</strong> The Call Stack (where functions are executed) and the Heap (where memory is allocated).</li><li><strong>What it lacks:</strong> It has no concept of time, files, or network requests. It just executes what it’s told, one line at a time.</li></ul><h4>The Hosting Environment (Browser or Node.js)</h4><p>This is where the Event Loop resides. The Event Loop is part of the Runtime Environment that wraps around the engine.</p><h4>The Two Queues</h4><p>To keep things fast and responsive, the Event Loop prioritizes tasks based on where they come from:</p><h4><strong>Microtask Queue (The High Priority List):</strong></h4><ul><li><strong>Contents:</strong> Promises (.then, .catch, .finally), await continuations, and queueMicrotask.</li><li><strong>The Rule:</strong> The Event Loop cannot move on to anything else until this queue is completely empty. If a microtask adds another microtask, it runs that one too, immediately.</li></ul><h4><strong>Macrotask Queue (The Task Queue / Main List):</strong></h4><ul><li><strong>Contents:</strong> setTimeout, setInterval, setImmediate (Node.js), and I/O operations (like clicking a button or a file finishing its download).</li><li><strong>The Rule:</strong> The Event Loop picks <strong>one</strong> task from here, executes it, and then immediately goes back to check the Microtask Queue again.</li></ul><h4>Trace the Output:</h4><pre>console.log(&#39;A&#39;);<br><br>setTimeout(() =&gt; { console.log(&#39;B&#39;); }, 0);<br><br>Promise.resolve().then(() =&gt; { <br>  console.log(&#39;C&#39;); <br>}).then(() =&gt; { console.log(&#39;D&#39;); });<br><br>console.log(&#39;E&#39;);</pre><h4>Output:</h4><p>The correct order is: <strong>A, E, C, D, B</strong>.</p><h4>Why?</h4><ul><li><strong>A &amp; E (Synchronous):</strong> The “Initial Script” is the first Macrotask. It runs top-to-bottom. It hits A, schedules the timeout, schedules the promise, and hits E.</li><li><strong>C (Microtask):</strong> The script finishes. Before moving to the next Macrotask (the timeout), the loop checks the Microtask queue. It finds the first .then() and prints C.</li><li><strong>D (Microtask):</strong> Since the first promise resolved, the <em>next</em> .then() is immediately added to the Microtask queue. Because the loop <strong>must</strong> empty this queue entirely, it runs D immediately after C.</li><li><strong>B (Macrotask):</strong> Now that the Microtask queue is finally empty, the loop moves to the next Macrotask in line: the setTimeout callback. It prints B.</li></ul><h3>Event Loop Starvation</h3><p>Because the Event Loop <strong>must</strong> finish the entire Microtask queue before it moves to the next Macrotask (like setTimeout or UI rendering), you can accidentally &quot;starve&quot; the loop.</p><p>If a Microtask (Promise) recursively calls another Microtask, the Macrotasks will <strong>never</strong> run.</p><p><strong>Here is what that looks like in logic:</strong></p><pre>function freeze() { <br>  Promise.resolve().then(freeze);<br>}<br><br>freeze();<br><br>setTimeout(() =&gt; console.log(&quot;I will never run!&quot;), 0);</pre><p>In this scenario, the browser tab will literally freeze. It can’t even repaint the screen or handle a mouse click because it’s stuck in an infinite loop of “VIP” Microtasks.</p><h4>One Final Distinction: process.nextTick (Node.js only)</h4><p>If you ever move into heavy Node.js development, you’ll see process.nextTick().</p><ul><li><strong>The Rule:</strong> process.nextTick is even more &quot;VIP&quot; than a Promise.</li><li><strong>The Order:</strong> Synchronous → nextTick → Promises (Microtasks) → Macrotasks.</li></ul><p>If we added process.nextTick(() =&gt; console.log(&#39;VIP&#39;)) to our previous A, E, C, D, B example, the VIP would print right after E but before C.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2475d6a4fef2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker???]]></title>
            <link>https://medium.com/codetodeploy/docker-11994cb59c1a?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/11994cb59c1a</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 16:31:13 GMT</pubDate>
            <atom:updated>2026-01-22T04:15:11.519Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/codetodeploy">CodeToDeploy</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*FnK62JU5vb4zk4hd3RILvA.png" /><figcaption>Image by Author</figcaption></figure><h4>Docker Image</h4><p>A Docker image is a built, read-only package.</p><p>It contains:</p><ul><li>OS layer (Linux)</li><li>runtime (Node, etc.)</li><li>app code</li><li>dependencies</li><li>start command</li></ul><p>Key points:</p><ul><li>Images do not run</li><li>Images are templates</li><li>Images are created using a Dockerfile</li></ul><p>Example:</p><pre>docker build -t my-app .</pre><p>This creates an image.</p><h4>Docker Container</h4><p>A Docker container is a running instance of an image.</p><p>Key points:</p><ul><li>Containers run</li><li>Containers are isolated processes</li><li>You can start, stop, restart, delete them</li><li>Multiple containers can come from one image</li></ul><p>Example:</p><pre>docker run my-app</pre><p>This starts a container from the image.</p><h4>Relationship (important)</h4><pre>Dockerfile → Image → Container</pre><ul><li>Dockerfile defines how to build</li><li>Image is what gets built</li><li>Container is what actually runs</li></ul><h4>What is a Dockerfile?</h4><p>A <strong>Dockerfile</strong> is a text file that tells Docker <strong>how to build an image</strong> (step by step).</p><p>Used to:</p><ul><li>define runtime (Node, OS, etc.)</li><li>copy code</li><li>install dependencies</li><li>start the app</li></ul><p>No extension because Docker looks for the exact name Dockerfile by convention.</p><p><strong>server/Dockerfile</strong></p><pre>FROM node:18-alpine<br><br>WORKDIR /app<br><br>COPY package*.json ./<br>RUN npm install --production<br><br>COPY . .<br><br>EXPOSE 3001<br>CMD [&quot;node&quot;, &quot;server.js&quot;]</pre><p><strong>What this does:</strong></p><ul><li>Uses a lightweight Node image</li><li>Installs dependencies</li><li>Copies application code</li><li>Starts the API server</li></ul><h4>Why order matters in Dockerfile</h4><p>Docker builds <strong>line by line</strong> and <strong>caches layers</strong>.</p><p>If a line changes:</p><ul><li>that line and everything after it rebuilds</li></ul><p>That’s why deps are copied before app code.</p><h4>How Docker caching works</h4><ul><li>Each instruction = one layer</li><li>If nothing changed → Docker reuses cached layer</li><li>If something changed → rebuild from that point</li></ul><p>Result:</p><ul><li>Faster builds</li><li>Smaller rebuild scope</li></ul><h3>Dockerfile vs docker-compose.yml</h3><ul><li><strong>Dockerfile</strong> → how to build <strong>one image</strong></li><li><strong>docker-compose.yml</strong> → how to run <strong>multiple containers together</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*kmeHrPAHHgG7Xd7zCikFsA.png" /></figure><h4>When to use what</h4><ul><li>Only Dockerfile → single service</li><li>Dockerfile + Compose → full-stack app</li><li>Only Compose → using prebuilt images</li></ul><h4><strong>Docker Compose</strong>:</h4><blockquote><strong>Docker Compose defines how containers are started, connected, configured, and stopped as a group.</strong></blockquote><pre>services:<br>  backend:<br>    build: ./server<br>    container_name: api<br>    ports:<br>      - &quot;3001:3001&quot;<br>    env_file:<br>      - ./server/.env<br>    restart: unless-stopped<br><br>  frontend:<br>    build: ./client<br>    container_name: web<br>    ports:<br>      - &quot;80:80&quot;<br>    depends_on:<br>      - backend<br>    restart: unless-stopped</pre><p>This keeps frontend and backend isolated but connected.</p><h4>What actually happens</h4><p>When you run:</p><pre>docker compose up</pre><p>Docker Compose:</p><p>1)Looks at docker-compose.yml</p><p>2) For each service:</p><ul><li><strong>builds an image</strong> (if build: is defined) <strong>OR</strong></li><li><strong>pulls an image</strong> (if image: is defined)</li></ul><p>3) creates containers from those images</p><p>4) runs the containers together</p><p>Example:</p><pre>services:<br>  backend:<br>    build: ./server<br>  frontend:<br>    image: nginx</pre><p>What Compose does:</p><ul><li>Builds <strong>one image</strong> for backend</li><li>Pulls <strong>one image</strong> for frontend</li><li>Runs <strong>two containers</strong></li></ul><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9QTaaaxboQP_gKSLedW_w.png" /></figure><p>👉 Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></p><p>👉 Follow us: <a href="https://www.linkedin.com/in/code-to-deploy-3784391b9/"><strong>Linkedin</strong></a>| <a href="https://medium.com/codetodeploy"><strong>Medium</strong></a></p><p>👉 CodeToDeploy Tech Community is live on Discord — <a href="https://discord.gg/ZpwhHq6D"><strong>Join now!</strong></a></p><p><strong>Note:</strong> This Post may contain affiliate links.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11994cb59c1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codetodeploy/docker-11994cb59c1a">Docker???</a> was originally published in <a href="https://medium.com/codetodeploy">CodeToDeploy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Safe, zero-downtime way to increase storage on an EC2 instance (Ubuntu/Linux).]]></title>
            <link>https://medium.com/@gosucode/safe-zero-downtime-way-to-increase-storage-on-an-ec2-instance-ubuntu-linux-a1ec48b1d1ab?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1ec48b1d1ab</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 11:32:26 GMT</pubDate>
            <atom:updated>2026-01-21T11:32:26.741Z</atom:updated>
            <content:encoded><![CDATA[<h4>Overview</h4><ol><li>Increase <strong>EBS volume size</strong> in AWS Console</li><li>Rescan the disk on EC2</li><li>Extend the partition</li><li>Grow the filesystem</li></ol><p>No reboot required in most cases.</p><h4>1. Increase volume size in AWS Console</h4><ol><li>Go to <strong>EC2 → Volumes</strong></li><li>Select the volume attached to your instance</li><li>Click <strong>Modify volume</strong></li><li>Increase size (e.g. 8 → 24GB)</li><li>Click <strong>Modify</strong></li></ol><p>Wait until <strong>State = “in-use” &amp; “optimization completed”</strong></p><h4>2. Connect to your EC2</h4><pre>ssh ubuntu@&lt;EC2_PUBLIC_IP&gt;</pre><h4>3. Check current disk status</h4><pre>lsblk<br>df -h</pre><p>You’ll see the disk size increased but filesystem still old size — this is normal.</p><h4>4. Extend the partition</h4><p>For <strong>most Ubuntu EC2 instances (NVMe disk)</strong>:</p><pre>sudo growpart /dev/nvme0n1 1</pre><p>If your disk is xvda instead:</p><pre>sudo growpart /dev/xvda 1</pre><h4>5. Extend the filesystem</h4><p>Check filesystem type:</p><pre>df -T /</pre><p>If ext4 (most common):</p><pre>sudo resize2fs /dev/nvme0n1p1</pre><p>If xfs:</p><pre>sudo xfs_growfs /</pre><h4>6. Verify</h4><pre>df -h</pre><p>You should now see the new total size.</p><h3>Important safety notes</h3><ul><li><strong>Never format</strong> (mkfs) — that wipes data</li><li>Don’t detach the volume unless you know what you’re doing</li><li>Expanding EBS is <strong>non-destructive</strong></li><li>Take a <strong>snapshot</strong> before resizing if this is production (recommended)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1ec48b1d1ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Load Balancing (Simple, Practical Explanation)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/javarevisited/load-balancing-simple-practical-explanation-605acccc2317?source=rss-15b372fad854------2"><img src="https://cdn-images-1.medium.com/max/734/1*BHwRmoZ54i_TG4DGQARwPg.png" width="734"></a></p><p class="medium-feed-snippet">Not a member? Read for free here.</p><p class="medium-feed-link"><a href="https://medium.com/javarevisited/load-balancing-simple-practical-explanation-605acccc2317?source=rss-15b372fad854------2">Continue reading on Javarevisited »</a></p></div>]]></description>
            <link>https://medium.com/javarevisited/load-balancing-simple-practical-explanation-605acccc2317?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/605acccc2317</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Sat, 10 Jan 2026 10:55:11 GMT</pubDate>
            <atom:updated>2026-01-10T15:00:49.256Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Node.js Send Email using Google OAuth2]]></title>
            <link>https://medium.com/@gosucode/node-js-send-email-using-google-oauth2-99b54aa1f72f?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/99b54aa1f72f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[bulk-mail]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 07:10:45 GMT</pubDate>
            <atom:updated>2025-12-22T07:10:45.610Z</atom:updated>
            <content:encoded><![CDATA[<p>Create a project in the <a href="https://console.cloud.google.com/"><strong>Google Developer Console</strong></a><strong>.</strong></p><p>Create/Add new project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*K0BlAhaon5KxQEC1PKmXog.png" /></figure><p>After the project is successfully created,</p><ul><li>Make sure your project is selected</li><li>Go to API &amp; Services</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcXJhY5Cv9TeUw9eGX_vtQ.png" /></figure><ul><li>Go to <strong>Credentials </strong>and <strong>Create credentials -&gt; OAuth client ID</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdA6x8i3uxirNC1Y-gPkNg.png" /></figure><ul><li>Add authorized redirect URIs <a href="https://developers.google.com/oauthplayground/">https://developers.google.com/oauthplayground/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*UASOLYyxu-ArHhQ6VTuD5Q.png" /></figure><ul><li>Push to production</li><li>First go to <strong>OAuth consent screen -&gt; Audience -&gt; Publish App</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75E20YVKvxsPQdQbN4Er9w.png" /></figure><ul><li>Enable G-Mail API</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*HctB81OkxG64QvHqp2xOBw.png" /></figure><ul><li>Search Gmail API and enable it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*kk-OJG1Th_y9npMArhbw9A.png" /></figure><p>Required dependency in project</p><pre>npm install googleapis</pre><p>Sending Mail</p><pre>const { google } = require(&#39;googleapis&#39;);<br><br>/* Initialize OAuth2 Client */<br>const getOAuth2Client = (accessToken) =&gt; {<br>  const client = new google.auth.OAuth2(<br>    process.env.GOOGLE_CLIENT_ID,<br>    process.env.GOOGLE_CLIENT_SECRET,<br>    process.env.GOOGLE_REDIRECT_URI<br>  );<br><br>  client.setCredentials({ access_token: accessToken });<br>  return client;<br>};<br><br>/* Send one email */<br>const sendSingleEmail = async (accessToken, to, subject, html) =&gt; {<br>  const gmail = google.gmail({<br>    version: &#39;v1&#39;,<br>    auth: getOAuth2Client(accessToken),<br>  });<br><br>  const message = [<br>    `To: ${to}`,<br>    `Subject: ${subject}`,<br>    &#39;Content-Type: text/html; charset=utf-8&#39;,<br>    &#39;&#39;,<br>    html,<br>  ].join(&#39;\r\n&#39;);<br><br>  const raw = Buffer.from(message)<br>    .toString(&#39;base64&#39;)<br>    .replace(/\+/g, &#39;-&#39;)<br>    .replace(/\//g, &#39;_&#39;)<br>    .replace(/=+$/, &#39;&#39;);<br><br>  await gmail.users.messages.send({<br>    userId: &#39;me&#39;,<br>    requestBody: { raw },<br>  });<br>};<br><br>/* Bulk sender */<br>const sendBulkEmail = async (req, res) =&gt; {<br>  try {<br>    const { accessToken, recipients = [], subject, htmlBody } = req.body;<br><br>    let success = 0;<br>    let failed = 0;<br><br>  // Sequentially send emails by looping over recipients<br>    for (const email of recipients) {<br>      try {<br>        await sendSingleEmail(accessToken, email, subject, htmlBody);<br>        success++;<br>      } catch {<br>        failed++;<br>      }<br>    }<br><br>    res.json({<br>      success: true,<br>      result: { total: recipients.length, success, failed },<br>    });<br>  } catch (e) {<br>    res.status(500).json({ success: false, message: e.message });<br>  }<br>};<br><br>module.exports = sendBulkEmail;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99b54aa1f72f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why the Backend Doesn’t Need `.env` in Docker/CI but the Frontend Does]]></title>
            <link>https://medium.com/@gosucode/why-the-backend-doesnt-need-env-in-docker-ci-but-the-frontend-does-e39174f6d955?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/e39174f6d955</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Sun, 14 Dec 2025 06:08:46 GMT</pubDate>
            <atom:updated>2025-12-14T06:08:46.106Z</atom:updated>
            <content:encoded><![CDATA[<h4>CI/CD Workflow</h4><h4>1. Backend: Runtime Environment Variables</h4><p>Your backend (Node/Spring/etc.) reads:</p><pre>const key = process.env.POSTHOG_API_KEY;</pre><ul><li>process.env is <strong>read at runtime</strong>, when the container starts.</li><li>Docker, docker-compose, Kubernetes, systemd, whatever — all of these can inject envs <strong>when the container runs</strong>.</li><li>No need to bake them into the build image; they’re live values.</li></ul><p><strong>Analogy:</strong> Backend envs are like a lamp plugged into the wall — you can swap the socket anytime, and it still works.</p><h4>2. Frontend: Compile-Time Environment Variables</h4><p>Your frontend (Vite + React) reads:</p><pre>const key = import.meta.env.VITE_POSTHOG_API_KEY;</pre><ul><li>import.meta.env is replaced <strong>during </strong><strong>npm run build</strong>.</li><li>By the time the JS bundle is served, the code is static; runtime Docker envs do nothing.</li></ul><p><strong>Analogy:</strong> Frontend envs are like sealing a key in concrete — once baked, you can’t change it without rebuilding.</p><h3>How to Handle It in the Workflow (Frontend)</h3><p>Set the secrets in github secrets.</p><h4>Update the frontend Dockerfile to accept build args</h4><p>Before the build:</p><pre># Build stage<br>FROM node:20-alpine AS builder<br>WORKDIR /build<br><br># Copy package files<br>COPY package*.json ./<br>RUN npm install<br>COPY . .<br><br># Accept Vite build-time env<br>ARG VITE_POSTHOG_API_KEY<br>ARG VITE_POSTHOG_HOST<br>ENV VITE_POSTHOG_API_KEY=$VITE_POSTHOG_API_KEY<br>ENV VITE_POSTHOG_HOST=$VITE_POSTHOG_HOST<br><br>ENV NODE_OPTIONS=--max-old-space-size=2048<br><br># Build<br>RUN npm run build</pre><p><strong>Explanation:</strong></p><ul><li><strong>ARG</strong> allows the Docker build to receive values from GitHub Secrets</li><li><strong>ENV</strong> makes them visible to Vite during <strong>npm run build</strong></li></ul><p>Without this, Vite sees nothing.</p><h4>Update GitHub Actions frontend build step</h4><pre>- name: Build and push frontend<br>  uses: docker/build-push-action@v5<br>  with:<br>    context: ./frontend<br>    push: true<br>    tags: ${{ steps.meta-frontend.outputs.tags }}<br>    labels: ${{ steps.meta-frontend.outputs.labels }}<br>    platforms: linux/amd64<br>    build-args: |<br>      VITE_POSTHOG_API_KEY=${{ secrets.VITE_POSTHOG_API_KEY }}<br>      VITE_POSTHOG_HOST=${{ secrets.VITE_POSTHOG_HOST }}</pre><p><strong>Explanation:</strong></p><ul><li>Passes your GitHub Secrets into Docker</li><li>Ensures <strong>npm run build</strong> sees the envs</li><li>Guarantees PostHog key is baked into production JS</li></ul><h3>Notes</h3><ul><li>Always store secrets in GitHub repo secrets (or your CI platform’s equivalent) — never hardcode them.</li><li>Built-in vars like import.meta.env.MODE (“production”) or <strong>import.meta.env.PROD</strong> (true) work automatically — no need to set those.</li><li>If your app has <strong>no custom VITE_ variables</strong>, then no — you don’t need to specify any.</li><li>This applies to any CI/CD (GitHub Actions, Vercel, Netlify, etc.) — the principle is the same: vars must be present at build time.</li></ul><p>This setup ensures your production build embeds the correct values, just like local .env.production does.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e39174f6d955" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Ctrl+C Terminates Your Programs in the Terminal?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@gosucode/why-ctrl-c-terminates-your-programs-in-the-terminal-df2fe6e76230?source=rss-15b372fad854------2"><img src="https://cdn-images-1.medium.com/max/600/1*PThiI58ejfVn9eDckTM81w.png" width="600"></a></p><p class="medium-feed-snippet">The Mechanics Behind Ctrl+C, SIGINT, and Force-Killing Processes</p><p class="medium-feed-link"><a href="https://medium.com/@gosucode/why-ctrl-c-terminates-your-programs-in-the-terminal-df2fe6e76230?source=rss-15b372fad854------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@gosucode/why-ctrl-c-terminates-your-programs-in-the-terminal-df2fe6e76230?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/df2fe6e76230</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Sun, 28 Sep 2025 16:41:49 GMT</pubDate>
            <atom:updated>2025-09-28T16:42:37.805Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[I Went From Googling Problems to Writing on Medium]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/midform/i-went-from-googling-problems-to-writing-on-medium-d15b53d60e48?source=rss-15b372fad854------2"><img src="https://cdn-images-1.medium.com/max/2600/0*ZpSCFv-KpdxmDITe" width="3829"></a></p><p class="medium-feed-snippet">Medium turned me from a reader into a writer.</p><p class="medium-feed-link"><a href="https://medium.com/midform/i-went-from-googling-problems-to-writing-on-medium-d15b53d60e48?source=rss-15b372fad854------2">Continue reading on Midform »</a></p></div>]]></description>
            <link>https://medium.com/midform/i-went-from-googling-problems-to-writing-on-medium-d15b53d60e48?source=rss-15b372fad854------2</link>
            <guid isPermaLink="false">https://medium.com/p/d15b53d60e48</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alember Shreesh]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 04:29:07 GMT</pubDate>
            <atom:updated>2025-09-26T04:29:49.418Z</atom:updated>
        </item>
    </channel>
</rss>