<?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 Surabhi on Medium]]></title>
        <description><![CDATA[Stories by Surabhi on Medium]]></description>
        <link>https://medium.com/@alexa.polly007?source=rss-93eb0b4b1a39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eXRl3epRG7tSEg-d-WnhHA.jpeg</url>
            <title>Stories by Surabhi on Medium</title>
            <link>https://medium.com/@alexa.polly007?source=rss-93eb0b4b1a39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:01:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexa.polly007/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[kubernetes Interview Questions — For Developers]]></title>
            <link>https://medium.com/@alexa.polly007/kubernetes-interview-questions-for-developers-cef3f3ee3e73?source=rss-93eb0b4b1a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/cef3f3ee3e73</guid>
            <category><![CDATA[backend-interview]]></category>
            <category><![CDATA[job-interview-questions]]></category>
            <category><![CDATA[kubernetes-interview]]></category>
            <category><![CDATA[interview-questions]]></category>
            <dc:creator><![CDATA[Surabhi]]></dc:creator>
            <pubDate>Sun, 15 Oct 2023 17:34:24 GMT</pubDate>
            <atom:updated>2023-10-15T17:50:09.368Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes Interview Questions — For Developers</h3><p>Now a days , its common for interviewers to ask about docker and Kubernetes in interviews even when you are a backend developer. These questions are mostly asked to test knowledge of developers on deployment and orchestration . Below is list of questions that were asked to me in different interviews.</p><ol><li><strong>What is basic architecture of Kubernetes ?</strong></li></ol><p>Basic Kubernetes architecture consists of two parts — Control plane which usually exists on master node and worker nodes/machines. The control plane components include Kubernetes API server, Kubernetes Scheduler, Kubernetes Controller Manager and etcd. The worker nodes usually have pods(which is an abstraction over containerized application), kubelet service and kubernetes proxy service.</p><p><strong>Control Plane —</strong> It is also known as brain of entire Kubernetes cluster as it has components which co-ordinate and control the compute machines to maintain their desired state and configuration. It is deployed on a master machine , however in order to ensure fault tolerance and high availability, it can be deployed on multiple machines . It has below given components :</p><p>Kubernetes API server : Api Server act as single entry point to the cluster. API server helps in updates, scaling, lifecycle orchestration by providing apis for each of these. It acts a gateway for clients which can authenticate , access and tunnel to pod , services and nodes.</p><p>Kubernetes Scheduler : Kubernetes scheduler stores the resource usage data for each compute node, determines whether a cluster is heathy or not and whether new containers should be deployed , if yes where should those be placed. Then it selects an appropriate compute node and schedules the task, pod, or service, taking resource limitations or guarantees, data locality, the quality of the service requirements, anti-affinity and affinity specifications, and other factors into account.</p><p>Kubernetes Controller Manager : The controller manager sometimes known as cloud controller or simply controller is a daemon which runs the Kubernetes cluster using several controller functions .These controller manage the state of various end points (such as pods and services), token and service accounts(namespaces), nodes and replication. If the desired and current state of the managed objects don’t match , the controller takes the corrective action to drive object status towards the desired state.It also performs core lifecycle functions.</p><p>ETCD : ETCD is an open source , key value store database that stores configuration data and information about state of the cluster. It may be configured externally , but usually it is part of control plane.</p><p><strong>Cluster Nodes Components — </strong>these are some of the important components for rest of the cluster:</p><p>Nodes: These are the compute/worker nodes where pods are usually orchestrated and scheduled to run. Nodes do the actual work for the Kubernetes cluster. They connect applications, networking, compute and storage resources.</p><p>Container Runtimes : Nodes manage the lifecycle of the containerized applications using container runtimes. Kubernetes supports container runtimes like Docker, CRI-O, ContainerD, etc.</p><p>Kubelet Service : Each compute node on Kubernetes cluster has kubelet agent running which communicates with the control plane to ensure containers are running and healthy. Whenever needed, control panel sends the pod specifications through the api server to the kubelet and it performs the action on the node.</p><p>Kube-proxy service : Each compute node contains a kube proxy service that facilitates networking .It either forwards traffic itself or relies on the packet filtering layer of the OS to handle network communication both inside and outside the cluster.</p><p>Pods : A pod represents a single instance of an application and the simplest unit within the Kubernetes object model. Each pod consists of a container or tightly coupled containers in a series that logically go together along with rules that control how containers run.</p><p>2. <strong>How do pods communicate with each other or outside the cluster ?</strong></p><p>There are different ways in which inter pod communication can take place:</p><p>a. Pod IP addresses : Each Pod is assigned a unique IP address within the cluster which can be used to communicate to pod.</p><p>b. Services : Services provide fixed endpoints to pod or set of pods , other pods can use the same to communicate to underlying pods. Services use kubernetes DNS to resolve the IP addresses of the pods.</p><p>c. Kubernetes DNS : Kubernetes provide dns service that allows pods to communicate with each other using domain names.</p><p>d. Network Policies : Kubernetes also provide powerful network policy that restrict and allow access to any pod.</p><p>e. External Access : Pods can communicate with external systems outside the cluster using NodePort, External Name and LoadBalancer type of services.</p><p>3. <strong>What are different types of services in Kuberntetes ?</strong></p><p>Here are the main types of Services in Kubernetes:</p><p>ClusterIP : Exposes the Service on an internal IP within the cluster. This type makes the Service only accessible from within the cluster.Used when we want to expose a Service only within the cluster, for inter-service communication.</p><p>NodePort : Exposes the Service on a specific port on each node in the cluster. This means the Service is accessible on each node’s IP at the NodePort. Useful when we need to expose a Service externally, often for development or testing purposes.</p><p>LoadBalancer : Exposes the Service externally using a cloud provider’s load balancer. The external load balancer routes traffic to the Service, making it accessible from outside the cluster. Suitable for exposing a Service to the internet, often used in production environments.</p><p>ExternalName : Maps the Service to the contents of the externalName field, allowing Services to reference external services by name. Primarily used for integrating with external services or databases.</p><p>4. <strong>How does Kubernetes scale horizontally scale pods ?</strong></p><p>Horizontal scaling means that the response to increased load is to deploy more <a href="https://kubernetes.io/docs/concepts/workloads/pods/">Pods</a>. This is different from <em>vertical</em> scaling, which for Kubernetes would mean assigning more resources (for example: memory or CPU) to the Pods that are already running for the workload. HorizontalPodAutoscaler controls the scale of a Deployment and its ReplicaSet.Kubernetes implements horizontal pod autoscaling as a control loop that runs intermittently (it is not a continuous process). The interval is set by the --horizontal-pod-autoscaler-sync-period parameter to the <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/">kube-controller-manager</a> (and the default interval is 15 seconds).Once during each period, the controller manager queries the resource utilization against the metrics specified in each HorizontalPodAutoscaler definition. The controller manager finds the target resource defined by the scaleTargetRef, then selects the pods based on the target resource&#39;s .spec.selector labels, and obtains the metrics from either the resource metrics API (for per-pod resource metrics), or the custom metrics API (for all other metrics). for details please refer — <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#default-behavior">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#default-behavior</a></p><p>5. <strong>How do you see logs of the container for your application in kubernetes?</strong></p><h4>Default logs</h4><pre>kubectl logs podname -n namespace</pre><p>he above kubectl command shows the logs of the pod in the specified namespace.</p><h4>Specific Container Logs</h4><pre>kubectl logs podname -n namespace -c container_name</pre><p>This kubectl command retrieves the logs of a specific container.</p><h4>All Containers</h4><pre>Kubectl logs podname -n namespace –all-containers=true</pre><p>This lets us see the logs of all the containers present in the pod, which is useful in the case of container restarts.</p><p>6. <strong>Where do you application specific configuration (url, password, user credentials , etc.) saved in kubernetes cluster ?</strong></p><p>Kubernetes provides us with configMap to store general configuration data such as url, environment name, etc, where as secrets can be used to store sensitive values like user credentials in encrypted form.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cef3f3ee3e73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Standing up for the Right]]></title>
            <link>https://medium.com/@alexa.polly007/standing-up-for-the-right-785448553a64?source=rss-93eb0b4b1a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/785448553a64</guid>
            <category><![CDATA[fight-against-corruption]]></category>
            <category><![CDATA[courage]]></category>
            <category><![CDATA[consciousness]]></category>
            <category><![CDATA[courage-to-change]]></category>
            <category><![CDATA[truth]]></category>
            <dc:creator><![CDATA[Surabhi]]></dc:creator>
            <pubDate>Mon, 02 Oct 2023 12:18:12 GMT</pubDate>
            <atom:updated>2023-10-02T12:18:12.518Z</atom:updated>
            <content:encoded><![CDATA[<p>Not all the things are black or white,</p><p>but sometimes,</p><p>you must choose between wrong and right</p><p>without fearing what comes along</p><p>if something has to , it will go wrong</p><p>Fearing some one holding power</p><p>not gonna help , will push you lower</p><p>keeping silent, just to act civil</p><p>Will get you no good , but only evil</p><p>Enough is enough, its almost time</p><p>speaking up is no crime</p><p>And yes you don’t need a great might</p><p>but have courage , stand up for the right</p><p>~~Surabhi</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=785448553a64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software/Solution Architecture /System Design-Part 1- Interview questions]]></title>
            <link>https://medium.com/@alexa.polly007/software-solution-architecture-system-design-part-1-interview-questions-ed75baa05332?source=rss-93eb0b4b1a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed75baa05332</guid>
            <category><![CDATA[high-level-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[solution-architecture]]></category>
            <category><![CDATA[database-design]]></category>
            <dc:creator><![CDATA[Surabhi]]></dc:creator>
            <pubDate>Tue, 26 Sep 2023 08:25:35 GMT</pubDate>
            <atom:updated>2023-09-26T11:27:39.670Z</atom:updated>
            <content:encoded><![CDATA[<h3>System Design Basics - Part 1- Interview questions</h3><ol><li><strong>What do you mean by scalability — please explain different types of scalability?</strong></li></ol><p>The capability of systems to handle increased amount of load or volume while working normally is known as scalability. For example , if there is a news website which handles 10k requests per day/hour in normal circumstances , however if one of the news quoted by this site goes viral and there are as much as 100k requests related to that news per day/hour and if the system doesn’t crash , sustainably handles these requests , it will be called as a scalable system . There are mainly two types scalability :</p><p><strong>Vertical Scalability or Scaling Up</strong>: In this scenario , in order to meet the increased demand , the underlying resources of the system such as CPU, RAM etc. is increased . It is simpler to design as same processes run on the same system , only with increased capacity. However , there is always a limit to vertical scalability due to limit on the sizes of underlying resources.</p><p><strong>Horizontal Scalability or Scaling Out</strong>: In this scenario, more computers or computing instances are added to the underlying infrastructure so that increased demand can be taken care of. Some of the incoming requests can now be directed to these instances. However , some complexity is involved here on the routing and other aspects. But again horizontal scaling gives us liberty to scale to a very large extent.</p><p>2. <strong>What are NFRs(Non Functional Requirements) ?</strong></p><p>Non functional requirements are the requirements which are not directly related with features of the application but are rather expected for proper operation of the system under various circumstances. Some of the NFRs are security, integrity, scalability, robustness, etc. For example — Although it is not a functional requirement , but it is expected for an application to be threat and malware proof under any circumstances.</p><p>3. <strong>What is an API Gateway , what are the advantages that it offers ?</strong></p><p>An API Gateway is an api management software that sits between the client and the backend apis. It acts as the single entry point to the application and takes care of different cross cutting concerns for the underlying services — for example — security, logging, monitoring, request transformation, etc. It simplifies the job of the backend services by taking care of these concerns and letting those services focus on their business logic. It also provides request routing and load balancing . It enables the backend services to serve multiple type of clients(such as desktop, mobile, etc.) without have to bother about their implementation.</p><p>4. <strong>What are different types of databases , also please describe some use cases?</strong></p><p>There are different types of databases like relational , non-relational, file db , network db, etc. Here interviewer usually asks about relational and non- relational DBs .</p><p><strong>Relational Databases</strong> — Relational databases are the databases where data can be represented in the form of tables with rows. These DBs have fixed schema and usually enforce different constraints to ensure data consistency. Relational databases follow <strong>ACID</strong> properties. Examples — Sql databases such as MySql, Oracle, Postgres, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*xmiC54jrDdfjDKBWKDiXWA.png" /><figcaption>Advantages and Disadvantages of RDBMS</figcaption></figure><p><strong>Non Relational Databases</strong> — These type of databases don’t have fixed schema. Usually, non relational databases don’t follow ACID properties. There are different categories of non relational or no sql databases which are used for different purposes. Few important types of non relational databases are :</p><p><strong>Key Value Stores</strong> — In these type of DBs , values are usually stored in key value pairs, even requests, responses could be saved as key value pairs.These dbs provide very fast retrieval and can scale horizontally very easily. Example — Dynamo DB, Redis(Cache) , etc.</p><p><strong>Document Based DB</strong> — In these type of DBs, we store data in the form of collections of documents where document has actual data. Documents usually don’t have fixed schema and can accommodate data varying in structure. These DB are used for ready/write heavy operations — very useful as an alternative to relational DB when a query fetches data from too many tables. Example — MongoDB</p><p><strong>Columnar DB</strong> — Data in these DBs are structured in the form of fixed columns which are decided on the basis of read query , but these DBs don’t follow ACID properties. Some example of such data can be — signals coming from a particular device varying with respect to time, views of a particular video or songs, etc. These DBs support heavy write but selective reads. These dbs support distributed databases. Some examples of columnar DBs — Cassandra, Hbase, etc.</p><p>Search DBs — In these type of databases,data against queries are saved in advanced indexes . Usually , these databases are not the primary databases for the application. The result of frequently searched queries are stored in searched DB where as actual data is stored in some other sql/no sql Dbs. Some examples are — ElasticSearch, etc.</p><p>There are many more types of databases and corresponding use cases , but I have described a few, many a times, till this point interviewer will explicitly try to seek some more details about one of these types he/she is interested in.</p><p>5. <strong>What is caching ?What are different caching techniques and when are those used ?</strong></p><p>Caching can be done at different layers to improve the user experience, quicker fetching of data, saving some network bandwidth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*e_EOyGIe8-babSEiIV1TnQ.png" /></figure><p>We can start answering this question by specifically asking the interviewer whether he/she wants to ask about client side or server side caching.</p><p><strong>Client Side Caching</strong> — It is usually achieved through the http headers on the browser side . In these scenarios , browser maintains a cache at its end which is validated/invalidated as per information conveyed in the response headers sent by the server.</p><p>Caching Headers : expires, pragma,(before http 1.1) cache-control</p><p>Expires: The value of the expires header shows the absolute expiry date for the response till which the response can be cached. It can’t be more than an year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*iTXb_x1EeISGYWAdN-iWLA.png" /></figure><p>Pragma: The possible value of this header can be be no-cache. It is one of the headers that was used pre HTTP/1.1 and it was used to prevent caching.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*ZDf3gMqMMegRqYV0qGJaaA.png" /></figure><p>Cache-Control: It is multi value header, it was introduced in HTTP/1.1 to determine the caching behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*yKG2jtyVIkzuhzmq8CkszA.png" /></figure><p>It means cache is private to the user and it will only be cached in browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*8YoDOpihlcExMKdZU8AZ1g.png" /></figure><p>It means cache can be used by multiple users and can be cached at proxies too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*1J_PjHrTPKWXs9vqQOGldQ.png" /></figure><p>It means content can’t be cached at the client side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*B2fwH1-10iSaxt6_ZmjIaQ.png" /></figure><p>It means content can be cached at the client, but to reuse it , it must validate it from the server which can be done using Etag headers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*F7Mco2cxBfuYZMyo4d5_EA.png" /></figure><p>It means content can be cached for given number of seconds at the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*I973rpru6woIsBg1qMy2Dw.png" /></figure><p>Same as max age but it denotes the number of seconds for which content can be cached at the proxies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*GCq0NZOvuSMWczQ3tx80Nw.png" /></figure><p>The control ‘must-revalidate’ is used to enforce the client to revalidate the cached value from the server before serving it . It is highly useful in the cases where due to some reasons if backing server is down, client tends to serve the stale cached content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*INd_DWZhs2jcEmfkZbz78g.png" /></figure><p>Same as above, only applicable to proxies.</p><p><strong>Client Cache Validation</strong> — While serving a content, the server usually sends an Etag(Entity Tag) which uniquely identifies a resource, client later makes a request using this Etag to check if the content has been changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*XJcLm9ZGqjfkF6T03vdGGg.png" /></figure><p>If the resource is changed at the server, the server sends the new resource with new Etag in response, where as in case if the resource is not changed it sends 304 as response code — Not Modified.<strong> Last-Modified</strong> is another tag which is used for validation/invalidation of cache.</p><p><strong>Caching Strategy</strong> — It differs from use case to use case. However it can be majorly categorized into groups :</p><p>Light Caching — for the contents where client is needed to validate ex- html</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*RqE-GS-v84rRg79131zBXQ.png" /></figure><p>Here , we make sure that although the client can cache the content but it must validate with server before serving it.</p><p>Aggressive Caching — for resources such as javascripts, css, images , we can cache it for longer period of time and then use fingerprints for each updated versions of these files in the builds so that when html files are validated , if it detects any updated resource file it downloads from the server link rather than using it from local cache.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*Jcyzv8mFoFZqJndncbt4RA.png" /></figure><p>Now , coming to the server side cache part, I have written a detailed article for the same that can referred for the same</p><p>Sever side Caching : -<a href="https://medium.com/@alexa.polly007/understanding-caching-eviction-invalidation-patterns-and-their-use-cases-9fbfd34be970">https://medium.com/@alexa.polly007/understanding-caching-eviction-invalidation-patterns-and-their-use-cases-9fbfd34be970</a></p><p>I don’t want this article to go too long , so I am saving some questions for the next part, hope you enjoyed reading it so far .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed75baa05332" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Caching- Eviction, Invalidation , Patterns and their Use Cases]]></title>
            <link>https://medium.com/@alexa.polly007/understanding-caching-eviction-invalidation-patterns-and-their-use-cases-9fbfd34be970?source=rss-93eb0b4b1a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fbfd34be970</guid>
            <category><![CDATA[cache-eviction-policies]]></category>
            <category><![CDATA[caching-strategies]]></category>
            <category><![CDATA[invalidation]]></category>
            <category><![CDATA[caching]]></category>
            <dc:creator><![CDATA[Surabhi]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 04:44:06 GMT</pubDate>
            <atom:updated>2023-09-21T05:35:55.997Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Caching- Eviction, Invalidation , Patterns and their Use Cases</h3><p><strong>What is cache ?</strong></p><p>In simple words, a hardware or software component that helps in serving the data ,which is either frequently requested or which is computationally expensive to retrieve is called cache . Cache stores such data and helps to render whenever requested. Usually , this data is stored in the form of key -value pair, where key identifies the item uniquely in the cache .</p><p>Caching is done in many common scenarios to speed up the process of retrieval , optimize performance and enhance user experience. Most of the systems/applications maintain some sort of cache.</p><p><strong>In Absence of Cache</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*xUZros95tr7jtQPo0oajAQ.png" /></figure><p>A client(e.g a browser) sends a request to the server for fetching some data ,server in turn fetches the data from backing database/datastore. Now , suppose user again sends same request(for same data), entire flow is repeated — including computation/network heavy database read. So, in order to optimize this process , <strong>we put a cache in between </strong>, <strong>cache is something which is closer to the application/server than the database</strong>. Cache can be part of application/server, in memory store or anything which has lower network cost than it takes to access the database.</p><p><strong>After putting cache in between</strong></p><p>The second or the subsequent requests for the same data doesn’t go to database, but it is fetched from local cache/low latency cache and returned back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*3KsfO2v--mEhAtrGA8iNBQ.png" /></figure><p><strong>Cache hit and Cache miss</strong></p><p>If a request is sent to the application and the data is present in the cache, the application reads the data from the cache and returns , it is known as <strong>cache hit</strong>.</p><p>However if the data is not present in the cache, the application has to fetch the data from the database. This situation is called as <strong>cache miss</strong>.</p><p>The above diagram shows a very basic set up for the caching, we will go into the more advanced patterns in details further in the article.</p><p><strong>Eviction and Invalidation — Volatile nature of cache</strong></p><p>Cache Invalidation — Once a value is loaded into a cache corresponding to some key, its quite possible that after some time , someone/some process would have updated its value in the database, so it needs to be updated or invalidated from the cache too.</p><p>How do we invalidate cache ? One way is to keep an expiry time for cache items known as TTL or time to live . How do we determine appropriate ttl ? This is not deterministic , it varies from case to case and to determine an approximate ttl , we should consider the tradeoff between the cache performance and stale data that can be accepted by the system. Cache would not make sense if it needs to be refreshed too frequently.</p><p>Cache invalidation can also be done by using application code whenever some data is created or updated in DB, but it again varies from case to case . Hybrid approach for cache eviction is also possible where we use a combination of both approaches.</p><p>Cache Eviction — Caching enhances efficiency of read heavy operations but it comes with a cost . We can cache only limited number of keys in cache at one point of time. So, whenever we have a new key that needs to be added to the cache , if it has reached its limit , there must be some other key that should be evicted from the cache.</p><p><strong>Few strategies for cache eviction :</strong></p><p><strong>First In First Out</strong> : The key which has come first in the cache leaves the cache first</p><p><strong>Least Recently Used</strong>: The key which has not be used in longest time , leaves cache.</p><p><strong>Least Frequently Used </strong>: The key which has the lowest frequency of usage goes out.</p><p>In addition to above mentioned strategies which of course varies from case to case , it is also possible to maintain our own eviction policy(based on some customized algorithm which can combine any of these or implement custom rules to suit the usecase). For example there could be caching eviction policy which only keeps the most frequently used ,that too in recent past — similar to any viral post or any hot products on sale.</p><p><strong>Cache Patterns/Strategies</strong></p><p>These are the some generic strategies in which the cache are used in real world application:</p><ol><li><strong>Cache Aside Pattern</strong> : This is the cache placement pattern when cache does not interact with database directly.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*hzIePD3iFH5cQ3OeT-rFsA.png" /></figure><p>This pattern supports heavy reads. The application works even if the cache goes down for some reason(it fetches directly from DB though).However to maintain a synchronization between the DB values and cache values , some mechanism like ttl/application logic has to be in place.</p><p>2. <strong>Cache Read Through Pattern and Cache Write Through Pattern </strong>: Usually these two patterns are used together in the systems. In these patterns , the cache is placed in between the application and the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*fE1kR5ascRKMvD_PRjz11g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*EYrtyNbVBvHgCJZY9brJsg.png" /></figure><p>These pattern together can be great option for read heavy workloads , ex- reels, newsfee, etc.However , one thing that needs to be kept in mind here that data model for both cache and databse should be similar. Usually third party libraries/systems are used as cache in such scenarios. Another disadvantage here is failure of caching layer can bring entire system down .Also , it adds some latency while writing to the DB as there is cache in between. So, in order to overcome this issue there is a similar pattern with some deviation that we will go through in the next section.</p><p>3.<strong> Cache Write Around Pattern</strong> — In this pattern , all the set up remains same as above , only the write is done directly to the database. It helps minimizing the write latency as mentioned in the above case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*qtOVIRdLzajtQUDpQoPacg.png" /></figure><p>4. Cache Write Back Pattern — This pattern is suitable for write heavy patterns , where a quick response is needed at client side. So, all the writes are written quickly in the cache and response is rendered back to the client. Later , all these write data are batched and written back to the database. This pattern is write efficient approach, but again failure of cache leads to loss of all the write data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*5td0mWSiM3Xkp-DIPrBddw.png" /></figure><p><strong>Which Caching Pattern is the best one?</strong></p><p>The answer to this question is none. The applicability of these patterns varies from case to case. We should also give some thought around — Which is more important ?cache sufficing in case if DB is down or system failure in case if cache is down, can the system have similar models for database or cache or different models for these modules? These are just few points, there are many more that should be discussed while choosing and designing cache for the application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fbfd34be970" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Interview Questions]]></title>
            <link>https://medium.com/@alexa.polly007/microservices-interview-questions-e3aa677c326b?source=rss-93eb0b4b1a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3aa677c326b</guid>
            <category><![CDATA[distributed-transaction]]></category>
            <category><![CDATA[choreography]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[saga]]></category>
            <dc:creator><![CDATA[Surabhi]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 08:33:18 GMT</pubDate>
            <atom:updated>2023-09-20T08:33:18.918Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>How do you handle distributed transactions in in your architecture- Microservices or Service based architecture?</strong></li></ol><p>Ans — Distributed transactions are the transactions that can span across multiple services. These type of transactions might introduce complexity and tight coupling amongst the services. One way is to avoid these transactions and keep those as set of local transactions for each service. SAGA pattern can be used here to handle it cleanly — There are two ways to use it -Choreography-based saga, Orchestration-based saga.</p><p><strong>Choreography</strong> — Post local transaction(which is actually some DB transaction with a flag to denote it is still to be fully committed, first participating service publishes an event to next service in the workflow which again executes a local transaction — post transaction, the second service either returns a success or error code based on failure of some business rules, based on the returned event , the first service either change the initial local transaction as final approved transaction or deletes(invalidates) initial transaction. There can be multiple services in a business flow. It gives a scope of enhanced scalability but at the expense of simplicity(which makes this implementation complex). It requires some additional resources such as Message broker etc.</p><p><strong>Orchestration</strong> — Instead of local transactions interacting with each other directly with events , in case of orchestration , there is an Orchestrator object which co-ordinates between these local transactions and it is responsible for compensating/reversing all the previous local transactions if one of the transactions fail. It somewhere has somewhere tight coupling wrapped within implementation along with single point of failure. It doesn’t need other additional resources .</p><p>For details , below link can be visited :</p><p><a href="https://microservices.io/patterns/data/saga.html">Microservices Pattern: Pattern: Saga</a></p><p>2. <strong>What is the difference between Choreography and Orchestration , what would be use cases for each of the patterns ?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*uCscrVO4HLQv_0eyAXMoOw.png" /></figure><p>3. <strong>What is Command Query Response Segregation Pattern in Microservices and when do we use it?</strong></p><p>After adopting Microservices architecture ,having applied database per service, when we try to get join data from multiple services, it becomes very complicated . There could be multiple options to service such requests. One of this is Command Query Response Segregation Pattern where we create a new view database , which is a read-only replica that is designed to support that query. This database is updated on the domain events published by the individual services. For details, please refer :</p><p><a href="https://microservices.io/patterns/data/cqrs.html">Microservices Pattern: Pattern: Command Query Responsibility Segregation (CQRS)</a></p><p>4. <strong>When do you think , an organization/team should go for Microservices Architecture ?</strong></p><p>Moving to Microservices either for a new product/project or revamping an existing application is not an easy decision. Different parameters should be considered in terms of Organization , Processes and Mindset while deciding for the architecture:</p><ol><li>Is the Organization ready to take a leap , are there presence or possibility of forming cross functional small teams that can own and deliver a microservice?</li><li>Are the processes agile enough to accommodate the quick and continuous integration, deployment and delivery of these independent services.</li><li>What is extent of dev-ops paradigm automated?</li><li>Do we really need Microservices for the target application that we are talking about, is it really worth all the pain. Not same coat fits all.</li></ol><p>Overall, before moving into Microservices , a team should weigh properly all the pros and cons ,their own readiness and organizational support.</p><p>5. <strong>What is the difference between cohesion and coupling ?</strong></p><p>Cohesion refers to association and relationship within a module, highly cohesive means the component of module are tightly couple , changing one needs a change in other . This can be considered as one the factors while designing microservices. Something which changes together should be packaged together.</p><p>Coupling refers to association and relationship of one module with another. Usually a loosely coupled relationship is preferred for separate module so that those could change independently without impacting other.</p><p>6. <strong>What are different tools which help in developing and maintaining Microservices ?</strong></p><p>Below are some of the tools/technologies that I can think of for developing/maintaining Microservices:</p><ol><li>Technologies for developing Services — REST APIs, GRAPH QL, Java, Python, NoseJs , SpringBoot, Databases etc.</li><li>Some Message Broker Systems — Kafka , Rabbit MQ, SQS, etc.</li><li>Containerization Technologies — Docker, ContainerD , etc.</li><li>Container Orchestration Technologies — Kubernetes , ECS, EKS, DockerSwarm , etc.</li><li>Some Automation and CI/CD Technologies — Github/GitLab , Jenkins, etc.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3aa677c326b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>