<?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 Harsh Prateek on Medium]]></title>
        <description><![CDATA[Stories by Harsh Prateek on Medium]]></description>
        <link>https://medium.com/@harsh-prateek-singh?source=rss-c7bb81ff732a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*K5jccHcrVmw8BlJQYzRocQ.jpeg</url>
            <title>Stories by Harsh Prateek on Medium</title>
            <link>https://medium.com/@harsh-prateek-singh?source=rss-c7bb81ff732a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:54:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harsh-prateek-singh/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[Why GitOps trumps all modern CD Solutions]]></title>
            <link>https://lambda.blinkit.com/why-gitops-trumps-all-modern-cd-solutions-31bc2a710278?source=rss-c7bb81ff732a------2</link>
            <guid isPermaLink="false">https://medium.com/p/31bc2a710278</guid>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Harsh Prateek]]></dc:creator>
            <pubDate>Sun, 02 May 2021 15:12:45 GMT</pubDate>
            <atom:updated>2021-05-02T15:17:25.726Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why GitOps trumps most modern CD Solutions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jmmE0w5OAbJt0ZwN.png" /></figure><p>When Kubernetes started to gain prominence around 2016, a lot of people were exposed to a concept that is fundamental to a lot of fundamental algorithms yet has little real life adoptions — <a href="https://cluster-api.sigs.k8s.io/developer/providers/implementers-guide/controllers_and_reconciliation.html"><strong>Reconcilers</strong></a>. A reconciler is a piece of a code that, at its very least, simply synchronises two different states. The even more fundamental principles it puts into action is eventual consistency, something that has been used in several implementations like Swift file system. Most distributed systems rely on one or the other form of eventual consistency.</p><p>Traditional code delivery mechanisms to Kubernetes needed some glue to keep them running. The typical <a href="https://www.jenkins.io/">Jenkins</a> pipeline mechanism (or similar CD solutions) required loading cluster contexts, some kind of master token to grant access to deploy across multiple namespaces and clusters have to be polled for status and declare deployment guarantee. While this allows for excellent transition with minimal ops overhead, this also presents certain risks and gaps.</p><p>For starters, Jenkins is not an excellent tool for managing secrets. While this can be solved with using backends like <a href="https://www.vaultproject.io/">Vault</a>, the very fact that a pipeline has privileged access over a cluster can lead to certain worse case scenarios. A big challenge can be to identify what exactly is running in the cluster, with multiple micro-services spread across dozens of namespaces, auditing can soon turn into a nightmare.</p><h3>A big challenge can be to identify what exactly is running in the cluster, with multiple micro-services spread across dozens of namespaces, auditing can soon turn into a nightmare.</h3><p>GitOps is based on the principle that code delivery should happen in cluster, not out of cluster. In a typical GitOps approach, we commit the manifests that are supposed to be running on a Kubernetes cluster at any time. Want to deploy an application ? Raise a PR. Update the image ? Raise a PR. The cluster level changes are now mapped to git actions. This immediately provides a host of benefits over the typical out of cluster approach. Individual repos can have different synchronisation rules. <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">RBAC</a> and <a href="https://kubernetes.io/docs/reference/access-authn-authz/abac/">ABAC</a> can provide highly narrowed scope of privileged access that reduce the blast radius for catastrophe. And since everything is now deployed via a git repo, its open up the familiar git tools like code reviews, pipeline checks etc that can help to detect problems before deployment, rather than fixing them post deployment.</p><h3>The Declarative Advantage</h3><p>Once a git repository contains the manifests for a given application, it now becomes a state that is declared and can be referred while making decisions or debugging. Compare this to a Jenkins pipeline that is based on facts, the parameters that were presented when the pipeline was run. And if the pipelines were triggered by another pipeline or some web-hook, the problem of managing the information presented to the pipeline becomes challenging and require extensive error handling similar handling mechanisms</p><h3>Leveraging the mature git ecosystem</h3><p>Git at its core is a ver very mature collaboration systems. While features like code review, checks etc can help establish a robust system to review every change rolling out in the cluster, systems like git blame or git bisect provide a strong mechanism to identify breaking changes and isolate users or bots introducing that change. Graphical git servers like Github or Gitlab can also provide great review mechanisms as well. Also, since everything is now a merge into master, every change is now traceable and can be rolled back to.</p><h3><strong>Single Source of Truth</strong></h3><p>Have more than one entry point for deploying applications ? Do you use Jenkins and GitHub actions for different updates ? This introduces a classic source of truth problem to identify what exactly was deployed in the cluster, and is a painful process of reviewing deployment logs and execution times to come up with the process that rolled the latest change. With GitOps, you can have each commit rollout in a non concurrent fashion, making it easier to identify and rollback breaking changes (<em>revert merge </em>).</p><h3><strong>The Reconciler Advantage</strong></h3><p>A common scenario post deployment is manual hot-fixes. Did a dev rollout a change without a pipeline run ? Or is their some rogue cron job that is altering deployments periodically ? Or did the cluster get compromised ?</p><p>The course of action is a typical CI system would be a nightmare, triggering redeploys, creating namespaces and fixing RBACs. And if you have a not-so-mature monitoring setup, you can have end users updating you over social media about the application malfunction.</p><p>GitOps operator however solve this problem in a simple way, they do comparisons about the drift the manifests in the git and the manifests deployed on the cluster. So if the git code is well in sync (it should not have merged if it was faulty), the only thing an ops team needs to do to ensure desired cluster state with an operator like Flux or Argo is do nothing.</p><h3>The only thing an ops team needs to do to ensure desired cluster state with an operator like Flux or Argo is do nothing.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31bc2a710278" width="1" height="1" alt=""><hr><p><a href="https://lambda.blinkit.com/why-gitops-trumps-all-modern-cd-solutions-31bc2a710278">Why GitOps trumps all modern CD Solutions</a> was originally published in <a href="https://lambda.blinkit.com/">Lambda by Blinkit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CPU Throttling in Kubernetes: A Postmortem]]></title>
            <link>https://lambda.blinkit.com/cpu-throttling-in-kubernetes-a-postmortem-b9b433d24b03?source=rss-c7bb81ff732a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9b433d24b03</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Harsh Prateek]]></dc:creator>
            <pubDate>Wed, 26 Aug 2020 04:39:32 GMT</pubDate>
            <atom:updated>2020-08-27T10:48:16.512Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGxSzsbXtGDq-RfwcBWmEg.jpeg" /></figure><p><a href="https://lambda.grofers.com/a-comprehensive-guide-to-deploying-a-website-in-kubernetes-c5829bfa4519?source=false---------1">Kubernetes is a crucial part of our infrastructure</a>. We don’t just deploy applications on Kubernetes in production, but we also use it heavily for our CI/CD and developer infrastructure. While developing our CI/CD infrastructure, we dealt with a particular performance issue of our dev and CI environments taking up a lot of time to spin up.</p><p>In this article, we will attempt to go deep into the issue that degraded performance of our applications and how we finally solved that issue.</p><h3>Background</h3><p>At Grofers, we follow a microservice architecture where all critical components like payments, carts, inventory, etc. are organised as a microservice. Therefore developers cannot work on multiple services at the same time in the same namespace. This led us to adopt a design where each developer has his own namespace with all services deployed in an isolated environment for testing and debugging. This is what we internally call ‘Grofers-in-a-namespace’. To achieve this, we have developed an in-house tool called mft. Mft is used to create new namespaces in Kubernetes and inject necessary dependencies from <a href="https://www.vaultproject.io/">Vault</a> and <a href="https://www.consul.io/">Consul</a>.</p><p>All the services necessary to run a copy of Grofers are then deployed via common Jenkins setup. The services are then exposed via ingress for developers to use with the test suite or use as the endpoint for debug apps for application testing.</p><h3>The Issue</h3><p>We adopted <a href="https://orangematter.solarwinds.com/2017/10/05/monitoring-and-observability-with-use-and-red/">USE-RED</a> dashboards for our services to help us track critical metrics. This allowed us to optimise the infrastructure further for getting maximum performance out of it.</p><p>When we started to analyse such metrics we observed that certain applications took a large amount of time to start and get ready, something that developers did not observe in the local setup. Also, some of our Jenkins jobs took a lot of time to create the environments and get them ready, something that we previously did not account for. This led us to revisit all metrics to identify what could have caused this slow startup in our Kubernetes infrastructure.</p><p>Furthermore, these issues were not being observed in production environments. The production deployments have slightly different manifests, with much more liberal CPU and memory allocation. Also, our production cluster has a lot more headroom for scaling which led us to believe that it is an infrastructure specific issue.</p><h3>Root Cause</h3><p>After debugging for almost a month, we decided to revisit our testing and Kubernetes setup to help isolate the problem. During the optimisation process of our RAV (<strong>R</strong>egression <strong>A</strong>nd <strong>V</strong>erification) testing, we started plotting all Kubernetes metrics that could affect our containers performance. One interesting metric that we identified was CPU throttling (container_cpu_cfs_throttled_seconds_total). Once we plotted that metric, we found shocking and interesting results. Some of our most critical services were getting CPU throttled and we had no idea. Furthermore, we observed that in our CI and dev environments, this was happening a lot with some specific containers at startup time — these were containers where we were running some kind of CPU intensive operation at startup time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UCk2RQ_VUhi_eOxj" /></figure><p>We immediately started planning a cause and effect analysis and came up with the following causes:</p><ol><li>Incorrect CPU limit of containers that causes the application to hit the limits quickly causing Kubernetes to throttle it.</li><li>Background activity like GC that triggers after some time causing CPU cycles to increase. This can also be caused by incorrect heap sizes for JVM based applications.</li><li>Some periodic CPU intensive activity on the node that steals CPU cycles available to cgroups, also hinting towards CPU limits that were not decided to keep periodic spikes in the application logic</li></ol><h3>What is CPU Throttling</h3><p>Almost all container orchestrators rely on the kernel control group (cgroup) mechanisms to manage resource constraints. When hard CPU limits are set in a container orchestrator, the kernel uses <a href="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">Completely Fair Scheduler (CFS)</a> <a href="https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt">Cgroup</a> bandwidth control to enforce those limits. The CFS-Cgroup bandwidth control mechanism manages CPU allocation using two settings: quota and period. When an application has used its allotted CPU quota for a given period, it gets throttled until the next period.</p><p>All CPU metrics for a cgroup are located in /sys/fs/cgroup/cpu,cpuacct/&lt;container&gt;. Quota and period settings are in cpu.cfs_quota and cpu.cfs_period .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZlDl89R87ar10mbqDVJcw.png" /><figcaption>A breakdown of CPU resources in cgroup</figcaption></figure><p>You can also view throttling metrics in cpu.stat. Inside cpu.stat you’ll find:</p><ol><li>nr_periods — number of periods that any thread in the cgroup was runnable</li><li>nr_throttled — number of runnable periods in which the application used its entire quota and was throttled</li><li>throttled_time — sum total amount of time individual threads within the cgroup were throttled.</li></ol><h4>Monitoring Memory Limits for OOM Kills</h4><p>Another interesting metric to consider is the number of container restarts due to OOM. This highlights the containers are that frequently hitting the memory limits specified in their Kubernetes manifests.</p><pre>kube_pod_container_status_terminated_reason{reason=”OOMKilled”})</pre><h3>Resolution</h3><blockquote>So a quick solution to the problem was increasing the limits between 10–25% to ensure that the peaks are hit less often, or avoided altogether.</blockquote><p>After identification of the root cause, we came up with some possible fixes. We took into account the following considerations:</p><p>CPU throttling is primarily because of low CPU limits. Its limits that actually affect the Cgroup behaviour. So a quick solution to the problem was increasing the limits between 10–25% to ensure that the peaks are hit less often, or avoided altogether. This also does not affect the resource requirements for starting pods as requests remain untouched.</p><p>Meanwhile, for certain intensive applications, especially those utilising JVM based systems, we decided to profile the application again for correct CPU and memory requirements as JVM is notorious for high resource consumption. Tweaking JVM parameters will be the right fix in the long term for such applications.</p><h3>What We Learned and Next Steps</h3><p>It was an insightful experience for us. We realised that some of the lesser looked (or in this case overlooked) metrics can have a deep impact on application performance. We also had some amazing insights into the CFS and cgroups, and how the kernel handles resource virtualisation.</p><p>Based on this exercise, we came up with an application profiling plan for our major applications and added CPU throttling to one of our core suspects of poor application performance.</p><h3>References</h3><ul><li><a href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/ch01">Chapter 1. Introduction to Control Groups (Cgroups) Red Hat Enterprise Linux 6 | Red Hat Customer Portal</a></li><li><a href="https://man7.org/linux/man-pages/man7/cgroups.7.html">cgroups(7) - Linux manual page</a></li></ul><p><a href="https://sysdig.com/blog/troubleshoot-kubernetes-oom/">https://sysdig.com/blog/troubleshoot-kubernetes-oom</a></p><p><a href="https://medium.com/omio-engineering/cpu-limits-and-aggressive-throttling-in-kubernetes-c5b20bd8a718">https://medium.com/omio-engineering/cpu-limits-and-aggressive-throttling-in-kubernetes-c5b20bd8a718</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9b433d24b03" width="1" height="1" alt=""><hr><p><a href="https://lambda.blinkit.com/cpu-throttling-in-kubernetes-a-postmortem-b9b433d24b03">CPU Throttling in Kubernetes: A Postmortem</a> was originally published in <a href="https://lambda.blinkit.com/">Lambda by Blinkit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling an XML Ad Server to 1 million requests per second.]]></title>
            <link>https://harsh-prateek-singh.medium.com/scaling-an-xml-ad-server-to-1-million-requests-per-second-ed280fbee97f?source=rss-c7bb81ff732a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed280fbee97f</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Harsh Prateek]]></dc:creator>
            <pubDate>Thu, 30 Apr 2020 14:57:38 GMT</pubDate>
            <atom:updated>2020-04-30T15:09:41.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7jAZmChkotfIMoI3fpbzw.png" /></figure><h3>Scaling an XML Ad Server to 1 million requests per second. And why it needed Rust</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/0*U06CUlqruIFK-TUk" /><figcaption>How the final results look like</figcaption></figure><p>This weekend one of my friends called me fretting over his Azure bill. Almost 6 months ago I hacked together an adserver for him for his particular use case of targeting individuals on his mobile app and digital signages. The hack itself came from a project me and some friends worked for our friends at <a href="https://www.olevea.com/">Olevea</a> in 2018, which ran into some technical hurdles around testing. However we wrote some fantastic software around ad bidding with XML and VAST tags.</p><p>The recent problem however was his Azure bill, standing at close to 22,000 USD. Not much, but at his scale it had a massive dent. While most of the software he used was developed by his team in Russia, the core processing logic was mine as I already had it developed and wanted an open world test.</p><p>Initially I suspected poor application design, but it looked more like a case where python was a poor choice. The system was not designed to scale to this extent and they relied on horizontal scaling to keep pace with the traffic. Plus it had lot of components like Redis, Elasticsearch and MongoDB databases that made cost a big challenge.</p><p>After a three hour long discussion we identified two critical flows in any adserver:</p><ol><li><strong>The request for an ad</strong>. In XML ads, the end user provides a set of parameters like IP, Keyword, Browser and additional data for segregation of traffic (like Subid). These URL parameters are verified in runtime for any blocked user agents, IPs or invalid parameters. Post this, the business logic bids across dozens of additional ad servers linked it the feed, in some cases up to hundreds and generates a XML of top feeds in the system.</li><li><strong>The request for serving the ad</strong> The XML ad is the clicked by an end user entity, which may have received this ad after passing from several other exchanges. When the ad is clicked, the URL contains encrypted data around the original browser and IP that requested the ad. If that data matches, it proceeds to perform a valid browser check ( tests to check if the browser is not rigged or controlled by a bot. Sometimes is as simple as check for Selenium, some times we need to add <a href="https://www.imperva.com/products/advanced-bot-protection-management/">Imperva</a>)</li></ol><h3>These two points were pushing the limits of python as a language, especially as the entire ad XML needs to be served under 1 second</h3><h3>Speeding up the Ad Serving</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/0*Qm_vjBrFG66CGW6R" /><figcaption>The new king of systems programming ?</figcaption></figure><p>Since we were clear to dump Python, we needed a new language capable of heavy hitting. GoLang was a strong candidate, and my friends at <a href="https://chocolateplatform.com/">Chocolate</a> also moved from Python to GoLang over similar issues. However Go has a problem of GC spikes at this kind of performance, and I had a itch for systems programming, I decided to rewrite an API endpoint in Rust.</p><p>I chose the Nickel framework in Rust, as I have heard strong points for its performance, plus unlike Rocket, it does not need a nightly build which is a very strong point for a production system. It took a lot of painful time before I realized that the MongoDB driver was rust has some serious performance issues, and had a switch to the C++ driver. Rust has strong interop, so it was not a painful affair. Once I got my basic queries working, I decided to explore Aerospike as the caching backend instead of Redis, as for an ad server that grew to this scale Aerospike is kind of the industry standard.</p><p>In three days I had the entire system ready with the python business logic converted into a rust binary. The biggest pain point of Rust as of now is slow builds. Builds took half an hour, and release builds can freeze systems (like mine which are ill equipped for such experiments).</p><p>A real world load test can never be beaten, but ab is a good measure of system performance. I decided to run an ab test on both the systems</p><pre>Server Software:        cloudflare<br>Server Hostname:        test-setup14.envgen.com<br>Server Port:            80<br><br>Document Path:          /api/v1/feeds/?count=4&amp;subid=2761&amp;ua=Mozilla%2F5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_14_6%29%20AppleWebKit%2F537.36%20%28KHTML%2C%2<br>0like%20Gecko%29%20Chrome%2F74.0.3729.169%20Safari%2F537.36&amp;keyword=car&amp;feed_id=9is4px9c<br>Document Length:        2658 bytes<br><br>Concurrency Level:      50<br>Time taken for tests:   5.399 seconds<br>Complete requests:      300<br>Failed requests:        0<br>Non-2xx responses:      0<br>Total transferred:      470700 bytes<br>HTML transferred:       398700 bytes<br>Requests per second:    27.78 [#/sec] (mean)<br>Time per request:       1799.687 [ms] (mean)<br>Time per request:       35.994 [ms] (mean, across all concurrent requests)<br>Transfer rate:          85.14 [Kbytes/sec] received<br><br>Connection Times (ms)<br>              min  mean[+/-sd] median   max<br>Connect:        1    2   0.5      2       3<br>Processing:   276 1559 464.5   1734    2041<br>Waiting:      276 1559 464.5   1734    2041<br>Total:        279 1561 464.1   1736    2043</pre><p>And this is how our Rust rewrite performs to the same query</p><pre>Server Software:        Nickel<br>Server Hostname:        localhost<br>Server Port:            6767<br><br>Document Path:          /api/v1/feeds/?count=4&amp;subid=2761&amp;ua=Mozilla%2F5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_14_6%29%20AppleWebKit%2F537.36%20%28KHTML%2C%2<br>0like%20Gecko%29%20Chrome%2F74.0.3729.169%20Safari%2F537.36&amp;keyword=car&amp;feed_id=9is4px9c<br>Document Length:        49 bytes<br><br>Concurrency Level:      100<br>Time taken for tests:   0.100 seconds<br>Complete requests:      1000<br>Failed requests:        0<br>Total transferred:      193000 bytes<br>HTML transferred:       49000 bytes<br>Requests per second:    10011.71 [#/sec] (mean)<br>Time per request:       9.988 [ms] (mean)<br>Time per request:       0.100 [ms] (mean, across all concurrent requests)<br>Transfer rate:          1886.97 [Kbytes/sec] received<br><br>Connection Times (ms)<br>              min  mean[+/-sd] median   max<br>Connect:        2    4   1.0      5       7<br>Processing:     2    5   1.1      6       7<br>Waiting:        0    3   1.5      3       7<br>Total:          6   10   1.5     10      12</pre><p>Load testing an ad server needs a lot of planning, as the system has a lot of features like rate limiting, IP banning and bot restrictions to prevent such behavior. Its also not feasible to load test dev environments, as critical components like caches and frontend proxies need to scale with the system.</p><p>As I write this blog, the developers on this system are planning a locust test to see the stability of this Rust code. They use a internal capacity calculation tool, which calculates the new system to cross 1 Mil QPS, while costs should go down to exponentially as lesser resources are required. The autoscaling also happens faster now, as the docker size is reduced from 689 MB to 10MB</p><p>How big is the Rust binary ? See yourself</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*h81XoMOxg86wwFTKarzYKQ.png" /><figcaption>When Size Matters</figcaption></figure><p>That’s 9 MB holding the business logic that just wracked 22000 USD in someone’s credit card. The only pitfall I see with Rust is build times. The final build took 53 mins 12 seconds to generate the binary in release mode. Plus they lost Sentry support in this migration. Rust and Sentry don’t play well as of now.</p><p>There is a complete different logic to speed up the ad parsing, but it seems I cannot pick that up for some weeks. Writing Rust, just like C++ can exhaust you, and the last thing I want is to write more of it.</p><blockquote>Using the same-size docker-container, we were able to go from 27.78 requests per second per second with Python to 10011.71 requests per second with Rust. That is a 36039.27% increase in throughput.</blockquote><h3>The bottom line is that no matter how quickly your infrastructure layer adopts the most cutting edge technology, unless the application is engineered in a way to leverage it, its all but cloud charges. In the race to adopt latest infrastructure like Kubernetes, do a fact check of your application to see if it can leverage the features offered by the latest infrastructure platform.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed280fbee97f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a HyperLocal App to fight COVID-19 : Part I]]></title>
            <link>https://harsh-prateek-singh.medium.com/building-a-hyperlocal-app-to-fight-covid-19-part-i-8bf7f6b8b8e8?source=rss-c7bb81ff732a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bf7f6b8b8e8</guid>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[e-commerce-solution]]></category>
            <dc:creator><![CDATA[Harsh Prateek]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 12:20:46 GMT</pubDate>
            <atom:updated>2020-04-15T12:20:46.174Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a HyperLocal App to fight COVID-19 : Part I</h3><p>With the COVID19 expanding at a unprecedented rate, a lot of small businesses are affected, especially those that rely on a brick and mortar model for sales. During the quarantine I decided to explore the idea of making a hyperlocal ecommerce app that can help small business with sales during this period.</p><h3>The Tech Stack</h3><p>The goal is to keep a minimal tech stack that reduces the cost of the application, while keeps the spirit of a<em> simple clone</em>. We don’t need to implement features that large providers like Amazon or Grofers need for their operations. I decided to go ahead with Flutter, as it was one of my goals for this year and allows the same codebase to run on iOS and Android, something that is highly desirable. I had heard a lot of praise around Firebase, so decided to give Firebase a shot for this application, especially that fabric is now integrated with firebase.</p><p>For back-end, I will use python. Its simple enough for a app like this as we don’t have scale factor to consider.</p><h3>The Architecture</h3><p>I decided to break all the services into simple components. I came up with the following basic services that I need:</p><ol><li><strong>User</strong>: The basic user model. Should contain details like user’s email, phone and saved addresses.</li><li><strong>Authentication</strong>: The authentication service is going be a child class of Auth that implements Firebase Authentication.</li><li><strong>Cart</strong>: The cart model. At basic level, this is a map of items and quantity, but should support features like tracking payment, finding total price and conversion of a paid cart to an order that should go out for delivery.</li><li><strong>Geo Location</strong>: The geolocation services should allow to find the user’s geo location and identify the nearest store and fetch inventory. It should also provide a place picker for the user to select a custom location.</li><li><strong>Inventory</strong>: This fetches the inventory for a store from the backend, and is responsible to handling the available quantity and stock count of items.</li><li><strong>Push Notifications</strong>: The wrapper around the firebase cloud messaging functionality, allowing to push notifications to end user for events like sales or stock outage.</li><li><strong>Store</strong>: The store model contains the store details like store name, store location, payment IDs for the payment gateway</li><li><strong>Catalog</strong>: This is a WIP. Ideally the catalog should be loaded from every store that should be used to build the feed and manage cart entities. I have not been able to implement it as of now, but its on my road map.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*YUfILs6NfO3UzrVO6WnODQ.jpeg" /><figcaption>How it all stiches together</figcaption></figure><h3>Layout</h3><p><strong>Welcome and Sign Up Page</strong></p><p>I wanted to greet the user with a personalized experience. This again can be customized, but provides the user with basic information around the application. I used the flutter library <a href="https://pub.dev/packages/liquid_swipe"><em>liquid_swipe</em></a><em> </em>to achieve this. However I found liquid swipe to be slow on certain occasions for me, so had to tweak some code to get it working smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*4OeBcd-8lWL-_KbzlUNhNA.gif" /><figcaption>A swipe animation to add spice to the welcome page</figcaption></figure><p><strong>The Home Screen</strong></p><p>I looked at the home screen of some established apps like Grofers, Amazon and BigBasket and decided that following are essential for a great landing page experience:</p><ol><li>Product promotions that catch people as soon as they login</li><li>A product feed that is well organized to find products in 2–3 taps</li><li>All app functions easily accessible</li></ol><p>However the app model that we have has following challenges:</p><ol><li>The feed and discounts vary from store to store</li><li>We need the geolocation before we can show the feed</li></ol><p>To solve this, I used the flutter <a href="https://pub.dev/packages/geolocator"><em>geolocator</em></a><em> </em>library. In the Home Page’s init state, we call the function <em>getLocationInBackground. </em>This guarantees that when the home screen Widget is rendered, the location is already available for all network calls.</p><pre>void getLocationInBackground() {<br>  new Future.delayed(Duration.<em>zero</em>,() async {<br>    var _store = Provider.<em>of</em>&lt;FranchiseStore&gt;(context, listen: false);<br>    Position _position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.<em>high</em>);<br>    print(&quot;&gt;&gt;&gt;Location: &quot;+_position.toString());<br>    _store.getStoreDetails(_postion);<br>  });<br>}</pre><p>We find the current location of the user device, and pass it to the instance of store class to load the nearest store’s payment details and location.</p><p>We also want the user to be able to update his location, so we use the <em>google_map_location_picker</em> to select a geolocation. and get its lat long and address via google maps API. This location is then used to update the current store model, and all necessary widgets rebuild as it refreshes the app state.</p><pre>void showPlacePicker(FranchiseStore store) async {<br>  LocationResult result = await showLocationPicker(context, &quot;&lt;Google Maps API Key&gt;&quot;,hintText: &quot;Enter delivery address&quot;,layersButtonEnabled: true);<br>  store.getStoreDetails(result);<br>}</pre><p>Once we get the store, we simply use a FutureBuilder to parse the json response of inventory and render it into widgets. We fetch all inventory by category which allows to render the inventory by category. This entire operation is cached by the Store model, so we perform this expensive network call just once for every store.</p><p>A very basic cache implementation can be something like</p><pre>class CacheInterceptor {<br>  var _cache = Map&lt;String, String&gt;();<br><br>  get cache =&gt; _cache;<br>  Future&lt;String&gt; getResponseWitchCache(String category) async{<br>    if(_cache[category] == null) {<br>      print(&quot;Fresh network request&quot;);<br>      var response = await http.Client().get(&#39;https://ourawesomeapp.com/category/&#39;+category);<br>      _cache[category] = response.body;<br>      return _cache[category];<br>    } else {<br>      print(&quot;Cache hit&quot;);<br>      return _cache[category];<br>    }<br>  }<br>}</pre><p>The app utilizes a much more complex caching that is backed by Aerospike in the backend which is also used for search and suggestions, but this is a simple cache implementation for people looking for a bare minimum way to cache network calls for a user session.</p><p>This is how the end app looks like with all this functionality baked in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*9bArK70sp5OuBT6e0dREBQ.gif" /><figcaption>Notice that store location is immediately updated on Home Screen Update. Clicking on the location opens the location selector popup that allows to edit the location</figcaption></figure><p>This event is also recorded at Firebase Analytics and the data can be extracted. We can see this event in the User Engagement tab in the <em>MainActivity </em>section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-9ODr9pItwvMFIa4rEcZw.png" /></figure><p><em>This blog is first of the 4 series blog covering the app I am working on to help small businesses fight COVID 19. In the next part I will cover how the cart model is implemented and how we manage cart state across the consumer and delivery app.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bf7f6b8b8e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Started Working With Kubernetes]]></title>
            <link>https://lambda.blinkit.com/how-i-started-working-with-kubernetes-1c60f2eb1886?source=rss-c7bb81ff732a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c60f2eb1886</guid>
            <category><![CDATA[cncf]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Harsh Prateek]]></dc:creator>
            <pubDate>Thu, 07 Nov 2019 12:01:05 GMT</pubDate>
            <atom:updated>2019-11-15T08:39:15.833Z</atom:updated>
            <content:encoded><![CDATA[<h4>And eventually became a contributor.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EbB0orW3kZfPgutl727fTQ.gif" /><figcaption>Animation by <a href="https://medium.com/u/43a6f2601658">Asif Jamal</a></figcaption></figure><p>I first heard about Kubernetes in 2016. When Docker was the new boom, Kubernetes was introduced as a prototype system to manage containers.</p><p>Though I was unsure of getting into it, I passed it at that time as I was content with containers and didn’t need any orchestration.</p><p>However, when I did start working on Kubernetes, I found it pretty exciting. But there were certain aspects of Kubernetes that bothered me. These aspects were buggy and didn’t work as intended.</p><p>Upon diving further, I found that the entire ecosystem was written in Golang. To catch up, I started working on Golang and eventually grew comfortable around the system.</p><blockquote>All in all, it took me around 10 months to get comfortable around Docker and Kubernetes source code.</blockquote><p>The Kubernetes community was also helpful, and I found a lot of help from <a href="https://www.linkedin.com/in/jonathanbasseri/">Jonathan Brasseri</a> and <a href="https://www.linkedin.com/in/aldo-culquicondor-68512348/">Aldo Culquicondor</a> who answered my queries around the Kubernetes scheduler.</p><p>And it’s then that I started contributing code to the scheduler, gradually adding new components, and removing redundant ones.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fbpqxym%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fbpqxym&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252Fbpqxym%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/e005a1ef121a226d6a931c16a6b01e67/href">https://medium.com/media/e005a1ef121a226d6a931c16a6b01e67/href</a></iframe><p>To be fair, it was tough identifying where to start. Since I was most comfortable around scheduler and networking, I started picking topics from there. I identified some redundant components and started removing them.</p><p>I also moved around certain components of the scheduler to make the contract between scheduler and controller more decoupled.</p><p>After a lot of dedicated effort, I have now been invited to join the Kubernetes organization on Github.</p><blockquote>The community has a big role to play. It recognizes your efforts around the contributions you make towards the Kubernetes platform — eventually helping you to move to join sigs and leading them.</blockquote><h3>What’s next?</h3><p>I’m now working towards floating IP issues in Istio and working on some new design components in Calico.</p><p>I have also started to explore eBPF, and I am working to figure out how we can introduce the capabilities of Cilium into Calico.</p><blockquote>A short piece of advice to anyone who’s starting out: <strong>start by studying the test cases.</strong></blockquote><p><strong><em>Next </em></strong><em>→ </em><a href="https://lambda.grofers.com/how-we-sustain-dns-outages-at-grofers-800731e5280c"><em>How We Sustain DNS Outages at Grofers</em></a></p><p><a href="https://lambda.grofers.com/software-engineering-internship-at-grofers-bddd2dd1523e"><em>Software engineering internship at Grofers</em></a><em> ← </em><strong><em>Previous</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXPapXzEJ1bFMU2t5yvUqw.gif" /></figure><h4><a href="https://www.linkedin.com/in/hprateek43/">Harsh Singh</a> is a Software Development Engineer at Grofers and works in our infrastructure team. He loves engaging with the tech community and is a regular speaker at the <a href="https://www.meetup.com/Gurgaon-Kubernetes-Meetup/events/dxnrnqyzpbvb/">Gurgaon Kubernetes meetup</a>.</h4><h4>Interested in solving problems and working with a team that’s passionate to contribute and do great work? Check out the <a href="http://grofers.careers/tech">open roles at Grofers</a> (we are hiring!)</h4><h3>Thanks for reading Lambda.</h3><p>Say hello on <a href="http://www.twitter.com/groferseng">Twitter</a> or follow us on <a href="https://www.linkedin.com/company/grofers/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c60f2eb1886" width="1" height="1" alt=""><hr><p><a href="https://lambda.blinkit.com/how-i-started-working-with-kubernetes-1c60f2eb1886">How I Started Working With Kubernetes</a> was originally published in <a href="https://lambda.blinkit.com/">Lambda by Blinkit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>