<?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 Vivek Sharma on Medium]]></title>
        <description><![CDATA[Stories by Vivek Sharma on Medium]]></description>
        <link>https://medium.com/@vivek_skywalker?source=rss-a4fb063e09fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WO88g-H_qMWIW6ja.jpg</url>
            <title>Stories by Vivek Sharma on Medium</title>
            <link>https://medium.com/@vivek_skywalker?source=rss-a4fb063e09fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:02:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vivek_skywalker/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[Serverless Architecture: Introduction]]></title>
            <link>https://medium.com/@vivek_skywalker/serverless-architecture-introduction-8853c9db5653?source=rss-a4fb063e09fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/8853c9db5653</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 11:54:21 GMT</pubDate>
            <atom:updated>2023-01-07T11:54:48.654Z</atom:updated>
            <content:encoded><![CDATA[<p>First let’s address the elephant in the room. It does not mean there are not servers involved, of course you need machines running your business logic and serving client requests. “Serverless” is a terrible misnomer for a really well designed architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*leI2Ss41s71x_KBEVLc9xA.png" /><figcaption>I knew it !!</figcaption></figure><p>All what “serverless” means is that the team or developer adopting a serverless architecture is not anymore responsible for managing and provisioning of these servers, the job gets <strong>delegated to the cloud provider </strong>and thereby frees up the engineering resources with in the team to focus on the application logic only.</p><h3><strong>Need for serverless</strong></h3><p>The way in which engineering teams deploy their code has evolved over the years. Traditionally, APIs are hosted on hardware server which is configured and managed by the team in-house.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FB3qxOIflo-ezotje4H0Fg.png" /><figcaption>API server hosted on hardware</figcaption></figure><p>Now this hardware server which might have a hypothetical config of 16GB RAM and 8 core CPU is continuously running. It is capable of handling 10,000 requests per seconds. Such a fixed configuration is only efficient when the server expects a constant (or almost constant) traffic as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*v5-mdizQFqdpWueksrW9WQ.png" /><figcaption>Near constant traffic</figcaption></figure><p>Most real world applications do not have such near constant traffic on them. There are spikes or surges which can last for a few seconds to few days e.g. e-commerce websites will see traffic surge for few days before the Christmas week or a news application will see traffic spike of few hours on the day of the election result, similar to the pattern shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*cBd_qX3f7Wjh9V9504UP6Q.png" /><figcaption>Temporary traffic surges</figcaption></figure><p>Now the hardware server which we will have to configure to handle such traffic will have to take into account the surges to prevent any outages but such surges last for far less time and the rest of the time we are wasting extra resources. This is the reason for the development of serverless computing.</p><p>Applications with irregular traffic ideally needed something which can meet the following requirements:<br>1. Scale up and down with the incoming traffic<br>2. Self-maintained and fault-tolerant<br>3. Gets billed per execution.</p><p>Keeping all the jargon aside, what happens in serverless architecture is that when the traffic is small, the infrastructure being used (for which we get billed) is small and when the traffic increases, the infrastructure also scales up. So the infrastructure becomes “elastic” in a way.</p><p>This “elasticness” is achieved through something called as “<strong>Function as a Service or FaaS</strong>, they get spin-up for a little bit of time on demand and are deleted afterwards. This can potentially save a lot of money for the team which is getting wasted on idle server resources. As there is no idle time with this setup, it is super cost effective.</p><p>All the major cloud providers like Google(Google cloud functions), Amazon(lambda functions), Cloudfare(cloudfare workers), Azure(azure serverless functions) provide some kind of FaaS. All of them have the same core idea, which is <strong>billed per execution</strong>. These are kind of like compute platforms for functions (single unit of deployment of code, like process sending OTP to user or generate a report file, etc.) which are executed in response to events (like button-click from user or month-end event). This is referred to as an Event-driven architecture. We can build our apps which use databases, IOT devices, etc which create the events and the application code listens to those events, and acts accordingly.</p><h3>Use cases</h3><p>Some of the real-world scenario of bursty traffic where serverless architecture makes sense.</p><ol><li><strong>CRON jobs</strong>: Imagine an investment agency which manages the portfolio of a lot of individual clients. They want to automate the process the report generation for each of them at month end (or start) and send each one an email. Now things like report generation and email processing are resource intensive tasks and need “big” servers but this is needed only for few days ( or few hours) each month. So why deploy a big server which would run idly for days not doing anything.</li><li><strong>Online evaluation platforms: </strong>Platforms like Leetcode are one of the best use-cases for serverless architecture. Every time a candidate submits code for testing purpose, a server running the evaluation service gets spin-up, does the processing and then gets destroyed. So the Leetcode engineers don’t need to worry about how many candidates are using the platform simultaneously, as they will only get billed per use and infrastructure will scale with the increasing or decreasing use.</li><li><strong>(Infrequent) Batch / Stream processing: </strong>Typically we might have an asynchronous flow where after an API request, we put a message on a message broker(SQS maybe). Now we need a bunch of servers (or a big server) constantly polling the message broker for new messages (a bunch of servers to handle surges) but if there are no messages in the broker our servers are still running and doing nothing. Serverless can make this architecture “reactive”. For every cloud provider we can plug the message broker to their serverless e.g. AWS lambda functions with AWS SQS, whenever there is a message on SQS trigger this lambda function. So this completely eliminates the need for server polling the message broker.</li></ol><h3>When not to use:</h3><ol><li>User traffic is “almost” constant and predictable, serverless becomes costlier in this use case compared to a traditional approach.</li><li>Multi-tenancy is needed, serverless is not isolated and all the application servers are running on the same underlying infrastructure.</li><li>Trendy, don’t jump in blindy without understanding the use case and the expected traffic pattern.</li></ol><h3>Advantages:</h3><ol><li>No server management and maintain: This done by the cloud provider, no need for engineers to worry about the Docker container or security patching or managing access control to the production servers.</li><li>Pay per use: All serverless functions (most of them) get billed for the amount of time they are running and executing your application logic.</li><li>No capacity planning: Scale up/down is abstracted away. No need to worry about traffic and outages.</li></ol><h3>Disadvantages:</h3><ol><li><strong>Cold-start problem</strong>: If there is not traffic to the application, the underlying server might not even be up and running as it get built per execution. So for the first request, the infrastructure needs to actually boot up, leading to a relatively long latency. There are hacky ways to get around this issue but out-of-the box, serverless is not designed for zero traffic.</li><li><strong>Testing and Debugging: </strong>Log statements written for serverless architecture are created inside the logging framework of the cloud provider e.g. if we are using AWS lambda functions, logs go inside AWS cloudwatch and debugging the application using those logs in painful to say the least. It’s better to use serverless for small utilities which are easy to test and debug.</li><li><strong>Vendor lock: </strong>Moving from one cloud provider to the next is not trivial because the application code is very specific to the cloud provider. A lot of pre-consideration is needed before picking one cloud provider as migration is not at all seamless.</li></ol><p>Thanks for reading. Feel free to suggest corrections and edits to this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8853c9db5653" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Permutation Importance]]></title>
            <link>https://medium.com/@vivek_skywalker/permutation-importance-a1df5010fa99?source=rss-a4fb063e09fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1df5010fa99</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[permutation-importance]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[feature-importance]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Sun, 23 Sep 2018 08:19:17 GMT</pubDate>
            <atom:updated>2018-09-23T08:31:10.168Z</atom:updated>
            <content:encoded><![CDATA[<p>It answers one of the most primitive questions that data scientists wonder about their model.</p><blockquote><strong><em>Which features have the most impact on my model or feature importance ?</em></strong></blockquote><p>There is no silver bullet to go about measuring feature importance and <em>permutation importance</em> is one of the commonly used methods to do this. It has the following advantages over other techniques.</p><ol><li>Fast to calculate</li><li>Easy to use and understand</li><li>It has properties we want a feature importance measure to have.</li></ol><h4><strong>How does it work ?</strong></h4><p>Permutation importance is calculated after a model has been trained. This technique asks question to the trained model that if we randomly shuffle a column of the validation data while leaving the target and all other columns in place, how would that affect the accuracy of the predictions ?</p><p>Random shuffle of a single column should cause less accurate predictions and we are nowhere near any real data. So the idea is that for a feature with high importance this random-reshuffle would cause a lot more damage to the accuracy of the predictions as compared to that for a less important feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*xTnUewjHnsCEzNTMNLLVRw.png" /><figcaption>Fig.1 Random shuffle of &#39;Height at age 10(cm)&#39; column</figcaption></figure><p>As shown in Fig.1, only the values of the column &#39;Height at age 10(cm)&#39; are reshuffled leaving the values in all the other columns as they were before. And if the this column were to have high importance for the trained model then this reshuffle would hurt the performance very badly.</p><h4><strong>Show me some code !!</strong></h4><p>Below you can see a simple RandomForestClassifier being trained to predict if a player from the team won the &#39;Man of the match&#39; award.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/104e0325d7be8d4f5edea6451b680ff0/href">https://medium.com/media/104e0325d7be8d4f5edea6451b680ff0/href</a></iframe><p>Then we use the &#39;eli5&#39; library to calculate permutation importance</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66f1625de82752f0b791c91d948ad164/href">https://medium.com/media/66f1625de82752f0b791c91d948ad164/href</a></iframe><h4><strong>Interpreting Results</strong></h4><p>Features have decreasing importance in top-down order. First number in each row shows the reduction in model performance by reshuffle of that feature. Second number is a measure of the randomness of the performance reduction for different reshuffles of the feature column.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1df5010fa99" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>