<?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 Ernesto on Medium]]></title>
        <description><![CDATA[Stories by Ernesto on Medium]]></description>
        <link>https://medium.com/@ernesto02ma86?source=rss-2d003755dece------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VOS1U4iILo2vYkFPmAioWA.jpeg</url>
            <title>Stories by Ernesto on Medium</title>
            <link>https://medium.com/@ernesto02ma86?source=rss-2d003755dece------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 10:52:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ernesto02ma86/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[Decision Making in the Creation of Asynchronous vs.]]></title>
            <link>https://medium.com/enviame-engineering/decision-making-in-the-creation-of-asynchronous-vs-92f95a0462f1?source=rss-2d003755dece------2</link>
            <guid isPermaLink="false">https://medium.com/p/92f95a0462f1</guid>
            <dc:creator><![CDATA[Ernesto]]></dc:creator>
            <pubDate>Thu, 15 May 2025 15:42:03 GMT</pubDate>
            <atom:updated>2025-05-26T15:51:08.430Z</atom:updated>
            <content:encoded><![CDATA[<h3>Decision making in the creation of asynchronous vs. synchronous services for Envíame billing processes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jCZ7VWDvwloq71MdVRPKw.png" /></figure><p>In software development — particularly in high-volume systems such as billing and logistics platforms — choosing between synchronous and asynchronous services is a critical decision that directly affects efficiency, scalability, and user experience.</p><p>At Envíame, we face unique challenges due to the massive volume of data we handle, such as Excel file uploads containing up to 300,000 records or more. This article explores the key indicators and best practices we follow to determine when to use asynchronous (background) services and when to opt for synchronous ones, based on our experience with technologies like Node.js, Google Cloud Tasks, Google Cloud Storage, and internal rate APIs.</p><h3>Technical context at Envíame</h3><p>At Envíame, we leverage a microservices-based architecture running on Google Cloud. Some of the key components include:</p><ul><li><strong>Node.js</strong>: Used for backend service development, thanks to its efficiency in handling I/O operations and its ability to manage multiple concurrent requests.</li><li><strong>Google cloud tasks</strong>: Enables us to manage asynchronous workloads by queuing and processing large volumes of data without blocking the system.</li><li><strong>Google cloud storage</strong>: Used for storing files — such as the Excel spreadsheets uploaded by users — ensuring both security and scalability.</li><li><strong>Rate APIs</strong>: Used to calculate costs and shipping rates in real time, tightly integrated with our billing and logistics systems.</li></ul><p>In addition, Envíame has developed a specialized service for importing costs from Excel files. This service not only validates and processes the data, but also integrates with our rate APIs to ensure calculations are accurate and up to date.</p><h3>Synchronous vs. Asynchronous services: when to use each</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*NfqnGgJ_572CCrE50Ee8LQ.png" /></figure><h4>Synchronous services</h4><p>Synchronous services are those in which the client waits for an immediate response after making a request. They are ideal for fast, low-computation-cost operations such as:</p><ul><li>Simple validations (e.g., checking the format of a file).</li><li>Queries to small databases.</li><li>Operations that require real-time responses, such as transaction confirmations.</li></ul><p>At Envíame, we use synchronous services for files with data volumes that our ecosystem considers manageable (for example, fewer than 1,000 records according to our internal metrics), where processing is nearly instantaneous and does not justify the complexity of an asynchronous flow.</p><h4>Asynchronous services</h4><p>Asynchronous services allow operations to run in the background, freeing the client from waiting for an immediate response. This is especially useful for:</p><ul><li>Processing large volumes of data (Excel files with hundreds of thousands of records).</li><li>Long-running operations, such as calculating rates for thousands of shipments.</li><li>Tasks that require high scalability and fault tolerance.</li></ul><p>At Envíame, asynchronous services are the backbone of our cost import system, where processing large files can take several minutes or even hours.</p><h3>Criteria for choosing sync or async</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*Z455KLt4uevKGVGqnCSBGQ.png" /></figure><h4>Data volume</h4><p>When files exceed the internally defined “manageable” threshold, synchronous processing becomes unfeasible. This limit varies depending on the technical capabilities of each system, but at Envíame we define it through load testing and performance analysis.</p><h4>Processing time</h4><p>If an operation takes more than a few seconds (for example, when each rate calculation requires an internal API call), it is advisable to use asynchronous services. This prevents blocking and enhances the user experience.</p><h4>Scalability</h4><p>Asynchronous services are more scalable, as they allow workload distribution across multiple instances or tasks. This is particularly useful in cloud environments where demand can fluctuate significantly.</p><h4>Fault tolerance</h4><p>In critical operations, such as cost import processes, it is essential to ensure that tasks are completed even if errors occur. Asynchronous services can be designed to retry failed operations, increasing overall system robustness.</p><h4>Parallel processing</h4><p>When a task can be divided into independent subtasks, parallel processing can significantly reduce execution time. At Envíame, we use Node.js to run tasks in parallel within asynchronous services.</p><h3>Practical example: cost import at Envíame</h3><p>At Envíame, when a user uploads an Excel file containing cost data, the system must validate, process, and calculate rates for each record. Depending on the file size, we decide whether the process will be synchronous or asynchronous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*zjinj5wkFr0a-jvrxKQaWw.png" /></figure><h3>Processing flow</h3><h4>File upload</h4><p>The user uploads an Excel file through our platform.<br> The file is validated to ensure it meets the required format.</p><h4>Synchronous/Asynchronous decision</h4><p>If the file is within the volume we consider manageable, it is processed synchronously.<br> If it exceeds the threshold, it is stored in <strong>Google Cloud Storage (GCS)</strong> and an asynchronous process is triggered.</p><h4>Asynchronous processing</h4><p>The file is split into smaller batches.<br> Each batch is processed in parallel using <strong>Google Cloud Tasks</strong> and <strong>Node.js</strong>.<br> The results are stored in <strong>Google Cloud Storage (GCS)</strong> for later retrieval.</p><h4>User notification</h4><p>Once processing is complete, the user receives a notification (via email or within the platform) with a summary of the results.</p><h4>Asynchronous code in action</h4><p>Here is a code snippet showing how we handle the asynchronous processing of an Excel file at Envíame:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*kTuRTpNFEhnGAznuy4gWlg.png" /><figcaption>Asynchronous Code.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*yagLmmFpvXCG1WKaFqonug.png" /><figcaption>Asynchronous Code.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*khRJueGb-aUD-oq0N5GWZA.png" /></figure><h3>Conclusion</h3><p>At <strong>Envíame</strong>, the choice between synchronous and asynchronous services is driven by clear indicators such as data volume, processing time, and scalability needs. Thanks to this strategy, we have optimized our cost import processes and ensured optimal performance, even under heavy workloads. The combination of technologies like <strong>Node.js</strong>, <strong>Google Cloud Tasks</strong>, and <strong>Cloud Storage buckets</strong> allows us to deliver a smooth and reliable experience to our users.</p><p>This approach not only enhances system efficiency, but also empowers Envíame users to focus on what truly matters: managing their logistics effectively and without hassle.</p><h3>Technical references</h3><h4>Microservices &amp; synchronous vs asynchronous communication</h4><ul><li><a href="https://cloud.google.com/architecture/microservices-architecture-interservice-communication"><em>Interservice communication in a microservices setup — Google Cloud</em></a><br> Official guide from Google on how to choose between synchronous and asynchronous communication in microservices architectures.</li><li><a href="https://martinfowler.com/articles/microservice-trade-offs.html"><em>Microservice Trade-Offs — Martin Fowler</em></a><br> A key article explaining when and why to use microservices, and what trade-offs are involved.</li></ul><h4>Google cloud tasks &amp; asynchronous services</h4><ul><li><a href="https://cloud.google.com/run/docs/triggering/using-tasks"><em>Executing asynchronous tasks with Cloud Tasks — Google Cloud</em></a><br> Practical guide on how to trigger background tasks from Cloud Run using Google Cloud Tasks.</li><li><a href="https://cloud.google.com/tasks/docs"><em>Cloud Tasks Documentation — Google Cloud</em></a><br> Official documentation for working with managed asynchronous task queues in the cloud.</li></ul><h4>Cloud storage</h4><ul><li><a href="https://cloud.google.com/storage/docs/best-practices"><em>Best Practices for Cloud Storage — Google Cloud</em></a><br> Recommended best practices by Google for storing and managing files (such as Excel documents) efficiently and securely in the cloud.</li></ul><h4>Parallel processing with node.js</h4><ul><li><strong>Speed up your code with Promise.all</strong> — <em>Devin Perry, DEV Community</em><br> <a href="https://dev.to/dperrymorrow/speed-up-your-code-with-promiseall-3d4i">https://dev.to/dperrymorrow/speed-up-your-code-with-promiseall-3d4i</a><br> Explains how using Promise.all() can drastically reduce execution time when handling multiple asynchronous operations.</li><li><strong>How async/await can slow down your node.js app</strong> — <em>Arunangshu Das, Medium</em><br> <a href="https://medium.com/@arunangshudas/how-async-await-can-slow-down-your-node-js-app-2bd8c6f793f7">https://medium.com/@arunangshudas/how-async-await-can-slow-down-your-node-js-app-2bd8c6f793f7</a><br> A practical article showing when await can become a bottleneck and how Promise.all() can improve performance.</li><li><strong>Improving performance with async/await and promise.all()</strong> — <em>Abdul Ghaffar, LinkedIn</em><br> <a href="https://www.linkedin.com/pulse/improving-performance-asyncawait-promiseall-abdul-ghaffar">https://www.linkedin.com/pulse/improving-performance-asyncawait-promiseall-abdul-ghaffar</a><br> Focuses on real-world examples where concurrent async execution enhances Node.js service efficiency.</li><li><strong>Mastering promises and async/await in javascript: best practices</strong> — <em>Rahul Bharati</em><br> <a href="https://blog.rahulbharati.dev/mastering-promises-and-async-await-in-javascript-best-practices-and-code-examples-dac12d805ccc">https://blog.rahulbharati.dev/mastering-promises-and-async-await-in-javascript-best-practices-and-code-examples-dac12d805ccc</a><br> Offers a complete breakdown of modern async programming patterns with working examples.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92f95a0462f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enviame-engineering/decision-making-in-the-creation-of-asynchronous-vs-92f95a0462f1">Decision Making in the Creation of Asynchronous vs.</a> was originally published in <a href="https://medium.com/enviame-engineering">Envíame Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>