<?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 Dharmesh Panchmatia on Medium]]></title>
        <description><![CDATA[Stories by Dharmesh Panchmatia on Medium]]></description>
        <link>https://medium.com/@dharmeshpanchmatia?source=rss-9b8ca7c47367------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0nVaGoUN51vysZbg.jpg</url>
            <title>Stories by Dharmesh Panchmatia on Medium</title>
            <link>https://medium.com/@dharmeshpanchmatia?source=rss-9b8ca7c47367------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:22:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dharmeshpanchmatia/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 a highly scalable configuration rule engine for eCommerce]]></title>
            <link>https://dharmeshpanchmatia.medium.com/building-a-highly-scalable-configuration-rule-engine-for-ecommerce-4a9040bb5c72?source=rss-9b8ca7c47367------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a9040bb5c72</guid>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[b2b]]></category>
            <category><![CDATA[cpq]]></category>
            <category><![CDATA[config-rule-engine]]></category>
            <dc:creator><![CDATA[Dharmesh Panchmatia]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 23:55:30 GMT</pubDate>
            <atom:updated>2021-01-10T23:55:30.679Z</atom:updated>
            <content:encoded><![CDATA[<h3>Abstract</h3><p>Configuration is the process of selecting components for a product to ensure its validity at the time of order placement. Configuration rule engines drive the configuration experience of products on eCommerce platforms to ensure products can be introduced quickly without requiring any code changes.</p><p>Configuration rule engines need to be scalable to handle complex products such as network routers and switches as there can be over a million records in their bill of material (BOM). Most of the configuration rule engines in the market today struggle dealing with configuration of complex products.</p><p>We have built a scalable rule engine for Cisco’s eCommerce platform that can scale to millions of transactions per hour and can handle complex products with ease. This white paper explains configuration rule engine basics, highlights challenges with traditional rule engines, and details out our novel approach to address these challenges.</p><h3>Configuration Basics</h3><p>Two key capabilities required to enable a configurable product on an eCommerce platform are:</p><ol><li><strong>Application for Product setup: </strong>allows product teams to set up structure and configuration rules for products</li><li><strong>Rule Engine: </strong>applies rules at runtime and guides a user (buyer) with selection of product components</li></ol><p><strong>Application for Product Setup</strong></p><p>Building an application for product setup is relatively straight forward and hence I will not focus on that aspect. I will instead explain product structure and configuration rules with an example.</p><p><strong>Example of product structure</strong></p><p>The following is an example of the product structure for a rack server. A rack server consists of many components (SKUs), such as chassis, blades, processors, memory, storage, power supply, operating system, etc. I will use a rack server with only four components: blades, processors, memory and power supply, for simplicity.</p><p>Components in <strong>bold italics</strong> are logical entities (groups) used for grouping similar physical components (SKUs). Physical components (SKUs) are depicted in <strong>regular font</strong>. “|” delimiter shows the level of depth of a component from the top level of the hierarchy.</p><p>Product — RACKSERVER</p><p>|- <strong><em>BLADE</em></strong></p><p>| |-<strong><em>BLADENAME</em></strong></p><p>| | |- B1</p><p>| | | |- <strong><em>Processor</em></strong></p><p>| | | | |- P1</p><p>| | | | |- P2</p><p>| | | |- <strong><em>Memory</em></strong></p><p>| | | | |- M1–256MB</p><p>| | | | |- M2–512MB</p><p>| | |- B2</p><p>| | | |- <strong><em>Processor</em></strong></p><p>| | | | |- P3</p><p>| | | | |- P1</p><p>| | | |- <strong><em>Memory</em></strong></p><p>| | | | |- M1–256MB</p><p>| | | | |- M2–512MB</p><p>|- <strong><em>Power</em></strong></p><p>| |- <strong><em>Power Supply</em></strong></p><p>| | |- AC-PWR-SKU</p><p>| | |- HIGH-AC-PWR-SKU</p><p>The product RACKSERVER consists of <strong><em>BLADE</em></strong> and <strong><em>Power.</em></strong> <strong><em>BLADE </em></strong>further contains <strong><em>BLADENAME,</em></strong> <strong><em>Processor</em></strong> and <strong><em>Memory</em></strong> units, and <strong><em>Power</em></strong> contains <strong><em>Power Supply</em></strong>. It is a hierarchical tree with the product RACKSERVER as the root of the tree. <strong><em>BLADE</em></strong> &amp; <strong><em>Power</em></strong> are children of RACKSERVER and <strong><em>BLADENAME</em></strong> is a child of <strong><em>BLADE</em></strong>.</p><p>B1, B2, P1, P2, P3, M1–256MB, M2–512MB, AC-PWR-SKU &amp; HIGH-AC-PWR-SKU are examples of physical SKUs. B1 &amp; B2 are blade SKUs, P1, P2 &amp; P3 are processor SKUs, AC-PWR-SKU &amp; HIGH-AC-PWR-SKU are power supply SKUs and M1–256MB &amp; M2–512MB are memory SKUs with capacity of 256 &amp; 512MB respectively.</p><p><strong>Example of configuration rules</strong></p><p>There are many types of configuration rules. We will focus on only three rules types: expansion, compatibility and value constraint rules, to illustrate challenges of dealing with complex products. Other rule types face similar issues.</p><p><strong>Expansion Rule:</strong> expand a component (SKU) on selection of another component (SKU)</p><p><strong>Rule1: </strong>Automatically add processor P1 if user selects blade B1.</p><p>If BLADENAME = B1 (Condition)<br> then Processor = P1 (Action)<br> <br> <strong>Rule2: </strong>Automatically add processor P2 if user selects blade B2.</p><p>If BLADENAME = B2 (Condition)<br> then Processor = P2 (Action)</p><p><strong>Rule3: </strong>Automatically add power supply AC-PWR-SKU if user selects processor P1.</p><p>If Processor = P1 (Condition)<br> then Power Supply = AC-PWR-SKU (Action)</p><p><strong>Incompatibility Rule</strong>: one component is incompatible with another component. These rules can be defined on individual components (SKUs) or on a group of components.</p><p><strong>Rule4: </strong>Hide power supply HIGH-AC-PWR-SKU on selection of blade B1 as it is not compatible<br> B1 incompatible HIGH-AC-PWR-SKU</p><p><strong>Value Constraint Rule:</strong> Constrain the number of components selected based on the total value of an attribute of those components (for e.g. total memory for a rack server cannot exceed 1GB)</p><p><strong>Rule5: </strong>Throw error message if total value of memory selected exceeds 1GB <br> If <strong>count(M1–256MB ) &gt; 4</strong> or <strong>count(M2–512MB) &gt;</strong> <strong>2</strong> or <strong>[count(M1–256MB) &gt; 0 and count(M2–512MB) &gt; 1] </strong>or <strong>[count(M1–256MB) &gt; 2 and count(M2–512MB) &gt; 0] </strong>(Condition)<br> then display error: Memory cannot exceed 1GB (Action)</p><p><strong>2.</strong> <strong>Configuration Rule Engine</strong></p><p>On selection of a component (SKU) of a product by a user, the eCommerce application sends the user selection to a configuration rule engine. The rule engine executes all relevant rules, changes the data set based on the outcome of the rules and then returns the next set of selectable components to the eCommerce application. The end goal is to ensure a valid configuration of the product which can be successfully ordered.</p><p>We can build rule engines in many different ways, but the following are typical approaches used:</p><p><strong>Using forward chaining:</strong><br> Forward Chaining starts with the data and uses inference rule to extract more data until it reaches a goal. An inference engine using forward chaining searches the inference rules until it finds one where the antecedent (If clause) is true. This is also called constraining rule execution as one narrows the selection options available to users based on previous selections.</p><p><strong>Using a variation of Rete algorithm:</strong></p><p>Charles Forgy’s Rete algorithm provides a generalized functionality responsible for matching data tuples (“facts”) against productions (“rules”) in a pattern-matching system.</p><p>A drawback of Rete algorithm is that it is memory intensive as all different permutations of data and rule tuples can be exponentially large. It needs considerable amount of memory for every user session.</p><p>Hence many configuration rule engines use variations of forward chaining. For rest of the discussion we will focus on configuration rule engines implemented using forward chaining.</p><h3><strong>Traditional Configuration Rule Engines versus Our Approach</strong></h3><p>This section highlights the challenges with traditional rule engines and explains how we have overcome them.</p><p>1. <strong>Rich content at component level</strong></p><p><strong>Tradition rule engines</strong> do not have the capability for product teams to provide rich content as part of product setup. This feature is critical for complex products with a high number of SKUs under the same logical group. For example, high end blade servers can have 50+ processor SKUs and it becomes difficult for users to understand the differences between them without rich descriptive content that can provide that clarity.</p><p><strong>Our Approach</strong>: We have built content management features in our configuration rule engine. Our rule engine offers card templates that allows product teams to provide rich content such as images and verbiage at component level as part of the product setup. The product teams can change the images or the verbiage for a product anytime without the need of a code change. This feature is a competitive differentiator for Cisco.</p><p><strong>2.</strong> <strong>High resource consumption</strong></p><p>Assume that a rack server has 16 slots and there are 10 different blades that can be placed in these slots. In addition, assume there are 50 different processor and 40 different memory SKUs available for each blade. We can configure each blade with a combination of different processor and memory SKUs.</p><p><strong>Traditional Engines:</strong> In a typical engine, the product structure repeats the 10 blades with all its underlying processors and memory SKUs for each of the slots resulting in a very large product structure (for each slot -&gt;10 blades, for each blade-&gt;50 processor SKUs &amp; 40 memory SKUs). In addition, most traditional rule engines are stateful and maintain the product structure in session memory for every user session. This results in a very high memory consumption.</p><p><strong>Our Approach:</strong> We use the concept of dynamic instantiation to address the above problem. We have also built a stateless rule engine instead of a stateful rule engine. Since the engine is stateless, all user selections have to be sent to the rule engine on every user selection, resulting in a much bigger payload. But the benefit we get is that we do not have to maintain all previous user selections in memory, thus significantly reducing our memory footprint. Memory requirement for large, complex products reduces by 70+% compared to traditional rule engines.</p><p><strong>3.</strong> <strong>Poor response times</strong></p><p><strong>Traditional Engines:</strong> Lets continue with the product structure of a rack server with 5 rules described in the previous section. When a user selects blade B1, the engine will check the antecedent (if conditions) of all the 5 rules to see if any of them are satisfied. Rule1 &amp; Rule4 satisfy the “if condition” and hence the consequent (Then Processor = P1) is added to the data and item HIGH-AC-PWR-SKU is removed from the domain as it is incompatible with blade B1.</p><p>Since the engine has added a component P1 to the data set, the engine needs to check all the rules again to see if any “if conditions” are satisfied after addition of P1. “If conditions” of all the rules are tested again, and this time, Rule3 satisfies the condition and hence Power Supply = AC-PWR-SKU is added.</p><p>The algorithm needs to test all the rules and its conditions and take action based on the “Then” part of the rule. These actions may add additional components, which may satisfy additional rules, and hence the rule base needs to be searched again and again till it adds no more components to the set.</p><p>A typical rack server will have 7000–8000 available components and 1000–2000 rules written on them. A rack server configuration requires selection of 50–100 components. Every component selection will iterate through and test the rules multiple times. This evaluation of rules for component selections can become expensive from a processing perspective. Traditional rule engines compile rules once, and perform pattern matching and rule execution every time it asserts facts, resulting in very poor performance.</p><p><strong>Our Approach:</strong> Our rule engine works on the principle of “Rules compile and match once, run execution multiple times” versus the traditional approach of “Rules compile once, and match and execute multiple times”. By doing so, our algorithm avoids repeated evaluation of rules for every fact. In addition, we have optimized our code by leveraging libraries such as Trove for hashmaps to save on code execution times. This helps us in improving the performance of our algorithm significantly; resulting in 90+% performance improvements compared to traditional rule engines. 95th percentile response time for the rule engine is ~10 milliseconds.</p><p><strong>4. APIs for 3rd party Integration</strong></p><p><strong>Tradition rule engines</strong> do not expose APIs for integration with other eCommerce platforms. This becomes a limitation for companies that have a large channel partner ecosystem because it does not give their partners the flexibility to transact using B2B APIs.</p><p><strong>Our Approach:</strong> Our rule engine exposes APIs that can work with any 3rd party platform as long as it has the ability to invoke external APIs. Approximately 25% of Cisco revenue is booked by our channel partners leveraging these APIs. We guarantee strong uptime (99.95% uptime) and response time SLAs (95th percentile response time of less than 200 milliseconds) to ensure smooth functioning of our large channel partner ecosystem.</p><p><strong>5. Time to introduce new offers</strong></p><p><strong>Traditional Engines:</strong> Let us consider execution of the value constraint rule. The condition part of the rule 5 has expressions for 2 memory SKUs: M1–256MB &amp; M2–512MB. If we add a 3rd memory SKU M3–128MB, then the existing rule has to be modified as follows. The added expressions are in bold.</p><p><strong>Rule5:</strong></p><p>If count(M1–256MB) &gt; 4 or count(M2–512MB) &gt; 2 or [count(M1–256MB) &gt; 0 and count(M2–512MB) &gt; 1] or [count(M1–256MB) &gt; 2 and count(M2–512MB) &gt; 0] <strong>or count(M3–128MB) &gt; 8 or [count(M1–256MB) &gt; 0 and count(M3–128MB) &gt; 6] or [count(M1–256MB) &gt; 1 and count(M3–128MB) &gt; 4] or [count(M1–256MB) &gt; 2 and count(M3–128MB) &gt; 2] or [count(M1–256MB) &gt; 3 and count(M3–128MB) &gt; 0] or [count(M2–512MB) &gt; 1 and count(M3–128MB) &gt; 0] or [count(M2–512MB) &gt; 0 and count(M3–128MB) &gt; 2] …</strong></p><p>(Condition)<br> then display error: Memory can not exceed 1GB (Action)</p><p>As one can see the number of expressions grow from 4 to 12+ as the number of SKUs increase from 2 to 3. If we have 10 memory SKUs instead of 3, the number of expressions grow exponentially and it is impossible to write and test these rules for accuracy.</p><p>This is true not only for value constraint rules but for other rules as well. Consider a scenario where two more blades B3 and B4 are added as part of a new product introduction. All the blade rules have to be added again two times, once for B3, and once for B4.</p><p>In addition, if we have a line of products in which the product structures and the rules are the very similar with very few minor differences, one has to create a different product structure and rules for each product. This delays the ability to go-to-market with new products quickly.</p><p><strong>Our Approach:</strong> We have addressed manageability of rules by providing the flexibility of defining rules on properties of components instead of components themselves. This not only reduces work when new components are added (you need to define property values for new components instead of adding new rules) and reduces the number of rules one needs to define but it also allows product management teams to create a single model for similar products instead of having to maintain a different model for each product. We can model complex products in 1–2 days compared to 1–2 weeks for tradition configuration rule engines.</p><h3><strong>Conclusion</strong></h3><p>Traditional configuration rule engines run into challenges for complex products such as lack of content management, lack of APIs, high response times and high resource consumption. We have a built a highly scalable rule engine that addresses these pain points and handles configuration of large, complex products very easily.</p><p>It handles 500,000 hits per hour with a 95th percentile response time of ~10 milliseconds with a single JVM with 1GB memory. It scales horizontally and can handle millions of transactions per hour as it is stateless. We sell over 10,000 hardware, software and hybrid products (software licenses as a component of hardware) leveraging our rule engine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a9040bb5c72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Analytics and AI/ML platform for eCommerce]]></title>
            <link>https://dharmeshpanchmatia.medium.com/data-analytics-and-ai-ml-platform-for-ecommerce-68639df89c7f?source=rss-9b8ca7c47367------2</link>
            <guid isPermaLink="false">https://medium.com/p/68639df89c7f</guid>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[event-stream-processing]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Dharmesh Panchmatia]]></dc:creator>
            <pubDate>Fri, 01 Jan 2021 18:17:01 GMT</pubDate>
            <atom:updated>2021-01-01T18:17:01.021Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Objective</strong></h3><p>Cisco’s eCommerce platform is a mission-critical platform responsible for booking $50+ billion in revenue annually. It is live in 150+ countries and in 16 different languages. It has an uptime of 99.95+%, 95th percentile end-user response time of sub 3 seconds, and gets about 11 million hits daily.</p><p>The aim of creating a real-time event streaming analytics platform was to harness the user interactions on the eCommerce platform and provide actionable insights to improve the user experience, drive top-line growth, and optimize margins.</p><h3><strong>Reference Architecture</strong></h3><p>The first step was to determine the technology stack for the analytics platform. The objective was to utilize open source technologies as much as possible and avoid cloud provider lock-in.</p><p>After a comprehensive assessment, we used Matomo, Kafka, Apache Spark Streaming, Apache Spark MLlib, Snowflake, and Twilio as the core technologies for the platform. The high-level architecture diagram is captured below:</p><p>The reference architecture is broken into five tiers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*bNQ75hRROpwkxK7RQrxwGg.jpeg" /></figure><h4>1. <strong>Data Sources</strong></h4><p>The aim of this tier is to capture events from disparate sources. We wanted to capture events from web applications, telemetry data from Cisco products, and events from back-end databases. We leveraged different technologies based on the event source.</p><p><strong><em>eCommerce applications:</em> </strong>We wanted to capture all relevant user actions as they browse and transact on the platform. Since our eCommerce platform consists of many applications, we wanted to leverage a framework that can capture user actions without coding. We used Matomo, an open-source analytics framework to accomplish this goal.</p><p><strong><em>Databases:</em> </strong>We use different persistent stores such as Oracle, MongoDB &amp; Cassandra. We wrote custom adaptors for Oracle and leveraged Kafka adapters for MongoDB &amp; Cassandra for capturing backend data modifications.</p><h4><strong>2.</strong> <strong>Data Ingestion</strong></h4><p>Data ingestion tier ingests events from different event sources and passes them to the enrich tier. We went with Kafka for ingesting events as we have a great deal of in-house Kafka expertise.</p><h4><strong>3.</strong> <strong>Enrich</strong></h4><p>Enrich tier is used to perform real-time transformations and apply business logic across events from multiple sources to provide actionable insights to users.</p><p>We evaluated Apache Spark Streaming and Apache Flink for real-time streaming analytics and even though Flink offered slightly better performance in our evaluation; we went with Spark Streaming as it has a more mature ecosystem and offers better compatibility with Spark MLlib.</p><h4><strong>4.</strong> <strong>Analyze</strong></h4><p>The aim of the analyze tier is to apply AI/ML or deep learning algorithms on real-time events and transaction and reference data to provide machine learning based insights to the users.</p><p>We evaluated Spark MLlib, FlinkML, and Google AutoML. Since FlinkML is not as rich in functionality as MLlib, we decided to use Spark MLlib. MLlib offers advanced features and is extendable with third-party frameworks. We also kept Google AutoML as a second option for machine learning for engineers who may lack a data science background. Google Auto ML is great for users who are not well versed with data science and machine learning.</p><p>We went with TensorFlow for deep learning as we have a few data scientists on the team with TensorFlow expertise.</p><p>We used Snowflake as the persistent store for storing historical transaction data, reference data and events. We went with Snowflake, as it fared well in performance and ability to ingest data in different formats in our evaluation.</p><h4><strong>5.</strong> <strong>Output</strong></h4><p>User insights were delivered via three routes: user notifications, Rest APIs, and analytics dashboards.</p><p><strong><em>User Notifications:</em> </strong>We enabled email, mobile, browser, and WebEx teams notifications for our users.</p><p>o <strong>Email notifications:</strong> We developed a generic framework with pre-defined templates that can send notifications to users in multiple languages.</p><p>o <strong>Mobile Notifications:</strong> We used Twilio for sending notifications to mobile devices as it can handle sending notifications to Android as well as iOS devices.</p><p>o <strong>Browser Notifications:</strong> We leveraged browser APIs from different browsers for sending browser-based notifications.</p><p>o <strong>Reusable notification subscription widget:</strong> We developed a reusable UI widget that any application can leverage to turn on notifications with zero coding. The widget has the intelligence to determine relevant business events a user can subscribe to, based on the application it is part of.</p><p>o <strong>Notification Management Dashboard:</strong> We developed a central dashboard where users can view and manage their notifications across all applications from a single dashboard.</p><p><strong><em>Rest APIs:</em></strong> We developed Rest APIs using Rest/JSON and GraphQL when we wanted to provide real-time insights to users as part of transactional flow within applications.</p><p><strong><em>Analytics Dashboards:</em></strong> We mainly use Tableau for developing analytics dashboards.</p><h3><strong>Use Cases</strong></h3><p>Some key use cases we have implemented leveraging the above platform are:</p><p>1. <strong>Smart Recommendations &amp; Smart Defaults:</strong> We default certain fields and also provide smart recommendations based on historical transactions and past user behavior. We have been able to reduce the number of user inputs required by 50–70% by leveraging this approach.</p><p>2. <strong>Order Anomaly Detection: </strong>Identifying discount outliers using the 3rd standard deviation and interquartile deviation method. The intent is to flag orders with large discounts and plug potential discount leaks.</p><p>3. <strong>Max Capacity Forecasting:</strong> Leverage AI/ML algorithms to forecast when a customer will consume all blade/rack servers in its data center and send real-time notifications to customers, sellers and partners. This can help them by giving more time to procure incremental capacity.</p><p>4. <strong>Customer Churn:</strong> Predict customer churn based on several factors such as underconsumption of software licenses, transaction history, and the number of support cases created by customers.</p><p>5. <strong>Product Trending: </strong>Product trending over time and popular product configurations for products by geography &amp; market segment to help engineering teams optimize pre-defined product configurations.</p><p>6. <strong>Order Status Notifications: </strong>Real-time notifications to sellers and customers anytime the status of their order changes. We have also enabled the option of sending a single digest of status changes for all their orders to users.</p><p>We are pleased with the results of our analytics platform so far. The platform can scale to millions of events without a degradation of performance. Our objective is to double down on implementing analytics and AI/ML use cases next year to transform our eCommerce platform further by improving user experience and user productivity significantly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68639df89c7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>