<?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 Prashant Pandey on Medium]]></title>
        <description><![CDATA[Stories by Prashant Pandey on Medium]]></description>
        <link>https://medium.com/@prashant.pandey?source=rss-65a0b819d967------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Prashant Pandey on Medium</title>
            <link>https://medium.com/@prashant.pandey?source=rss-65a0b819d967------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 07:10:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prashant.pandey/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[The curious case of Migrations]]></title>
            <link>https://tech.oyorooms.com/the-curious-case-of-migrations-23c2a4fa9447?source=rss-65a0b819d967------2</link>
            <guid isPermaLink="false">https://medium.com/p/23c2a4fa9447</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[migration]]></category>
            <dc:creator><![CDATA[Prashant Pandey]]></dc:creator>
            <pubDate>Thu, 08 Apr 2021 08:47:27 GMT</pubDate>
            <atom:updated>2021-04-09T15:32:29.373Z</atom:updated>
            <content:encoded><![CDATA[<p>We often find ourself in the need to rewrite/migrate apis from one system(codebase, infrastructure) to another system. To rewrite any api running on high demand with expectation of zero downtime / zero percentage errors involves following challenges.</p><ol><li>Ensure response of new and old api is same for all inputs without involving clients</li><li>Smooth and safe migration of api without any downtime</li></ol><p>We at OYO used following techniques to tackle these challenges.</p><h4><strong>Shadow Testing approach</strong></h4><p>This approach was used to ensure the correctness of the revamped api.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*-JFPDoxF4A3GQDrO" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ClrfdMPe7D0iX5vS" /><figcaption>Green — % matches , Red —% mismatches</figcaption></figure><p>In this approach, A parallel environment (namely shadow testing environment) of using same data sources as of production environment was set up using the same database, another environment(namely async workers, which will calculate and publish the correctness of api, matches and mismatches of the apis) was set up.</p><p>Whenever an api request lands on the existing prod environment, before sending the response to the client, it schedules a job with params as request and response of api to run on async workers.</p><p>The job makes requests to the new shadow environment (which runs the new developed code) and compares the production and shadow environment responses and publishes in the logs if any mismatch is found with mismatch details in logs.</p><p>This process of making changes continues till we get a 100 % match result in the shadow testing results.</p><h3><strong>Approaches for smooth and safe migration</strong></h3><h4><strong>1. Change in Interceptor approach</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*EEGdQC7QAtSqdPc7_4Tj7g.jpeg" /><figcaption>Requests are being routed from interceptor</figcaption></figure><p>In this approach, One adapter will be added at the interceptor layer of the source application from where api needs to be migrated. The adapter will read the configuration and based on configuration for the api in database, it will decide how much percentage of requests should be migrated to the destination server.</p><p>Major drawback of this approach is : The requests always need to go through source application, i.e. another dependency for resource allocation, thread management and response builder.</p><h4>2. <strong>Changes in api gateway router</strong></h4><p>In this approach, changes are done at api gateway router level. Where for any specific endpoint of specific url, rules will be there to identify which server the request should be served from.</p><h4><strong>Implementation of the approach in case of Kubernetes ingress controller as api gateway router</strong></h4><p><strong>Inception of dual Stack</strong></p><p>It is a rule defined to achieve blue green deployment at ingress level where before routing requests to specific replica set, ingress will read configuration defined in helm (e.g. how should requests be divided between the two given replica sets) and route them accordingly. Since changes in ingress reflect dynamically (there is no need of deployment of ingress controller), changes in configuration of dual stack reflects dynamically i.e. developers can always change the %requests route to each replica set through option present in helm. (see <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary">https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary</a> to implement dual stack through annotations)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*_dERzh9DfIT_WgNq" /></figure><p><strong>Exporting options to change/configure rollout percentage to helm</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLIMSPLwMtzTw2YmKA_q-A.png" /><figcaption>Helm option to change rollout percentage</figcaption></figure><p>To export the option to helm, we need to create a <strong>dualstack.yml</strong> file which in which main_stack and canary_stack will be defined along with canary_weight (i.e. % requests route to canary stacks) .</p><pre><strong>gateway:<br>  public: false<br>  hostname: dualstack.abcd.com<br>canary_weight: 0<br>project: dualstack<br>dualstack:<br>  enabled: true<br>  main_stack:<br>    label: 1<br>    project: server-1<br>  canary_stack:<br>    label: 1<br>    project: server-2</strong></pre><p><strong>Ingress controller changes</strong></p><pre>  spec {<br>    rule {<br>      host = &quot;abcd.com&quot;<br>      http {<br>        path {<br>          path = &quot;/api/v2/endPoint&quot;<br>          backend {<br>            service_name = &quot;dualstack-main&quot;<br>            service_port = &quot;80&quot;<br>          }<br>        }<br>        path {<br>          path = &quot;/api/v2/users/endPoint2&quot;<br>          backend {<br>            service_name = &quot;dualstack-main&quot;<br>            service_port = &quot;80&quot;<br>          }<br>        }     <br>      }<br>   }<br> }</pre><p>The above changes will be added in ingress controller, where the rule of routing is defined as per the code. In this code, rule is written for url “abcd.com” and for endpoint “/api/v2/endPoint” and “/api/v2/users/endPoint2” to be routed to the dual stack (through dual stack to specific replica set according to it’s configuration).</p><p>By following these approaches, we at OYO were able to migrate Identity management service with zero error and downtime.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23c2a4fa9447" width="1" height="1" alt=""><hr><p><a href="https://tech.oyorooms.com/the-curious-case-of-migrations-23c2a4fa9447">The curious case of Migrations</a> was originally published in <a href="https://tech.oyorooms.com/">OYOTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>