<?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 Jeyabalaji Subramanian on Medium]]></title>
        <description><![CDATA[Stories by Jeyabalaji Subramanian on Medium]]></description>
        <link>https://medium.com/@jeyabalajis?source=rss-81a85a449dff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CScVZTPXbOSjgIQDcRyZKg.png</url>
            <title>Stories by Jeyabalaji Subramanian on Medium</title>
            <link>https://medium.com/@jeyabalajis?source=rss-81a85a449dff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 07:20:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jeyabalajis/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[Building Cloud Platforms as a Service — Key Pillars of Success]]></title>
            <link>https://medium.com/@jeyabalajis/building-cloud-platforms-as-a-service-key-pillars-of-success-901e53485bb1?source=rss-81a85a449dff------2</link>
            <guid isPermaLink="false">https://medium.com/p/901e53485bb1</guid>
            <category><![CDATA[platform-thinking]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <dc:creator><![CDATA[Jeyabalaji Subramanian]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 13:34:29 GMT</pubDate>
            <atom:updated>2022-12-16T03:39:23.558Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j2Bl6U0F_PmJpbOp" /><figcaption>Photo by <a href="https://unsplash.com/@mayertawfik?utm_source=medium&amp;utm_medium=referral">Mayer Tawfik</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Context</h3><p>For mature enterprises, planning, building, and managing foundational cloud technology platforms accelerate value for their internal clients. Once these enterprises reach a certain size and level of dependency on technology, establishing these foundational platforms help eliminate complexities, boost effectiveness of it’s use base, and also help adhere to compliance standards across the enterprise.</p><blockquote>Building these foundational platforms as a SaaS (Software as a Service) enables organizations to maximize their client experience and Return on Investment (ROI).</blockquote><p>Here is an example <a href="https://d1.awsstatic.com/saas/SaaS_Journey_Framework_1min_wp_Mar_2021.pdf"><em>SaaS Journey Framework</em></a><em> </em>that breaks down the path to SaaS into four distinct phases (Business Planning, Product Strategy, Minimum Viable Service, and Launch/Go-To-Market), each of which represents a key stage in the move to SaaS.</p><p>At a broad-level, SaaS Journey Framework allows you to accomplish the following:</p><ul><li>Articulate the compelling factors for brining up a Platform as a Service, Target market within the organization, and the potential customer segments</li><li>Have a strategy that articulates a clear set of capabilities / offerings that target specific personas within the consumer base.</li><li>Identify critical capabilities for your Minimum Viable Service (MVS), and set clear definition and expectations of the launch, timelines, target customers, and how you will engage potential customers to capture feedback.</li><li>Before you launch, establish a Customer Advisory Board (CAB) to ingest voice-of-customer feedback and prioritize an appropriate sense of urgency; create measurable product adoption expectations.</li></ul><p>In the rest of the sections, we will get into each key pillar of success, as you build out your Cloud Platform as a Service. These key pillars of success can both be treated as a set of design principles, and also as recipes for success.</p><h4>Table of Contents / TLDR:</h4><ul><li><a href="https://medium.com/@jeyabalajis/building-a-cloud-platform-as-a-service-key-pillars-of-success-901e53485bb1#e3d7">Multi-Tenant Experience</a></li><li><a href="https://medium.com/@jeyabalajis/building-a-cloud-platform-as-a-service-key-pillars-of-success-901e53485bb1#dff2">Strong On-boarding and Identity Foundation</a></li><li><a href="https://medium.com/@jeyabalajis/building-a-cloud-platform-as-a-service-key-pillars-of-success-901e53485bb1#3f4c">Superior Self-Service</a></li><li><a href="https://medium.com/@jeyabalajis/building-a-cloud-platform-as-a-service-key-pillars-of-success-901e53485bb1#a28c">Security by Default</a></li></ul><h3>Multi-Tenant Experience:</h3><p>When you design your Cloud Platform for housing multiple tenants, you may want to take advantage of the economies of scale that come with <em>sharing infrastructure resources across tenants</em>. Simultaneously, the tenants require <em>some of the resources to be dedicated for them.</em></p><p>There are different SaaS models such as Silo, Pool, and Hybrid that provide different levels of multi-tenant experience and workloads isolation.</p><ul><li><strong>Silo:</strong> The silo model refers to an architecture where tenants are provided dedicated resources. For example, each tenant of your cloud platform may have their own aws account, that’s vended from a master <a href="https://docs.aws.amazon.com/controltower/latest/userguide/organizations.html">aws organizations</a> account.</li><li><strong>Pool:</strong> The pool model refers to an architecture where tenants share resources. These resources typically belong to base infrastructure. For example, networking services in aws such as <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html">NAT Gateway</a> or <a href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-your-vpc.html#vpc-subnet-basics">VPCs</a> could be shared across all your tenants.</li><li><strong>Hybrid: </strong>The hybrid model refers to an architecture where some resources of your platform are implemented in Silo model and some in Pool model. <em>This pattern acknowledges the reality that you cannot exclusively design for Silo or Pool.</em></li></ul><blockquote><em>In scenarios where you must comply with strict workload isolation for teams, choose Silo model. In scenarios where you would benefit from economies of scale (for example, a common set of VPCs, subnets, and NAT Gateway for a set of customers), choose Pool model.</em></blockquote><p>Immaterial of which model you choose, each environment managed by your platform still relies on a shared identity, onboarding, and operational experience where all tenants are managed and deployed via a shared construct. This is where a <em>Control Plane based operation</em> comes in to help.</p><h4>Control Plane:</h4><p>Control Plane is a management and operations layer that houses central SDKs and CI/CD Pipelines and operates across multiple accounts.</p><p>It is a critical part of your multi-tenant strategy that ensures that all your Infrastructure as Code pipelines (including On-boarding pipelines) are unified, and managed through a central account (Single Pane of Glass).</p><p>With Control Plane, you can</p><ul><li>Launch Base Infrastructure Resources across multiple hosts (aka accounts) through configuration.</li><li>On-board teams across all your platform-as-service offerings, through a single, automated, repeated process.</li><li>Manage platform admin CI/CD Pipelines as products, thus achieving standardization across all admin pipelines.</li><li>Build standard Admin Deployers that enable you to provide CI/CD Pipeline as Services.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hq9eNzcLtas50hMORxMK-w.png" /><figcaption>Components of a Control Plane that enables admins to perform unified management across accounts, and eat their own dog food.</figcaption></figure><h4>Tenant Workloads Isolation:</h4><p>When you build and operate a multi-tenant platform as a service, you must ensure that <em>each tenant is prevented from accessing another tenant’s resources</em>.</p><p>The following strategies help in enforcing workloads isolation:</p><ul><li><strong>Attribute Based Access Control (ABAC):</strong> <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html">ABAC</a> is an authorization strategy that defines permissions based on attributes. For example, you can enforce a policy that allows permissions to a user only when user’s <em>team name tag</em> matches resource’s <em>team name tag.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nwYBTTaOt_o0yOL6yZQcHg.png" /><figcaption>Attribute Based Access Control (ABAC)</figcaption></figure><ul><li><strong>Name Based Access Control (NBAC): </strong>All resources in your cloud provider may not support ABAC. In such scenarios, NBAC strategy additionally helps you to enforce permissions to a team based on resource naming convention. For example, you can enforce a policy that allows permissions to a user only when the resource starts with the <em>team name</em> to which a user belongs to. Use this as a complementary strategy on &amp; above ABAC.</li></ul><blockquote>In AWS, <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html">IAM Policy Conditions</a> element and <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_resource.html">IAM Policy Resource</a> element are excellent ways to enforce both ABAC and NBAC.</blockquote><blockquote>Beyond tenant workloads isolation, ABAC (using Tags) also allows you to measure the cost impact of individual tenants.</blockquote><blockquote>Designing multi-tenant experience for your platform as a service requires deliberate planning. The above patterns and techniques (Silo/Pool/Hybrid, Control Plane and Authorization strategies) should help you in coming up with a robust design.</blockquote><h3>Strong On-boarding and Identity Foundation:</h3><p>There are a number of channels (sign up page / GitHub Pull Request etc.) through which you may want to on-board tenants for your platform. Most often, tenant onboarding is initiated directly by tenants, but this could be a provider managed process too.</p><p>Immaterial of the channel,<em> </em>this step often requires the orchestration of a number of components to successfully provision and configure all the elements needed to create a new tenant.</p><p>For example, let’s take a scenario where we have decided our authentication strategy as <em>IAM with MFA.</em></p><p>When a Team (composed of a set of users) is on-boarded, the platform may perform the following steps:</p><ol><li>Create <em>IAM User</em> for each user within a team &amp; attach tag <em>team name </em>to the user with appropriate value.</li><li>Attach IAM User to one or many <em>IAM Groups</em>, depending upon the <em>persona</em> attached to the user in the request.</li><li>Create <em>Team Execution Roles</em> with appropriate permissions that underlying cloud services will use for execution. For example, the platform may create separate Team Execution Roles for SageMaker &amp; Glue.</li><li>Create <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html">AWS SNS Topic</a> for a Team as well as for each user. These topics can then used for sending notifications to the team or a user.</li><li>Attach <em>common policies </em>that govern platform usage across all users. For example, <a href="https://aws.amazon.com/premiumsupport/knowledge-center/mfa-iam-user-aws-cli/">mandate MFA</a> before any service is access through Console or CLI.</li></ol><blockquote>By pre-packaging all preventive permissions and team-specific resources (like execution roles) during on-boarding, you can deliver a secure, governed yet easy-to-use and repeatable on-boarding process that just works.</blockquote><h3>Superior Self-Service:</h3><p>Self Service is a key pillar that unlocks <strong><em>accelerated delivery</em></strong> by empowering consumers to launch cloud resources and pipelines with little or no intervention from administrators.</p><p>Enabling Self-Service on Cloud Platforms is hard since you need to simultaneously satisfy two goals which are seemingly contradictory:</p><ul><li>On the one hand, you need to provide flexibility to end users.</li><li>On the other hand, you require your cloud resources to be secure and compliant.</li></ul><p>AWS offers a couple of interesting models for self-service that you can embrace.</p><h4>CI/CD Pipelines as a Service:</h4><p>CI/CD Pipelines as a Service offers a toolchain standard to be re-used by application teams. In this model, end-user teams launch a governed deployment pipeline from <a href="https://aws.amazon.com/servicecatalog/">AWS Service Catalog</a>. The workflow for this model is as follows:</p><ul><li>Cloud platform engineers develop a <a href="https://aws.amazon.com/servicecatalog/features/">service catalog product</a>.</li><li>A product comprises of one or more AWS resources, and is created by designing AWS CloudFormation templates that combines resources, their relationships, and the parameters that the end user can plug in when they launch the product.</li><li>For example, a CI/CD Pipeline Service product may create a AWS CodePipeline project that connects with a GitHub Repository branch (plugged in by end-users) for <em>source stage, </em>followed by a <em>deploy stage, </em>which invokes a Lambda Deployer Function that performs the required deployment.</li><li>The input to Lambda Deployer function comes from a <a href="https://martinfowler.com/books/dsl.html">DSL </a>configuration file, which is supplied by end-users.</li><li>The launch of a product just creates a fully functional CI/CD Pipeline.</li><li>Now, whenever end-users push the DSL configuration file &amp; any other associated required files into the GitHub Repository branch, the CI/CD Pipeline kicks-off and the Lambda Deployer function performs the deployment &amp; also notifies the end-user through Team SNS Topic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*9JMy8eTjrEbCkQc1dLNQ3Q.png" /><figcaption>CI/CD Pipeline as a Service Model</figcaption></figure><p><strong>Key Benefits:</strong></p><ul><li><strong>Standard deployers, but flexible configuration: </strong>End-users are provided with flexibility to specify configurations &amp; details pertaining to the deployment (flexible), but admin takes care of the actual deployment to cloud (standardization and compliance)</li><li><a href="https://www.gitops.tech/"><strong>GitOps</strong></a><strong> &amp; DSL driven: </strong>Every deployment of a resource by the consumer team is forcefully driven through <a href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges">GitHub repository PR-Merge process</a>. Further, this follows a full-fledged <a href="https://www.gitops.tech/">GitOps</a> way of implementing Continuous Delivery for cloud-native applications.</li><li><strong>Eliminates individual personnel dependency</strong></li></ul><blockquote>GitOps: versioned CI/CD on top of declarative infrastructure. Stop scripting and start shipping. — <a href="https://twitter.com/kelseyhightower/status/953638870888849408">Kelsey Hightower</a></blockquote><h4>Centrally Managed Products:</h4><p>This model allows end-user/consumer teams to provision resources managed by a central operations team <em>as self-service</em>.</p><p>In this model, Cloud platform engineers publish infrastructure portfolios to AWS Service Catalog with pre-approved configuration. This locks down how infrastructure is configured and provisioned.</p><p>For example, consider offering <em>S3 Bucket as a Service.</em> In this case, the workflow would be as follows:</p><ul><li>Cloud platform engineers design and create a CloudFormation template, with appropriate end user parameters such as <em>team name, bucket name etc.</em></li><li>They pack in all required security and compliance requirements (No Public ACLs, enforce in-transit and at-rest encryption etc.)</li><li>They add required tests and DevSecOps validations.</li><li>They rollout this as a Service Catalog Product.</li><li><em>When end users launch this product, they receive a fully secure and compliant resource that is locked down to their team.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*Bwaxc1ylEs6eRhHyTirmVw.png" /><figcaption>Centrally Managed Product Model</figcaption></figure><p><strong>Key Benefits:</strong></p><ul><li><strong>Principle of least Privilege: </strong>End users are NOT provided elevated benefits. They must use Service Catalog products to launch resources.</li><li><strong>Standardization &amp; Compliance: </strong>All resources created through Service Catalog exhibit <em>the same behavior, </em>thus accomplishing standardization and compliance.</li></ul><blockquote>With <em>Centrally Managed Products &amp; CI/CD Pipelines as a Service </em>models, platform admins can provide superior self-service to end-users while adhering to the highest levels of security, standardization, and compliance.</blockquote><h3>Security by Default:</h3><p>Security is a key pillar that provides multi-fold benefits, especially when you are launching a platform as a service. Building all capabilities and services with <em>Security by default</em> principle ensures that hundreds of teams in your organization use these products, <a href="https://docs.aws.amazon.com/whitepapers/latest/aws-overview/security-and-compliance.html"><em>without worrying about managing security in the cloud</em></a>.</p><p>Below are a few strategies to ensure that platform offerings are secure by default:</p><ul><li>A strong Identity Foundation that is either built with MFA (or) Single Sign-on, and a Teams construct that ensures that workloads are appropriately tagged and authorized.</li><li>A preventive permissions model that protects cloud resources across all channels (console, CLI, programmatic access) and also enforces <em>team permissions</em>.</li><li>A carefully designed Tenant Workloads isolation through Attribute Based Access Control (ABAC) and Name Based Access Control (NBAC) that ensures teams can access only what is theirs.</li><li>A Control Plane architecture that ensures that all products and pipelines are launched into accounts from a central account (single pane of glass).</li><li>A carefully enforced data encryption standards (transport layer &amp; at-rest) while launching products through <em>Centrally Managed Products &amp; CI/CD Pipelines as a Service </em>models, through appropriate configuration.</li><li>Built-in DevSecOps controls through standard libraries like <a href="https://bridgecrew.io/infrastructure-as-code-security/">Checkov,</a><em> </em>which are codified at the source, and automated for efficiency.</li><li>Integrated container security during Continuous Integration with tools like <a href="https://sysdig.com/">sysdig</a>.</li><li>A hardened security posture for externally exposed services with appropriate controls such as CloudFront, Web Application Firewall (WAF), API Keys and Usage Plans.</li><li>Enforce standard tags across all resources launched (including admin resources) for attribution, security, and FinOps.</li></ul><blockquote>By establishing preventive guardrails, including DevSecOps in all builds, protecting data privacy in the capabilities offered, and isolating team workloads, you can deliver an exceptional security by default that works for teams at scale.</blockquote><h3>Conclusion:</h3><p>Cloud Platforms as a Service provide agility and innovation to mature organizations.</p><p>By treating them as full-fledged SaaS services with the help of SaaS journey framework, and also coming up with a solid architecture with the help of above mentioned pillars, organizations can unlock exceptional service experience, and also increased agility.</p><blockquote>“Platforms and platform thinking aren’t cure-all solutions. They’re conduits and catalysts for your strategic goals. To harness their full potential and realize their full value, they must be designed and built with your unique goals in mind.” — Rachel Laycock, Global Managing Director, Enterprise Modernization, Platforms and Cloud</blockquote><h3>References:</h3><ul><li><a href="https://www.thoughtworks.com/insights/looking-glass/lens-three-realizing-the-potential-of-platforms">Realizing the potential of platforms</a></li><li><a href="https://d1.awsstatic.com/saas/SaaS_Journey_Framework_1min_wp_Mar_2021.pdf">SaaS Journey Framework — One Minute White Paper</a></li><li><a href="https://d1.awsstatic.com/whitepapers/saas-journey-framework.pdf">SaaS Journey Framework</a></li><li><a href="https://aws.amazon.com/blogs/architecture/accelerate-deployments-on-aws-with-effective-governance/">Accelerate Deployments on AWS with effective governance</a></li><li><a href="https://www.thoughtworks.com/en-gb/radar/techniques/platform-engineering-product-teams">Platform Engineering Product Teams</a></li><li><a href="https://www.thoughtworks.com/insights/looking-glass/lens-three-realizing-the-potential-of-platforms">Realizing the potential of Platforms</a></li><li><a href="https://www.thoughtworks.com/content/dam/thoughtworks/documents/guide/tw_guide_enterprise_guide_to_platform_thinking.pdf">The enterprise guide to platform thinking</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=901e53485bb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A custom DSL for Rules Engine using Lark]]></title>
            <link>https://medium.com/@jeyabalajis/a-custom-dsl-for-rules-engine-using-lark-c8dd333d80c1?source=rss-81a85a449dff------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8dd333d80c1</guid>
            <category><![CDATA[credit-score]]></category>
            <category><![CDATA[domain-specific-languages]]></category>
            <category><![CDATA[lark]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[rules-engine]]></category>
            <dc:creator><![CDATA[Jeyabalaji Subramanian]]></dc:creator>
            <pubDate>Thu, 13 Oct 2022 16:23:43 GMT</pubDate>
            <atom:updated>2022-10-13T16:23:43.998Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QaChpqd2Je5kL798" /><figcaption>Photo by <a href="https://unsplash.com/@punttim?utm_source=medium&amp;utm_medium=referral">Tim Gouw</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Context:</h3><h4>Why Rules Engine?</h4><p>Decision-making has always been at the heart of any business. In specific industries (such as Lending), some of the decisions made are so dynamic &amp; in flux that programming these decisions by hand is counter-productive.</p><p>Take the example of the decision of giving someone a loan. When you start assessing a borrower based on their <em>ability to repay</em> and <em>intent to repay</em>, you typically get all facts required to make a decision (such as Bureau score, bank statements, etc.) and you will pass these facts through a <strong><em>decision matrix </em></strong>to arrive at the ability and intent to repay the loan.</p><p>The <strong><em>decision matrix </em></strong>mentioned above involves evaluation of multiple parameters and computation of scores.</p><ul><li>The evaluations and scores will <em>always</em> change over a period of time to adjust to business needs.</li><li>The <em>rules</em> will also change based on the nature of the business product.</li></ul><blockquote>Handling business rules that are in flux constantly warrants a declarative rules engine that is composable. This makes the corresponding software component flexible &amp; responsive to changing business needs.</blockquote><p><a href="https://github.com/jeyabalajis/simple-rule-engine#a-simple-decision-tree-involving-facts">Simple Rule Engine</a> is a composable, object-oriented rules engine that was used in production at <a href="https://medium.com/fundscornertech">FundsCorner</a> for executing a multitude of supply chain financing business rules.</p><p>Simple Rule Engine allows clients to compose rules and save them in a database. These rules can later be executed by passing facts from domain data. See <a href="https://github.com/jeyabalajis/simple-rule-engine#examples">here</a> for a comprehensive set of examples.</p><h4>Why DSL?</h4><p>An astute reader would have registered the usage of the parlance <em>business rules</em> in the section above. These rules are set by a domain expert and hence the rules that are created <em>must be </em><a href="https://martinfowler.com/bliki/BusinessReadableDSL.html"><em>business-readable</em></a><em>. </em>This unlocks the value of your rule engine but in a language that’s understandable by an end user.</p><blockquote>To make these rules business-readable, you might benefit from creating your own language, that describes the information in a clean and concise manner. That’s called a “Domain-Specific Language”, or DSL.</blockquote><blockquote><a href="https://github.com/lark-parser/lark">Lark</a> is an easy-to-use parsing toolkit for Python that enables you to create custom grammar that is business-readable.</blockquote><p>In the rest of the sections, we will compare two specific adapters for Simple Rule Engine, one with JSON and another with a business-readable custom DSL built with Lark. You may refer to this <a href="https://github.com/jeyabalajis/simple-rule-engine-client">repository</a> for adapter and code examples.</p><p>We will use a simple decision matrix provided below for our comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*QVYZk7ljUToW90_9epPyBQ.png" /><figcaption>A simple Decision Matrix that decides “GO” based on two parameters (Bureau Score &amp; Business Ownership)</figcaption></figure><h3>JSON Adapter for Simple Rule Engine</h3><p>JSON is a lightweight data-interchange format that is easy for humans to read and write. JSON is an ideal format for expressing and storing simple rules.</p><p>For the above-mentioned decision matrix, a candidate JSON representation could be as follows:</p><pre>{<br>    &quot;RuleDecision&quot;: {<br>        &quot;RuleRows&quot;: [<br>            {<br>                &quot;WhenAll&quot;: [<br>                    {<br>                        &quot;NumericToken&quot;: &quot;cibil_score&quot;,<br>                        &quot;Between&quot;: {<br>                            &quot;floor&quot;: 650,<br>                            &quot;ceiling&quot;: 800<br>                        }<br>                    },<br>                    {<br>                        &quot;StringToken&quot;: &quot;business_ownership&quot;,<br>                        &quot;In&quot;: [<br>                            &quot;Owned by Self&quot;,<br>                            &quot;Owned by Family&quot;<br>                        ]<br>                    }<br>                ],<br>                &quot;Consequent&quot;: &quot;GO&quot;<br>            }<br>        ]<br>    }<br>}</pre><h4>Advantages:</h4><ul><li>This is a faithful representation of the <a href="https://github.com/jeyabalajis/simple-rule-engine#grammar">underlying constructs of Simple Rule Engine</a>, hence it is easy to parse this rule specification and convert it into a Simple Rule Engine rule. See <a href="https://github.com/jeyabalajis/simple-rule-engine-client/blob/main/services/adapter/simple_rule_engine_dict_adapter.py">here</a> for an adapter written for JSON.</li></ul><h4>Disadvantages:</h4><ul><li>Since JSON follows a tree structure, with more complex rules, it is visually taxing to understand what the rule expresses.</li><li>This rule is not business-readable. Domain experts must spend some time understanding the grammar (RuleRows, WhenAll, NumericToken, StringToken, etc.) before they review the rules specification.</li></ul><h3>Custom SQL Like DSL for Simple Rule Engine</h3><p><a href="http://www.andrejkoelewijn.com/blog/2008/10/27/sql-is-a-dsl/">SQL</a> is an excellent language to express complex-yet-readable conditions. Since it has been prevalent for decades, domain experts can easily understand the intent of the rule with ease.</p><p>Let’s look at the rule specification for the same decision matrix, written in a <em>custom SQL Like grammar </em>built with <a href="https://github.com/lark-parser/lark">Lark</a>.</p><pre>my_rule {<br>    when {<br>        cibil_score &gt; 650 and<br>        house_ownership in (Owned by Self, Owned by Family)<br>    }<br>    then GO<br>}</pre><p>This representation is not only more concise but also clear to the reader reviewing the rule.</p><p>The benefits of SQL-like grammar only increase with complex rules. Let’s look at such a <strong>fictitious rule </strong>below:</p><h4>Complex Decision Rule:</h4><p><strong>Decide True when the following conditions are satisfied</strong></p><ul><li>CIBIL Score is between 650 and 750</li><li>Age is greater than 35</li><li>House ownership is owned or rented</li><li>The total overdue amount is zero (or) the number of overdue loans is less than 2 (or) the applicant is a big shot</li><li>Pet is dog</li></ul><p><strong>Decide False when the following conditions are satisfied</strong></p><ul><li>CIBIL score is less than 650</li></ul><p>With SQL-like custom grammar, the rule specification would be represented as follows:</p><pre>my_rule {<br>    when {<br>        cibil_score between 650 and 750 and <br>        age &gt; 35 and <br>        house_ownership in (owned, rented) and<br>        (<br>            total_overdue_amount == 0 or <br>            number_of_overdue_loans &lt; 2 or<br>            (<br>                number_of_overdue_loans &gt;= 2 and<br>                big_shot == true<br>            )<br>        ) and<br>        pet == dog<br>    }<br>    then true<br>    when {<br>        cibil_score &lt; 650<br>    }<br>    then false<br>}</pre><p>Even though the rule is complex, SQL allows the reader to process the various constituents with ease, and also shines with its compactness.</p><blockquote>SQL-like custom grammar representation allows you to build concise and business-readable DSL.</blockquote><h3>Under the hood</h3><p><a href="https://lark-parser.readthedocs.io/en/latest/how_to_use.html">Here </a>is a comprehensive guide on the recommended process for working with Lark.</p><p>At a high level, you will need to iteratively follow the below steps:</p><ul><li>Collect input samples that demonstrate key features in your language you’re trying to parse.</li><li>Write your grammar using EBNF.</li><li>Try your grammar in Lark against each input sample and ensure that the output tree makes sense. I.e. you have the right structure with which you can process the tree later.</li><li>Shape your grammar iteratively to make it concise.</li><li>Create a transformer to evaluate/convert the parse tree into a structure that you are aiming for.</li></ul><p>See <a href="https://github.com/jeyabalajis/simple-rule-engine-client/blob/main/services/adapter/simple_rule_engine_lark_tree_adapter.py">here</a> for an adapter that converts the Lark parse tree into a Simple Rule Engine Rule.</p><p>Here is the grammar that was written to represent the SQL-like custom DSL that we saw above:</p><pre>start: decisionrule+<br><br>decisionrule: CNAME &quot;{&quot; rulerow+ &quot;}&quot;<br><br>rulerow: when &quot;{&quot; condition &quot;}&quot; then decision<br>decision: boolean<br>        | numeric<br>        | string<br><br>?when: WHEN<br>?then: THEN<br><br>!condition: expression<br>        | [expression (conditional expression)*]<br><br>conditional: CONDITIONAL<br>expression: token in_operator word_list<br>        | token operator value<br>        | token between numeric &quot;and&quot; numeric<br>        | &quot;(&quot; [expression (conditional expression)*] &quot;)&quot;<br>        <br>token: TOKEN_OR_RULE<br><br>word_list: WORD<br>        | &quot;(&quot; [WORD (&quot;,&quot; WORD)*] &quot;)&quot;<br><br>between: &quot;between&quot;<br><br>?numeric: SIGNED_NUMBER  -&gt; number <br><br>?value: SIGNED_NUMBER   -&gt; number<br>        | boolean<br>        | string<br><br>?in_operator: INLIST<br><br>?operator: lt<br>        | gt<br>        | lte<br>        | gte<br>        | eq<br><br>string: CNAME<br>boolean: TRUE | FALSE<br>lt: &quot;&lt;&quot;<br>gt: &quot;&gt;&quot;<br>lte: &quot;&lt;=&quot;<br>gte: &quot;&gt;=&quot;<br>eq: &quot;==&quot;<br><br>TRUE: &quot;true&quot;<br>FALSE: &quot;false&quot;<br>WHEN: &quot;when&quot;<br>THEN: &quot;then&quot;<br>DECISION: (&quot;true&quot; | &quot;false&quot; | SIGNED_NUMBER | CNAME)<br>CONDITIONAL: &quot;and&quot; | &quot;or&quot;<br>TOKEN_OR_RULE: CNAME | (&quot;$RULE_&quot; CNAME)<br>DECISION_RULE: &quot;DecisionRule&quot;<br><br>INLIST: &quot;in&quot;<br>EQ: &quot;==&quot;<br><br>%import common.WORD<br>%import common.INT<br>%import common.SIGNED_INT<br>%import common.SIGNED_NUMBER<br>%import common.FLOAT<br>%import common.CNAME<br>%import common.ESCAPED_STRING<br>%import common.WS<br>%ignore WS</pre><h3>Conclusion</h3><p>A Rule Engine is a key constituent of many domains since it is prohibitive to write business rules of such domains by hand.</p><p>A rule engine that is declarative and composable makes the corresponding software component flexible &amp; responsive to changing business needs.</p><p>Writing a custom DSL that makes the business rules of your domain readable is a critical activity that unlocks the value of your rules engine to business users.</p><p>Lark is an easy-to-use parsing toolkit for Python that enables you to create custom grammar that is business-readable.</p><h3>References:</h3><p><a href="https://martinfowler.com/bliki/RulesEngine.html">Should I Use a Rules Engine</a> from <a href="https://martinfowler.com/">Martin Fowler</a></p><p><a href="http://blog.erezsh.com/how-to-write-a-dsl-in-python-with-lark/">How to write a DSL</a> from <a href="http://blog.erezsh.com/about/">Erez Shinan</a></p><p><a href="https://martinfowler.com/dsl.html">Domain-Specific Languages Guide</a> from Martin Fowler</p><p><a href="https://martinfowler.com/bliki/BusinessReadableDSL.html">Business Readable DSL</a> from Martin Fowler</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8dd333d80c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Data API Annotation Processor]]></title>
            <link>https://medium.com/@jeyabalajis/java-data-api-annotation-processor-1cc88a626f6a?source=rss-81a85a449dff------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cc88a626f6a</guid>
            <category><![CDATA[data-api]]></category>
            <category><![CDATA[data-platforms]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[data-mesh]]></category>
            <dc:creator><![CDATA[Jeyabalaji Subramanian]]></dc:creator>
            <pubDate>Sun, 06 Mar 2022 02:46:41 GMT</pubDate>
            <atom:updated>2022-10-14T11:31:44.983Z</atom:updated>
            <content:encoded><![CDATA[<p>A developer toolkit that <strong>reduces time to build Data APIs by 75% through rapid API generation (REST &amp; GraphQL)</strong>, using Java compile-time annotations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4P8bzjE4JDBQZQDs" /><figcaption>Photo by <a href="https://unsplash.com/@phillshaw?utm_source=medium&amp;utm_medium=referral">Phil Shaw</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What problem does this product solve?</h3><p>With the advent of microservices, the overall scope of a system is increasingly being segregated into multiple services.</p><p>Consider a big enterprise that has several systems, each focusing on a specific set of responsibilities. There is a need for a <em>single view of the data </em>generated by these systems, organized by business domains. At a large organization, a simple 360-degree view of a farmer may require integration from a dozen data sources.</p><p><a href="https://developer.confluent.io/learn-kafka/data-mesh/intro/">Data Mesh</a> is an approach that enables an organization’s data to be easily accessible and interconnected across the entire business. Data Mesh is found on the following base principles:</p><ol><li>Data as a Product</li><li>Data is available everywhere, Self-Serve</li><li>Data is governed wherever it is</li></ol><blockquote>The data mesh approach provides standard data guantees and access patterns by exposing a canonical set of data sets to consumers, thus obviating them from dealing with the complexities of the source systems.</blockquote><p><strong>Within a Data Mesh, a Data API is an interface that provides a self-serve consumption layer and solves the objective of making data discoverable, and secure, so other teams can make use of it.</strong></p><blockquote>The manual development of Data APIs for such <em>read services</em> severly impacts the agility &amp; standardization of the consumption layer.</blockquote><p><strong>This is where the <em>Java Data API Annotation Library </em>comes into play<em>.</em></strong></p><p>I recently led a micro-team in designing, building, and building out this product. Through the product, <strong>we accomplished a 75% reduction in time to roll out a new Data API.</strong></p><p>Let’s look at the salient features, high-level design &amp; technologies behind this product in the sections below.</p><h3>Salient Features</h3><ul><li>Ability to express query or sorting ability on fields through annotations</li><li>Allow search across hierarchical table structure</li><li>Database agnostic</li><li>Ability to plug in this as a library within Maven or Gradle dependency management providers.</li></ul><h4>Express Query or Sorting ability on fields through annotations</h4><ul><li>Allows developers to use a handful of annotations (similar to the familiar <a href="https://www.journaldev.com/17803/jpa-hibernate-annotations">JPA annotations</a> such as Table, Column etc.) to <em>express their query/sort requirements </em>and produce a full-fledged Data API.</li></ul><p>Here’s an example of how users would enable query and sort on a field:</p><pre>@Entity <br>@Table(name = &quot;employee&quot;)<br><strong>@DataApi </strong><br>public class Employee implements Serializable {     <br>   @Column(name = &quot;employee_name&quot;)<br>   <strong>@EnableQuery</strong><br>   <strong>@Sortable  </strong><br>   private String employeeName; <br>}</pre><h4>Allow search across hierarchical table structure</h4><ul><li>Ability to <em>search across hierarchical table structure</em> by exposing all fields enabled for a query across an entire tree of entities<em>.</em></li></ul><p>For example, let us say you have enabled DataApi for Entity A, which has a <em>One To Many relationship</em> with Entity B. Entity B has a <em>One to Many relationship</em> with Entity C. The search class for entity A will have filter fields belonging to Entity A, Entity B, and Entity C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rN_jsPjleBO3Wu1LSViTdw.png" /></figure><blockquote><strong><em>This enables consumers to develop powerful Data APIs that support complex queries across tables, without breaking a sweat.</em></strong></blockquote><h4>Database agnostic</h4><ul><li>Ability to <em>enable Data API on any relational database. </em>The product does not have a lock-in with any specific database. The queries constructed are ANSI SQL compliant.</li></ul><h3>High-Level Design</h3><ul><li>At a high level, the product employs <a href="https://hannesdorfmann.com/annotation-processing/annotationprocessing101/#:~:text=Annotation%20processing%20takes%20place%20at,annotation%20processor%20for%20certain%20annotations.">compile-time annotation processing</a> that enables developers to express their API query requirements as <em>annotations</em>. These are similar to the <a href="https://www.journaldev.com/17803/jpa-hibernate-annotations">JPA Annotations</a> developers are already familiar with. Annotations are provided on the field level to enable querying and/or sorting.</li><li>The product then extracts the metadata <em>through these annotations</em> &amp; builds a meta-data schema that houses developer specifications.</li><li>The meta-data schema is further leveraged to build a full-fledged API codebase through <a href="https://github.com/square/javapoet">Java code generation</a> <em>at compile time</em>.</li><li>The generated codebase exposes the following:</li><li><em>Search classes </em>are exposed for developers to express complex queries or sort requirements</li><li><em>Service classes are </em>exposed for passing in the search objects constructed above &amp; retrieving search results.</li></ul><p>The high-level design schematic is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EpIp7IHGe2cVV14mNa4E1Q.png" /></figure><h4>End-User flow</h4><ol><li>The user includes api-annotation-processor as a maven dependency in the package manager.</li><li>The user decorates entity classes &amp; fields inside these classes with appropriate annotations (for query, sorting, etc.).</li><li>The user compiles the code.</li><li>The system reads annotations from entity classes, generates metadata, and generates an API codebase under the <em>target folder, </em>exposing <em>search classes &amp; service processors.</em></li><li>The user uses the search classes generated above, composes search objects, and implements API requirements by calling <em>the service processor</em>.</li><li>The user can choose to unit test the API generated.</li></ol><blockquote>From end users perspective, they just need to annotate entities &amp; compile the code. They can then freely express any complex query by constructing appropriate search objects, and not worry about the underlying implementation.</blockquote><h3>Note on Query parameters</h3><p>The system generates appropriate <em>qualifiers </em>based on the <em>data type of the field</em> on which <em>EnableQuery </em>is used. Specifically,</p><ul><li><strong>String fields:</strong> <em>like and in </em>are exposed</li><li><strong>Numeric &amp; Date fields:</strong> <em>equals, not equal, greater than equals, less than equals </em>are exposed</li></ul><blockquote>Just by annotating a field with <em>EnableQuery, </em>developers are able to express the full range of query possibilities, without writing a single line of code.</blockquote><h3>Note on Annotations</h3><h4><strong>Entity level annotations:</strong></h4><ul><li><strong>DataApi:</strong> Use this annotation on any Entity Class and watch it getting transformed into a REST Service and/or a GraphQL endpoint.</li></ul><blockquote><em>An entity must contain all of </em>DataApi<em>, </em>Entity<em> and </em>Table<em> annotations to be considered by the processor.</em></blockquote><blockquote><em>An entity must contain a Primary Key field. I.e. a field annotated with </em>Id<em> or </em>EmbeddedId<em>.</em></blockquote><h4><strong>Field level annotations</strong></h4><ul><li><strong>EnableQuery:</strong> Use this annotation to enable search on a field within an entity. The system automatically generates <em>qualifier fields for </em>Equals, NotEquals, In, Not In, Like, Greater than Equals, Greater Than, Less than Equals, and Less Than criteria.</li><li><strong>Sortable:</strong> Use this annotation to enable sorting on a field within an entity.</li><li><strong>InnerJoin:</strong> Use this annotation on relations (<em>One to One</em> or <em>One to Many</em> or <em>Many to One</em>) to specify the inner join relation.</li><li><strong>LeftJoin:</strong> Use this annotation on relations (<em>One to One</em> or <em>One to Many</em> or <em>Many to One</em>) to specify the left join relation.</li></ul><blockquote><em>A field must contain one of </em>Column<em>, </em>OneToMany<em>, </em>ManyToOne<em>, </em>OneToOne<em>, </em>EmbeddedId<em> or </em>Id<em> annotation to be considered by the processor.</em></blockquote><h3>Technology components</h3><ul><li><a href="https://github.com/square/javapoet">Java Poet</a>: A Java API for generating .java source files. We used Java Poet to translate <em>metadata schema </em>into code.</li><li><a href="http://www.querydsl.com/">QueryDSL</a>: A powerful high-level abstraction for SQL queries. We used QueryDSL to compose <strong>powerful yet readable fluent queries</strong> by dynamically joining entities based on metadata, adding dynamic predicates (i.e. search criteria), and sorting by clauses.</li><li><a href="https://github.com/leangen/graphql-spqr">GraphQL SPQR</a>: GraphQL SPQR (GraphQL Schema Publisher &amp; Query Resolver, pronounced like <em>speaker</em>) is a simple-to-use library for rapid development of GraphQL APIs in Java. It uses a code-first approach to generate GraphQL schema and APIs from the existing models.</li></ul><h3>Conclusion</h3><p>By composing a set of powerful libraries, we were able to produce a solid developer product that <strong>reduced the time to build Data APIs by 75% </strong>and enabled developers to channel their time for other value-adding activities<strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cc88a626f6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Capacity Estimation in Systems Design]]></title>
            <link>https://medium.com/@jeyabalajis/capacity-estimation-in-systems-design-89cb1d0d3a0f?source=rss-81a85a449dff------2</link>
            <guid isPermaLink="false">https://medium.com/p/89cb1d0d3a0f</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[capacity-estimation]]></category>
            <dc:creator><![CDATA[Jeyabalaji Subramanian]]></dc:creator>
            <pubDate>Wed, 02 Mar 2022 06:04:38 GMT</pubDate>
            <atom:updated>2022-03-02T06:06:23.100Z</atom:updated>
            <content:encoded><![CDATA[<p>A framework for capacity estimation and auto-scaling</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T_WNKveOfLmOmCwc" /><figcaption>Photo by <a href="https://unsplash.com/@medbadrc?utm_source=medium&amp;utm_medium=referral">Med Badr Chemmaoui</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Capacity estimation or back-of-the-envelope calculations is often asked during systems design interviews. In this article, I propose a methodical way of breaking down such questions.</p><p>At the end of the article, you will not only gain an understanding of approaching such questions, but you will also have a method for designing auto-scaling (i.e. scale up or down based on demand).</p><p>Before diving into the concept, let’s warm up with this sample question.</p><ul><li>Let’s say we are designing a “Nearby restaurants locator”.</li><li>We expect a total of 2 million <em>search </em>requests per day.</li><li>Each request must be served within 100 milliseconds 90% of the time. I.e. we require a P90 latency of 100 milliseconds.</li></ul><p><em>How many servers are required to handle this?</em></p><h4>Framework for Capacity estimation</h4><p>Let’s look at capacity estimation as a problem of <em>designing for capacity</em>, that meets a <em>certain demand</em>, without compromising <em>service level objectives (SLO)</em>.</p><p>Thus, as a framework, solving for capacity estimation involves three key metrics, viz:</p><ol><li><strong>Service Level Objective (SLO).</strong> SLO is the maximum acceptable metric for the transaction in question. In our question above, we are solving for search query latency. So, an SLO of <em>100-milliseconds represents the maximum acceptable latency, </em>immaterial of the load on the system.</li><li><strong>The current number of requests. </strong>This is the load or demand on the system. For example, if there are <em>2 million active users per day, and each user makes just one search request, </em>this works out to 24 requests per second. [2,000,000/86400 = 23.14 ~=24]</li><li><strong>The average capacity of a single unit </strong>to process a request. For our example, one “unit” may take approximately <em>35 milliseconds to serve a request</em>. This number is typically arrived at by running performance tests on near-ready production services with tools such as <a href="https://locust.io/">Locust</a>.</li></ol><p>Using the above key metrics, let’s generate two more <strong>derived metrics</strong>, one for capacity &amp; demand each:</p><ul><li><strong>Capacity:</strong> Acceptable Backlog per Instance</li><li><strong>Demand:</strong> Backlog per Instance</li></ul><h4>Acceptable Backlog per Instance</h4><p>In our example above, <em>a unit takes approx. 35 milliseconds</em> to serve a request. We also know that our <em>SLO is 100 milliseconds</em>.</p><p>Acceptable Backlog per instance is defined as <strong>SLO divided by the average capacity of a unit</strong>, i.e. 100 / 35 ~= 3.</p><blockquote><em>Intuitively, Acceptable backlog per instance is the maximum number of requests that can be accepted by an instance, without compromising SLO.</em></blockquote><p>An astute reader will detect that the average latency is well below the SLO, allowing an instance/unit to take more than a request. This is common sense — if an instance cannot handle one single request within SLO, there is no question of scalability.</p><h4>Backlog per Instance</h4><p>In our example above, we estimated the demand as 24 requests per second.</p><p>Backlog per instance is defined as <strong>Demand divided by total running units in a fleet.</strong></p><p>Assuming that only a single unit is running in a fleet, the backlog per Instance is equal to 24 / 1 = 24.</p><blockquote>Intuitively, Backlog per instance is the total load that flows into a unit or instance, based on current traffic.</blockquote><h4>Total number of units/instances required</h4><p>We now know that</p><ul><li>The backlog per instance is 24</li><li>The acceptable backlog is 3</li></ul><p>The total number of units per required is defined as <strong>Backlog per Instance divided by Acceptable Backlog per Instance, </strong>i.e. 24 / 3 = 8 units.</p><p><strong>I.e. with 8 units, we can serve a load of 24 requests per second. Each unit can <em>comfortably </em>handle 3 requests without compromising SLO.</strong></p><h4>Auto-Scaling</h4><p>One critical question at this juncture is: “What if the traffic increases beyond the estimated 24 requests per second?”</p><p>Certain parts of the day see more traffic than usual. We must account for such scenarios as well.</p><p>The above framework enables us to deal with such scenarios with ease.</p><p>To handle the increase in traffic, we can configure an auto-scaling group with a <strong>target tracking policy</strong>. The target policy shall be configured as follows:</p><ul><li>Set <em>Acceptable backlog per instance </em>as the target value.</li><li>Periodically emit <em>Backlog per-instance </em>as the metric to compare against <em>Acceptable backlog instance.</em></li><li>Whenever the <em>backlog per instance </em>is higher than the <em>Acceptable backlog per instance, scale out</em><strong> (i.e. increase) the number of instances.</strong></li><li>Whenever the <em>backlog per instance </em>is lower than the <em>Acceptable backlog per instance, scale in</em><strong>(i.e. decrease) the number of instances.</strong></li></ul><p>Let us validate this with an example:</p><ul><li>The requests peak into 96 requests per second</li><li>The current fleet capacity is 8.</li></ul><p>In this case,</p><ul><li><em>Backlog per instance = 96/8 = 12.</em></li><li><em>Acceptable Backlog per Instance = 3.</em></li><li>This will trigger a scale-out action, and the number of instances in the fleet will be increased by another 24 units, taking the total number of instances to 32.</li><li><strong>After the scale-out action, the Backlog per instance would be 96/32=3. </strong>This stops any further scaling action.</li></ul><p>Similarly, when the requests drop to 24 requests per second,</p><ul><li><em>Backlog per Instance = 24/32 = 0.75</em></li><li><em>Acceptable Backlog per Instance = 3.</em></li><li>This will trigger a scale-in action, and the number of instances in the fleet will be reduced to 8.</li><li>After the scale-in action, the Backlog per Instance would be 24/8=3. This stops any further scaling action.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iCRjDiRs8LP5vP5X_J6hdA.png" /><figcaption>Auto-Scaling action as the demand increases</figcaption></figure><blockquote>We can use Backlog per Instance and Acceptable Backlog per Instance as metrics to estimate capacity, and also dynamically scale the current fleet capacity.</blockquote><h4>Summary</h4><p>We looked at a methodical way to calculate the number of instances required to satisfy SLO, given a current load/demand. The key metrics we defined are illustrated in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGz43FpDqxr6Wi1MuB8_Rg.png" /><figcaption>Key metrics for capacity estimation</figcaption></figure><h4>References:</h4><ul><li><a href="https://sre.google/sre-book/service-level-objectives/">Google - Site Reliability Engineering</a></li><li><a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-using-sqs-queue.html">Scaling policy based on Amazon SQS</a></li><li><a href="https://servebolt.com/articles/calculate-how-many-simultaneous-website-visitors/">How to Estimate How Many Website Visitors Your Hosting Can Deal With</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89cb1d0d3a0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To be or not to be]]></title>
            <link>https://medium.com/@jeyabalajis/to-be-or-not-to-be-b1dd56cabe10?source=rss-81a85a449dff------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1dd56cabe10</guid>
            <category><![CDATA[short-story-writing]]></category>
            <category><![CDATA[self-love]]></category>
            <dc:creator><![CDATA[Jeyabalaji Subramanian]]></dc:creator>
            <pubDate>Sat, 04 Sep 2021 07:32:56 GMT</pubDate>
            <atom:updated>2021-09-04T07:34:31.711Z</atom:updated>
            <content:encoded><![CDATA[<h4>A small story on (self) love</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*trmV9wYcF3yiLv2m" /><figcaption>Photo by <a href="https://unsplash.com/@olianayda?utm_source=medium&amp;utm_medium=referral">Olia Nayda</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Sajani was looking at herself intently in the mirror, worried about her date next week. The irony was inescapable.</p><p>Despite her orthodox Indian upbringing, Sajani had yearned for her freedom to choose someone freely — and partially succeeded too; She had met Arun a week back and felt he was genuine. She had even introduced him to her parents. Everything was going fine, but for this one thing that stood in her way — her lion tooth.</p><p>“I want to choose my partner freely, but can’t even choose to keep my teeth as is?”, Sajani wondered aloud. “What will Arun think about me?” Torn by this indecisiveness, Sajani stormed out of her room. She was mortified by what she saw.</p><p>Arun was standing outside her room. “Oh, err, what’s the matter? when did you come in?” Sajani asked meekly. “I had forgotten my bike keys in your vanity bag.” An eerie silence followed. “Okay, I should get going….”, “and, by the way, you can choose to keep the tooth and me,” said Arun and walked away.</p><p>With that, Sajani put an end to her vacillation and set up a dentist appointment for the next day.</p><p>P.S: I wrote this short story in response to a challenge: “Write a very short story — not more than 200 words — about a trip to the doctor or dentist in ABDCE structure (Action — Background — Development — Climax — End)”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1dd56cabe10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top best practices for architecting Cloud Native applications with confidence]]></title>
            <link>https://medium.com/fundscornertech/top-best-practices-for-architecting-cloud-native-applications-with-confidence-732baba24d1?source=rss-81a85a449dff------2</link>
            <guid isPermaLink="false">https://medium.com/p/732baba24d1</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[jeyabalaji]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Jeyabalaji Subramanian]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 12:42:54 GMT</pubDate>
            <atom:updated>2021-08-02T11:18:19.412Z</atom:updated>
            <content:encoded><![CDATA[<h4>A summary of our experiences building Cloud Native applications across 18 months</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ALy8nZEEUhvCPtn8" /><figcaption>Photo by <a href="https://unsplash.com/@danist07?utm_source=medium&amp;utm_medium=referral">贝莉儿 NG</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>At <a href="http://www.fundscorner.com/">FundsCorner</a>, we embraced Cloud Native from day one to conceive, architect and deliver an end to end digital supply chain lending platform in record time.</p><p>Cloud Native is the answer to the software industry’s relentless search in the current decade for a set of tools and practices that makes your software easily deployable, modular, maintainable, robust, reliable, scalable, portable and observable — all at once.</p><p>This post is a detailed account of our learnings and best practices with building applications with Cloud Native architecture (and mindset).</p><p>Under the hood, a Cloud Native architecture is supported by these key architecture patterns and processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*_7jSu3lNP7SwrEZ6yJ41MQ.png" /><figcaption>Architecture Patterns and processes that support Cloud Native, as per <a href="https://pivotal.io/">Pivotal</a>. See <a href="https://pivotal.io/cloud-native">here</a></figcaption></figure><p>Below we take a critical look at how we embraced these pillars, <strong>from the perspective of the benefits they bring in.</strong></p><h3>Agility:</h3><p>In the software world, <em>immaterial of what you do under hood</em>, agility is measured by how fast you bring in value to business through software. There are a number of question that beg answer from agility:</p><ul><li>How fast can your application respond change in Business Requirements?</li><li>Can you confidently deploy a change into production, just by pushing a commit into <a href="https://git-scm.com/">git</a>, knowing that the fix is isolated to a particular service and it would work?</li><li>And, when the fix DOES NOT work, how fast can you rollback this change without disrupting Production?</li></ul><p>For you to answer these questions with confidence, you must embrace the three pillars of Microservices, DevOps and Continuous Delivery.</p><blockquote>At FundsCorner, any software we have written ever, is a microservice.</blockquote><p>This forces us to isolate related, cohesive pieces of functionality into a logical unit; and allows us to change <strong>specific parts of the functionality with ease, without disrupting the whole product</strong>.</p><blockquote>We use <a href="https://nvie.com/posts/a-successful-git-branching-model/">Git flow</a> workflow model to isolate changes into branches and <a href="https://docs.gitlab.com/runner/">GitLab runners</a> to trigger builds when software is pushed into Git. We use <a href="https://docs.pytest.org/en/latest/">pytest</a> to write unit and module tests.</blockquote><p>This model enables us to create <strong>small and purpose driven branches</strong>, test them thoroughly and then merge into the master.</p><blockquote>Most of our services are automatically deployed onto the Cloud using <a href="https://github.com/Miserlou/Zappa">Zappa</a>. We also do use Docker to push out changes into a Docker registry, which then is pulled and rolled out based on Kubernetes deployment configuration.</blockquote><p>With the aforementioned tools, we are NOT anymore dealing directly with the infrastructure. We just modify the deployment instructions in a JSON or a YAML file (i.e. Infrastructure as Code) and the DevOps tool takes care of the rest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pKsIUpIzyMzr4s0Y" /><figcaption>Photo by <a href="https://unsplash.com/@gautamlakum?utm_source=medium&amp;utm_medium=referral">Gautam Lakum</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a> (Be agile, ship fast!)</figcaption></figure><p>Note that I had intentionally italicized “immaterial of what you do” in the opening of the section. Because, you cannot do whatever you want to do just for the sake of agility. In the long run, this practice is going to make you less and less agile, as the business requirements evolve… That brings our focus onto modularity…</p><h3>Modularity:</h3><p>Modularity measures how well the application is structured into cohesive units, <strong><em>abstracting away the complexities under the hood. </em></strong>For example, a loan management system will have to manage a lot of complexities under the hood in terms of the interest &amp; penalty computation — but still may expose a clean, user — understandable contracts to the end users &amp; other sub-systems alike.</p><p>The following are the questions that are typically answered by Modularity:</p><ul><li>Has the application been broken down into small, self sustaining &amp; cohesive pieces?</li><li>Has the functionality been sufficiently abstracted away for the end consumer (be it another service or end user) with meaningful data contracts?</li><li>How easy it is to introduce a new feature into the module with isolated impact surface? put in the other way, how <em>plastic/flexible</em> is the module?</li></ul><p>Microservices are the modern answer to the above questions. However, this approach of fine grained chopped microservices brings on challenges around <em>controlling and monitoring the overall business flow as a whole</em>.</p><p>There are patterns to solve these challenges. Peer to peer choreography and Orchestration are two predominant patterns among these.</p><p>At FundsCorner, we have developed an in-house serverless workflow manager, which orchestrates distributed microservices to fulfil a singular objective. (Side note: See <a href="https://medium.com/@jeyabalaji.subramanian/open-source-serverless-workflow-manager-dddd5801720c">here</a> for a detailed account on our approach and solution)</p><p>With the workflow manager approach, we were able to <em>standardize </em>services across multiple workflows, thus making the overall architecture more modular and extensible.</p><p>For example, we have a microservice dedicated for managing human tasks. With this service, you can configure &amp; control:</p><ul><li><em>how</em> a human is notified (SMS, Email or App Push Notification)</li><li><em>who </em>is supposed to fulfil this task (role based access control)</li><li><em>whether</em> the task is a gateway task (i.e. more than one choices possible, to enable approve / reject flows)</li></ul><p>When a new requirement for OTP based approval came in, <em>we were able to extend this service with ease</em> to fulfil this requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v0CDU-HrCxl1hTYQ" /><figcaption>Photo by <a href="https://unsplash.com/@dreamevile?utm_source=medium&amp;utm_medium=referral">Raphael Koh</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>(Be modular, Ship with confidence!)</figcaption></figure><h3>Portability:</h3><p>A portable software is <strong>agnostic to the environment under which it is deployed</strong>.</p><p>A few questions that are <em>important &amp; relevant for portability:</em></p><ul><li>How easy it is to deploy your software onto a different Cloud Provider?</li><li>Have you made database as a <em>detachable service</em>? How easy it is to point your microservices to a different instance of a database?</li><li>What about secrets? Is there a <em>central, secure repository from </em>where your secrets are being served? Or are they attached to the environment? (which in turns brings down the portability quotient)?</li></ul><p><a href="https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/">Kubernetes</a> is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.</p><blockquote>At FundsCorner, almost all of our services are deployed on the cloud, either as a serverless function on <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> (or) as containers in Kubernetes.</blockquote><blockquote>We use <a href="https://aws.amazon.com/secrets-manager/">AWS Secrets Manager</a> to <strong>secure and audit our secrets centrally</strong>. You may want to look at other alternatives such as <a href="https://www.vaultproject.io/?ref=stackshare">Vault</a> to manage secrets <strong>centrally and on cloud.</strong></blockquote><p>Conforming to <a href="https://12factor.net/backing-services">12 factor apps</a>, we treat backing services as attached resources. I.e. the database is just a URL which can easily be changed at run time at a Centralized Secrets Manager, <strong><em>without modifying any source code.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6l7SxiYHCjvOpFys" /><figcaption>Photo by <a href="https://unsplash.com/@frankiefoto?utm_source=medium&amp;utm_medium=referral">frank mckenna</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a> (Be portable, Ship with ease!)</figcaption></figure><h3><strong>Resiliency, Monitoring &amp; Exception Handling:</strong></h3><p>The inherent modular and distributed nature of cloud native applications make it all the more difficult to identify and trace issues.</p><p>There is minimal room for error. More often, there is NO box you can look into to see the logs.</p><p>Resiliency is the ability to recover from faults. So, you build an application knowing that there would be faults &amp; you <em>create services which are equipped to correct these faults.</em></p><blockquote><em>At FundsCorner, our in-house workflow manager serves as the monitoring tool for identifying failed micro services &amp; they are duly retried. The microservices </em>have also been written with the assumption<em> that they may get invoked multiple times.</em></blockquote><blockquote>We also we have a set of core integrity checkers &amp; retry agents. They ensure that the data integrity is maintained at all times.</blockquote><blockquote>We use <a href="https://sentry.io/welcome/">Sentry</a> for identifying crashes on time. We have also developed an in-house solution through <a href="https://api.slack.com/incoming-webhooks">Slack webhooks</a> to get notified of critical crashes as they occur.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JilVuJg_UHiiy40X" /><figcaption>Photo by <a href="https://unsplash.com/@yunmai?utm_source=medium&amp;utm_medium=referral">i yunmai</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a> (Build resilience into the system, intentionally)</figcaption></figure><h3>Conclusion:</h3><p>Our 18 months of building and running cloud native applications has provided us a number of benefits.</p><ul><li>Beyond the buzz, fully embracing cloud native practices has enabled us to <strong>look up to a true north for building a reliable, scalable and maintainable system</strong>.</li><li>We are more tolerant to failures because we have built or embedded controls to <strong>identify faults on time and recover to the correct state fast</strong>.</li><li>It has provided the team <strong>the joy of owning self-sufficient, cohesive services fully &amp; embrace agility</strong>.</li><li>We are addicted to <strong>building and shipping fast with Continuous Integration and DevOps tools</strong>.</li></ul><p>Hope this detailed account helps you in your journey of building great usable cloud native applications fast!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=732baba24d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fundscornertech/top-best-practices-for-architecting-cloud-native-applications-with-confidence-732baba24d1">Top best practices for architecting Cloud Native applications with confidence</a> was originally published in <a href="https://medium.com/fundscornertech">FundsCorner Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>