<?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 Wahid Shakib on Medium]]></title>
        <description><![CDATA[Stories by Wahid Shakib on Medium]]></description>
        <link>https://medium.com/@wsakib87?source=rss-f7bf227462b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WBQ3dJXLhr_dck-d</url>
            <title>Stories by Wahid Shakib on Medium</title>
            <link>https://medium.com/@wsakib87?source=rss-f7bf227462b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 17:53:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wsakib87/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[How We Migrated 100M+ Records Across 25 Salesforce Tables With Zero Data Loss]]></title>
            <link>https://medium.com/@wsakib87/how-we-migrated-100m-records-across-15-salesforce-tables-with-zero-data-loss-c5e00e474562?source=rss-f7bf227462b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5e00e474562</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-migration]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[engineering-stories]]></category>
            <dc:creator><![CDATA[Wahid Shakib]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 07:53:35 GMT</pubDate>
            <atom:updated>2026-12-01T07:54:39.831Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>100 million records. 25 tables. 6+ months. Zero data loss.</strong></p><p>Data migration sounds straightforward until you have to do it in production, with limited storage, strict platform limits, complex relationships, and almost no room for downtime.</p><p>When we discuss large-scale data migration, we usually think about data replication, message queues, Change Data Capture (CDC), dual writes, feature flags, and rollback strategies.</p><p>But in our case, most of those options were either impractical or too expensive to implement.</p><p>We had to find another way.</p><h3>The constraints we were dealing with</h3><p>Our migration involved moving data across 25 Salesforce tables. We were also denormalizing the data, combining information from multiple tables into a standardized structure.</p><p>This introduced several challenges.</p><h3>1. Salesforce storage limitations</h3><p>We couldn’t simply duplicate all the data in the destination tables and keep the old data around indefinitely.</p><p>Storage was limited, so every migration step had to be carefully planned.</p><h3>2. Salesforce governor limits</h3><p>Salesforce has strict limits on queries, DML operations, and platform events within a transaction.</p><p>If we tried to synchronize multiple tables simultaneously, we would potentially need to perform the same operations twice: once for the old structure and once for the new structure.</p><p>That would quickly push us toward the limits of Salesforce.</p><h3>3. Complex relationships</h3><p>We weren’t just moving records from one table to another.</p><p>Some tables depended on others. We had to preserve relationships even when the destination structure was different from the original one.</p><h3>4. Downtime and data consistency</h3><p>We needed to make sure that no records were lost between exporting the data and deploying the code that would start using the new structure.</p><p>We also needed a way to recover if something went wrong.</p><p>The obvious solution was to introduce a replication layer with CDC or a message queue.</p><p>But given our constraints, that would have added more complexity than we could justify.</p><p>So we took a different approach.</p><h3>The strategy: Migrate in small chunks</h3><p>Instead of migrating all 25 tables at once, we divided the migration into smaller chunks.</p><p>Each chunk contained approximately 2–3 related tables.</p><p>For every chunk, we followed the same process:</p><ol><li>Export the required data.</li><li>Migrate the data to the new structure.</li><li>Validate the migrated records.</li><li>Deploy the updated Salesforce code during off-peak hours.</li><li>Monitor the system before moving to the next chunk.</li><li>If everything is ok, then remove old data after a week.</li></ol><p>This gave us several advantages.</p><p>We didn’t need to duplicate the entire dataset at once. We could focus on a small number of tables, debug issues more easily, and keep the migration process manageable.</p><p>Most importantly, we didn’t need to introduce a feature flag or maintain two active data structures indefinitely.</p><p><strong>Only one chunk was migrated at a time.</strong></p><h3>How we designed the migration scripts</h3><p>The migration scripts were responsible for more than simply copying records.</p><p>We had to preserve relationships, handle different destination structures, and make sure that the new records could be connected correctly.</p><h3>Step 1: Identify the dependency graph</h3><p>Before exporting anything, we identified which tables depended on which other tables.</p><p>Some tables had to be migrated before others because they acted as parents.</p><p>For example:</p><pre>Parent Table<br>    |<br>    +---- Child Table A<br>    |<br>    +---- Child Table B<br>              |<br>              +---- Child Table C</pre><p>We migrated the parent table first, followed by the dependent tables. if dependent tables were not on the list of migration script that day, we would simply update the relationship field.</p><p>This ensured that the destination relationships could be established correctly.</p><h3>Step 2: Preserve the old IDs</h3><p>One of the most important decisions was to preserve the old record IDs during migration.</p><p>We needed those IDs to establish relationships between records in the new structure.</p><p>Our scripts maintained a mapping between the old IDs and the corresponding destination records.</p><pre>Old Parent ID  ---&gt;  New Parent ID<br>Old Child ID   ---&gt;  New Child ID</pre><p>When migrating a child record, we used this mapping to determine which destination parent it should reference.</p><p>Without this step, preserving relationships across a denormalized structure would have been much more difficult.</p><h3>Step 3: Estimate the migration volume</h3><p>Before running the scripts, we determined how many records needed to be inserted or updated.</p><p>This helped us estimate the migration duration and identify potentially risky chunks.</p><p>We exported the required data only after understanding the dependencies and expected volume.</p><h3>Step 4: Insert first, then update relationships</h3><p>We used Salesforce Data Loader to perform the required inserts and updates.</p><p>The migration process was designed so that records could be inserted first and then updated with the appropriate relationship information.</p><p>This was particularly useful when a destination record depended on another record that had not yet been migrated.</p><h3>Making the migration faster with Python asyncio</h3><p>After completing a few migrations, we noticed that our scripts could be made more efficient.</p><p>We introduced Python’s asyncio library to improve the update phase.</p><p>The idea was simple:</p><ul><li>Inserts were performed synchronously to maintain the required ordering.</li><li>Updates were performed asynchronously to improve throughput.</li></ul><p>This allowed us to preserve the dependency order where necessary while reducing the time spent waiting for independent update operations.</p><p>It wasn’t a complete rewrite of the migration process. It was an optimization we introduced after understanding the actual bottlenecks.</p><h3>What if something went wrong?</h3><p>We also needed a rollback strategy.</p><p>Our approach was deliberately simple.</p><p>If we encountered an issue after deploying the new code, we could revert the code to the previous version.</p><p>The migrated data would still exist, but the old code would no longer use it.</p><pre>Migration completed<br>       |<br>       v<br>Deploy new code<br>       |<br>       v<br>Issue detected?<br>   /       \<br>  No       Yes<br>  |         |<br>Continue   Revert code<br>migration     |<br>              v<br>       Old system restored</pre><p>This meant we didn’t need to immediately delete or reverse millions of migrated records during an incident.</p><p>The data migration and the code deployment were treated as separate operations.</p><p>That separation gave us a much simpler recovery path.</p><h3>How did we avoid losing data during deployment?</h3><p>This was probably the most important part of the entire process.</p><p>There was a potential consistency problem:</p><p>What if a user inserted or modified a record after we exported the data but before we deployed the new code?</p><p>That record could be missing from the destination structure.</p><p>We addressed this by scheduling each migration during off-peak hours, when users were not using the software.</p><p>We exported and migrated the data, then deployed the updated code during the same maintenance window.</p><p>This significantly reduced the risk of concurrent modifications between the export and deployment phases.</p><p>It also gave us enough time to validate the migration before the new code started using the destination tables.</p><h3>The difficult part: 20M+ records in a single day</h3><p>The migration took more than six months to complete.</p><p>Most chunks were manageable, but some were significantly larger than others.</p><p>At one point, we had to migrate more than 20 million records in a single day.</p><p>That was where the process became particularly challenging.</p><p>We had to carefully manage the migration volume, monitor the scripts, and make sure that Salesforce’s limits did not become a bottleneck.</p><p>There were hiccups along the way, but the chunk-based approach helped us isolate and troubleshoot them without putting the entire migration at risk.</p><h3>What I learned</h3><p>Looking back, the most important lesson wasn’t about Python, Salesforce, or even data migration.</p><p>It was about choosing the right level of complexity.</p><p>We could have introduced CDC, message queues, dual writes, and feature flags. Those are valid solutions for many migration scenarios.</p><p>But they weren’t necessarily the right solutions for ours.</p><p>Instead, we chose a controlled, incremental migration process that worked within the constraints of the platform.</p><p>We traded some migration speed for simplicity, predictability, and a much easier rollback strategy.</p><p>And that trade-off worked.</p><p><strong>100M+ records. 25 tables. 6+ months of migration. Zero data loss.</strong></p><p>Sometimes the best migration architecture isn’t the most sophisticated one.</p><p>It’s the one you can execute safely, understand completely, and recover from when things go wrong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5e00e474562" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I said “NO” to a feature that my Manager was pushing me to complete]]></title>
            <link>https://medium.com/@wsakib87/how-i-said-no-to-a-feature-that-my-manager-was-pushing-me-to-complete-56cbc1312abd?source=rss-f7bf227462b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/56cbc1312abd</guid>
            <category><![CDATA[saying-no]]></category>
            <category><![CDATA[cdc]]></category>
            <dc:creator><![CDATA[Wahid Shakib]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 04:42:55 GMT</pubDate>
            <atom:updated>2026-11-26T05:25:14.027Z</atom:updated>
            <content:encoded><![CDATA[<p>My manager came to me with a feature request that sounded straightforward at first.</p><p>The goal was to synchronize user data from Project A to Project B so that we could reduce the cost of maintaining a cloud project. The idea was to have a single source of truth for user data, with changes synchronized almost in real time.</p><p>Technically, this wasn’t a particularly difficult problem. We could build a synchronization mechanism, listen for changes using CDC(Changed Data Capture), and propagate the data between the two projects.</p><p>But the more I thought about it, the more I realized that <strong>the hardest part wasn’t synchronization. It was deciding which data to trust.</strong></p><h3>The problem wasn’t technical</h3><p>Imagine a user exists in both projects.</p><p>Project A has the user’s phone number as +880XXXXXXXX78, while Project B has it as +880XXXXXXXX79.</p><p>Now we have a conflict.</p><p>Which phone number should take priority?</p><p>Should Project A always win? Should Project B? Should we use the most recently updated value?</p><p>Each of these approaches sounds reasonable until you consider the actual business context.</p><p>What if the phone number in Project A was updated by an authorized employee, while the number in Project B was entered incorrectly by a user?</p><p>What if both numbers were correct at different points in time?</p><p>And more importantly, how would the system know which one was correct?</p><p>A synchronization mechanism can easily overwrite one value with another. But it cannot magically determine whether the incoming data is trustworthy.</p><h3>The real risk: losing trust in the system</h3><p>Consider another scenario.</p><p>A user has phone number A in Project A and phone number B in Project B.</p><p>Now imagine a deal is in progress. The sales team is communicating with the user using phone number A.</p><p>In the middle of that deal, a synchronization process changes the user’s phone number to B.</p><p>Suddenly, the system becomes unreliable.</p><p>The sales team may no longer know which number to use. The user may receive calls from the wrong number. And the people working with the data may lose confidence in the system.</p><p>Even if the synchronization process is technically working exactly as designed, the business outcome could still be wrong.</p><p>That’s when I realized something important:</p><p><strong>A system can be technically correct and still be operationally untrustworthy.</strong></p><h3>I pushed back</h3><p>After researching the problem, I realized that implementing synchronization between the two projects was not the hardest part.</p><p>The real challenge was defining the business rules around data ownership, conflict resolution, and correctness.</p><p>Before building anything, we needed answers to questions like:</p><ul><li>Which project owns the user data?</li><li>Who is authorized to modify it?</li><li>What happens when both projects have conflicting values?</li><li>Can a synchronization process overwrite data during an active business transaction?</li><li>How do we recover if incorrect data gets synchronized?</li></ul><p>Without clear answers, we would simply be automating the propagation of potentially incorrect information.</p><p>I brought these concerns to my manager.</p><p>Initially, the feature was being pushed forward because the expected benefit was clear: reducing cloud costs.</p><p>But after discussing the potential consequences, my manager understood that the risk was much greater than the apparent simplicity of the implementation.</p><p>Eventually, we decided not to proceed with the feature.</p><h3>Saying “No” is part of engineering</h3><p>As software engineers, we often feel that our job is to turn requirements into working code.</p><p>But I believe our responsibility goes beyond implementation.</p><p>Sometimes, the most valuable contribution an engineer can make is identifying a problem before it becomes an expensive production incident.</p><p>I didn’t say no because the feature was difficult to build.</p><p>I said no because <strong>we hadn’t defined what correctness meant.</strong></p><p>And in systems that handle business-critical data, that distinction matters more than the implementation itself.</p><p>Reducing cloud costs is important. But if the cost of doing so is losing trust in the data, we may end up paying much more in the long run.</p><p>Sometimes, the best engineering decision is not to build the feature.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56cbc1312abd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Reduced Salesforce Auth Token Exhaustion Using Platform Cache]]></title>
            <link>https://medium.com/@wsakib87/how-i-reduced-salesforce-auth-token-exhaustion-using-platform-cache-168a66dbf8d4?source=rss-f7bf227462b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/168a66dbf8d4</guid>
            <category><![CDATA[saleforce]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[cache-stampede]]></category>
            <dc:creator><![CDATA[Wahid Shakib]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 07:34:31 GMT</pubDate>
            <atom:updated>2026-11-24T07:34:31.361Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An on-call engineering experience: solving an authentication bottleneck under production pressure.</em></p><h3>The Problem: Too Many Requests, Too Many Tokens</h3><p>We had an external Angular application that communicated with our backend to retrieve various resources. Our backend, in turn, communicated with a Salesforce organization.</p><p>The authentication flow was relatively straightforward:</p><ol><li>The Angular application made a request to our backend.</li><li>The backend requested an access token from the Salesforce OAuth authentication server.</li><li>Once it received the token, it used it to make API calls to our Salesforce organization.</li><li>The backend returned the requested data to the Angular application.</li></ol><p>There was one major problem with this approach: <strong>we were requesting a new Salesforce access token for every incoming backend request.</strong></p><p>A single page load could trigger more than 100 requests to retrieve different resources. Now imagine 10–20 users opening the same page simultaneously.</p><p>That’s potentially thousands of authentication requests hitting the Salesforce OAuth server within a very short period.</p><p>Eventually, we started experiencing Salesforce authentication failures due to token request exhaustion.</p><p>I knew the architecture wasn’t optimal. However, as the primary on-call engineer, I needed to find a solution quickly without introducing significant changes to the existing system.</p><h3>The Initial Thought: Should We Retry?</h3><p>My first thought was to introduce a retry mechanism whenever the authentication request failed.</p><p>But after thinking about it, I realized that this could make things worse.</p><p>If the Salesforce authentication server was already struggling with the volume of requests, retrying failed requests would generate even more traffic.</p><p>Instead of reducing the load, we would amplify it.</p><p>I needed a way to avoid making unnecessary authentication requests in the first place.</p><h3>The Solution: Salesforce Platform Cache</h3><p>While exploring possible solutions, I came across Salesforce Platform Cache.</p><p>Platform Cache allows applications to temporarily store frequently accessed data and retrieve it without repeatedly executing expensive operations.</p><p>What caught my attention was that the cache wasn’t tied to an individual request or a particular application session. It could be shared across requests.</p><p>That was exactly what I needed.</p><p>Instead of requesting a new access token for every backend request, I could retrieve a token once, cache it, and reuse it across subsequent requests.</p><h3>How I Implemented It</h3><p>The implementation was relatively simple.</p><p>Immediately after successfully retrieving an access token from the Salesforce OAuth server, I stored it in Platform Cache with a time-to-live (TTL) of one hour.</p><p>For every subsequent incoming request, the backend followed this flow:</p><ol><li>Check Platform Cache for an existing access token.</li><li>If a valid cached token exists, retrieve and reuse it.</li><li>If the token is missing, request a new one from the Salesforce authentication server.</li><li>Store the newly retrieved token in Platform Cache.</li><li>Use the token to make the requested Salesforce API call.</li></ol><p>The result was that hundreds of incoming backend requests could reuse the same access token instead of independently requesting one.</p><h3>Before vs. After</h3><p><strong>Before:</strong></p><ul><li>Every incoming backend request triggered an OAuth token request.</li><li>A single page load could generate 100+ authentication requests.</li><li>Multiple concurrent users amplified the problem.</li></ul><p><strong>After:</strong></p><ul><li>The first request retrieved and cached the access token.</li><li>Subsequent requests reused the cached token.</li><li>Authentication requests were significantly reduced.</li></ul><p>This was a relatively small change that addressed a significant production bottleneck without requiring a major architectural overhaul.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O8Wdn13ZyjD2-CzAD8jJgg.png" /></figure><h3>Things I Learned Along the Way</h3><p>The solution addressed our immediate problem, but it also introduced some considerations that I hadn’t initially accounted for.</p><h3>1. Cache Stampede</h3><p>One potential issue is cache stampede (also known as a thundering herd problem).</p><p>Imagine the cached token expires or gets evicted.</p><p>If 100 requests arrive simultaneously, they might all find the cache empty and independently request a new access token from Salesforce.</p><p>We would end up with the same problem we were trying to solve.</p><p>A better implementation would introduce some form of request coordination or locking so that only one request refreshes the token while the others wait for the result.</p><p>This wasn’t something I encountered during the initial implementation, but it was an important edge case I identified later.</p><h3>2. Tight Coupling Between Authentication and Caching</h3><p>Another thing I realized was that authentication had become tightly coupled with Platform Cache.</p><p>The application was responsible for both retrieving the access token and managing its lifecycle in the cache.</p><p>For example, if we needed to invalidate a token, we also needed to make sure the corresponding cached entry was removed.</p><p>This introduced additional responsibility into our application code.</p><p>Ideally, authentication and token lifecycle management should be handled by a dedicated mechanism rather than being scattered throughout the application.</p><h3>3. Named Credentials: The Better Long-Term Approach</h3><p>Later, I realized that Salesforce Named Credentials could have been a better architectural choice if we maintain it per environment such as using prefix or suffix.</p><p>Named Credentials provide a declarative way to manage authentication and external service connections.</p><p>They handle much of the authentication lifecycle for you, reducing the need to manually retrieve, store, and manage access tokens.</p><p>There was another issue with our original implementation: we were storing authentication credentials in Custom Settings.</p><p>Named Credentials would have provided a more secure and maintainable approach to managing those credentials.</p><p>In retrospect, I would have preferred this approach for a long-term solution rather than maintaining a custom token management mechanism.</p><h3>Final Thoughts</h3><p>This experience taught me something important about production engineering.</p><p>Sometimes, the best immediate solution isn’t necessarily the best long-term architecture.</p><p>As an on-call engineer, I had to understand the bottleneck, evaluate the potential impact of different approaches, and make a decision under pressure.</p><p>Platform Cache gave us a relatively straightforward way to reduce unnecessary authentication requests and stabilize the integration.</p><p>However, it also taught me to think beyond the immediate fix:</p><ul><li>What happens when the cache expires?</li><li>What happens when multiple requests try to refresh the same token?</li><li>Who is responsible for token invalidation?</li><li>Are we reinventing something the platform already provides?</li></ul><p>Looking back, I would still consider caching a useful technique for reducing repeated authentication calls, but I would evaluate Named Credentials much earlier when designing the integration.</p><p><strong>The biggest takeaway: solving a production incident is not just about making things work again. It’s also about understanding the trade-offs of the solution you introduce.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=168a66dbf8d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>