<?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 Mohamad Assaf on Medium]]></title>
        <description><![CDATA[Stories by Mohamad Assaf on Medium]]></description>
        <link>https://medium.com/@mohammad.assaf?source=rss-6439b21cb992------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZsRIia-89-rwdudlFPiCdg.jpeg</url>
            <title>Stories by Mohamad Assaf on Medium</title>
            <link>https://medium.com/@mohammad.assaf?source=rss-6439b21cb992------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:29:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohammad.assaf/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[Canary releasing approach for an Azure-hosted eCommerce application]]></title>
            <link>https://medium.com/@mohammad.assaf/canary-releasing-approach-for-an-azure-hosted-ecommerce-application-946771a3b9f9?source=rss-6439b21cb992------2</link>
            <guid isPermaLink="false">https://medium.com/p/946771a3b9f9</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[canary-release]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Mohamad Assaf]]></dc:creator>
            <pubDate>Wed, 22 Oct 2025 10:45:56 GMT</pubDate>
            <atom:updated>2025-10-22T10:45:56.396Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Disclaimer: Platform or product mentions should not be interpreted as an endorsement, recommendation, or preference for one provider over another. McKinsey maintains an open ecosystem of technology providers and references herein are illustrative, meant only to highlight potential avenues rather than prescribe specific solutions.</em></p><p><strong>By Stephane Bout, Omar Dayi, Sallah Kokaina, and Mohamad Assaf</strong></p><p>Today’s tech users expect constant innovation and zero incidents. Engineering teams are under pressure to deliver new features quickly, but can’t risk widespread incidents. To keep up, engineers need to roll out new versions in a controlled, seamless way; testing with real users and real traffic, but only exposing changes to a small segment at first. This lets teams catch and fix issues early, without disrupting the broader customer base, which is critical given the complexity and unpredictability of modern platforms.</p><p>Having gradual releasing, or canary releasing (for the rest of the article), gives the advantages below:</p><ul><li>Canary releasing (our focus in this article), offers several advantages</li><li>Reduces the blast radius of incidents and regressions by initially targeting a limited audience</li><li>Allows early measurement of performance metrics (latency, crash rate, errors)</li><li>Builds confidence by collecting user feedback before scaling to full production</li></ul><p>In this article, we show how canary releasing directly shapes the backend setup, testing process, branching strategy, and monitoring. Each of these areas brings its own challenges, namely <strong>running multiple versions in parallel, ensuring compatibility, managing safe rollouts, and observing new versions before scaling</strong>. We solved these challenges in our implementation and describe them here.</p><h4><strong>Our Case</strong></h4><p>Our platform is a <strong>B2B eCommerce application</strong> with 25,000+ business users who rely on it to order their shop’s inventory. Given its role in daily operations and revenue generation, any outage — especially during peak morning hours — can have significant financial consequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*4QUDC8c_FLFaG3adyqxgQQ.png" /><figcaption><em>Figure 1: application architecture of B2B eCommerce application</em></figcaption></figure><ol><li><strong>Frontend:</strong> A mix of mobile and web applications, built using React Native (via Expo) and ReactJS. Our focus is on the primary Android-based customer-facing app. Applications integrated with Firebase to fetch configuration and send analytics.</li><li><strong>Backend:</strong> A NestJS application hosted on <strong>Azure App Service</strong>, following a modular monolith design.</li><li><strong>Commerce core:</strong> A SaaS platform that manages customer accounts, product catalogs, and order fulfillment.</li></ol><h4><strong>Canary Releasing Setup</strong></h4><p>We based our approach on three principles:</p><ol><li><strong>Gradual rollout</strong> of new versions to a subset of users</li><li><strong>Minimal-cost, efficient architecture</strong> with isolated critical services</li><li><strong>Separate monitoring</strong> to prevent and detect incidents between versions</li></ol><h4><strong>Mobile app release flow</strong></h4><p>Google Play Store (and Apple App Store) allows <strong>partial rollouts</strong>. We started each rollout with 20% of users. Google selects these users randomly, but keeps them consistent across future partial releases.</p><p>We used <strong>Firebase Remote Config</strong> to dynamically control backend URL routing per version. The config variable react_application_url was defined as JSON:</p><pre><br>{<br> “1.0”: main.azure.com<br> “2.0”: staging.azure.com<br>}</pre><p>The config is automatically pulled on application load (on load of the App.tsx component). The variable is inspected, and the right URL is selected by matching the current app version with the key in the parsed JSON. Internet is required to load the app initially, in case of no internet, an offline screen is displayed asking the user to check internet connection.</p><p>This allowed each app version to call the correct backend, without needing to release a new app for routing updates.</p><p>Worth nothing the importance of force update for unsupported mobile app versions. It is implemented using firebase remote config in a similar manner. An array of supported versions is defined on remote config, pulled on App.tsx component load, then checked versus current application version, and finally displaying a force update screen if the version is not in the array. This step was crucial to prevent the use of outadated</p><h4><strong>Azure App Service Configuration</strong></h4><p>We used <strong>deployment slots</strong> in Azure App Service:</p><ul><li>Each slot had its own URL, registered in API Gateway.</li><li><strong>Staging slot</strong> hosted the new backend version.</li><li><strong>Main slot</strong> served the existing stable backend.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*0yevO8egWPULaPLleRN7aw.png" /><figcaption><em>Figure 2: diagram of application and backend canary configuration</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*K-ymllnSNDzZX9t4vJ4Vpw.png" /><figcaption><em>Figure 3: shared Postgres database system, along with separated resources (on the right)</em></figcaption></figure><p>To reduce cost, both slots shared resources, except for:</p><ul><li>Redis cache (Azure Redis)</li><li>Configuration store (Azure App Configuration)</li><li>Messaging queue (Azure Service Bus)</li></ul><p>The key challenge: both backend versions shared the same <strong>database</strong>, requiring <strong>backward-compatible migrations</strong> to avoid breaking the live version when rolling out a new one.</p><p>To address this, we enforced <strong>strict backward compatibility review</strong> for database migrations. This happened at the PR review step (both in development, and when promoting environments), by inspecting any changes done to the “migrations” folder (TypeORM migrations were used). A required reviewer is automatically added when a change is done there (through Azure DevOps settings)</p><ul><li>No destructive operations (e.g., column drops or type changes)</li><li>Only additive schema changes were permitted (e.g., adding new tables, columns, or indexes)</li><li>Default values or fallbacks were included to prevent breaking existing logic</li></ul><p>A side-effect of the above is a <strong>bloated database schema</strong> with many unused columns. To address this, we planned <strong>column/table decomissions in later versions</strong>. For example: if column A is used by version 1.0, and has been kept to preserve the compatibility of versions 1.0 with 2.0, then column A is planned to be decommissioned on version 3.0 (since 2.0 does not use it).</p><p>As an additional QA step during sign-off, both backend versions were tested in parallel against the shared database to validate cross-version compatibility before production rollout, to be discussed further in later sections.</p><h4><strong>Branching strategy</strong></h4><p>We considered two approaches in Azure DevOps:</p><h4>Option 1: Separate production branches</h4><ul><li>main deployed to the main slot</li><li>staging deployed to the staging slot<br>This allowed isolated hotfixes for each slot.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*JiyS50Sam7GYmzar86CdSQ.png" /><figcaption><em>Figure 4: descriptive diagram for 2 separate branches</em></figcaption></figure><p><strong>Option 2: Unified branch with promotion</strong></p><ul><li>Single branch deployed to staging</li><li>Azure App Service promotion swaps staging → main<br>This is simpler but limits hotfixes during the canary period.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*6eY0nCxHPV0LgLobZFvSEQ.png" /><figcaption><em>Figure 5 descriptive diagram for a 1 branch approach</em></figcaption></figure><p>We chose <strong>option 1</strong> for flexibility and risk mitigation.</p><p><strong>Testing compatibility</strong></p><p>With two backend versions running in parallel, <strong>UAT testing</strong> needed to be more rigorous. We tested:</p><ul><li>New features and flows on the staging slot</li><li>Backward compatibility with the existing production version</li><li>Side-effects on other dependent applications</li></ul><p>This was enforced through a UAT checklist and architecture mimicking production before go-live.</p><p>Sign-off required testing the old and new versions in parallel in UAT before approving rollout.</p><h4><strong>Monitoring and observability</strong></h4><p>Monitoring was critical throughout the canary rollout. We used:</p><ul><li><strong>Azure Application Insights</strong> for backend telemetry (requests, dependencies, exceptions, and events)</li><li><strong>Firebase Crashlytics and Performance Monitoring</strong> for mobile app health</li></ul><p>This setup enabled us to:</p><ul><li>Compare latency and error rates between backend versions</li><li>Monitor screen load time and API response time on mobile</li><li>Set SLOs (e.g., error rate &lt; 1%, P95 latency &lt; 500ms) and block rollout if breached</li></ul><p>To differentiate versions in logs and traces, we used an environment variable referenced in openTelemetry, appended as a custom dimension in App Insights traces. Querying in KQL based on this parameter allowed monitoring the 2 versions separately</p><p>Firebase also plotted crash/performance charts by app version:</p><ul><li>Each version appeared as a separate line on charts</li><li>Alerts were triggered per version</li><li>Engineers could filter and debug metrics by app version</li></ul><p><strong>Conclusion</strong></p><p>Canary releasing enabled us to <strong>reduce risk</strong>, <strong>catch regressions early</strong>, and <strong>optimize user experience</strong> before scaling. By leveraging <strong>Azure App Service slots</strong> and <strong>Firebase Remote Config</strong>, we gained fine-grained control over traffic, observability, and rollout cadence — across both mobile and backend layers.</p><p>As systems grow in complexity, such practices are no longer optional — they are <strong>essential</strong> to ensure resilience, agility, and user trust.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=946771a3b9f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case study on performance testing of a large-scale application]]></title>
            <link>https://medium.com/@mohammad.assaf/case-study-on-performance-testing-of-a-large-scale-application-ca7a4e5f0c51?source=rss-6439b21cb992------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca7a4e5f0c51</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[k6]]></category>
            <category><![CDATA[performance-testing]]></category>
            <dc:creator><![CDATA[Mohamad Assaf]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 16:12:18 GMT</pubDate>
            <atom:updated>2024-09-29T16:12:18.009Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8uFbhw66rkAb_YWvYET7A.jpeg" /></figure><p><strong>By Erdem Senol, Pablo Taboas, Sallah Kokaina, and Mohamad Assaf</strong></p><p>Refer to our previous article</p><ul><li>Introduction to performance testing in modern large-scale applications <a href="https://medium.com/@mohammad.assaf/introduction-to-performance-testing-in-modern-large-scale-applications-830201f0a33b">here</a></li><li>Performance testing POC for large-scale applications using K6 <a href="https://medium.com/@mohammad.assaf/performance-testing-poc-for-large-scale-applications-using-k6-228ca7ed3732">here</a></li></ul><h4>Context for case study</h4><p>We ran performance testing on a retail banking application serving 2+ million customers. The application followed the architecture below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*QpX6DxfhZJpatjvB-kae2Q.png" /><figcaption>Figure 1 high level architecture of application</figcaption></figure><p>The application is a revamp of an existing bank application, reusing existing services, while also migrating some features to a new service-oriented architecture using an enterprise service bus (ESB). Frontend is a mobile and web application, developed using react-native-web. The backend is a set of NestJS microservices integrating with the existing application backend directly, and with core systems through a SOAP integration layer. It’s hosted on an on-prem OpenShift cluster.</p><p>The third-party systems are mostly legacy systems, and they are operational on the production environment</p><p>Below are the non-functional requirements</p><p>Load testing</p><ul><li>Concurrent users: 6,000</li><li>Duration: 1 hour</li></ul><p>Endurance testing</p><ul><li>Concurrent users: 3,000</li><li>Duration: 12 hours</li></ul><p>Tool used: K6 load testing (https://k6.io) please refer to the K6 article in this series</p><h4>Approach &amp; setup</h4><p>The application stack (along with third party systems) is hosted in a separate performance testing environment. In OpenShift, a separate namespace is created with a bigger pool of physical resources, to allow fine tuning our deployments to reach the optimal resource allocation.</p><p>Third-party systems were configured to be production-like in terms of allocated physical resources and configuration.</p><p>1 GitLab runner with 2 CPU cores and 4 GB of RAM was allocated to host K6 and run the performance testing scenarios. The GitLab runner was hosted inside a special OpenShift namespace that holds DevOps tools. K6 pushed metrics to a Prometheus instance, where a Grafana dashboard would read the data and display them to report the results. Below is an illustrative diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*4B7COR97OE468Ip6Im7Zxw.png" /><figcaption>Figure 2 performance testing process</figcaption></figure><p>Once the tester makes a push into the load testing repository, they can run the test stage (typically manual). It will use the K6 runner, call APIs that are on the application namespace, and measure and publish the metrics on the Prometheus instance. The data is visualized on Grafana. Below is an example view</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Y-vsa1lVs7sLW7GZoL0CXA.png" /><figcaption>Figure 3 Grafana dashboard to visualize and analyze results</figcaption></figure><p>More details on analyzing results charts is outlined in the K6 article of this series.</p><h4>Common challenges we faced while running our performance test cases</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__Xoic_gVoOGUB6Ed76LLA.png" /></figure><p>We will discuss each in detail.</p><h4>1- Extra load on downstream systems</h4><p><strong>Observation<br></strong>By inspecting our API traces, we noticed that our backend is fetching information from third party before they are needed, which was required by user experience designers</p><p><strong>Examples<br></strong>The Frontend would require to know if a user is eligible to perform operation “open a new account”, to let the user know when they enter the journey. For this purpose, it calls the Backend, which in turn has to call a third party API to get the user’s permission</p><ul><li>Design 1 (better user experience, more expensive)<br>The backend gives the information on login. this provides a fast user experience as user immediately gets a pop up when he tries to perform the operation, because the permission is cached on login</li><li>Design 2 (slightly worse user experience, more performant)<br>The Frontend will call the Backend when the user tries to enter open new account journey. Now the call to downstream systems is significantly offloaded from the initial login data fetch. The user will wait a bit when he makes the call to action to enter the journey, then gets the pop up</li></ul><p><strong>Solution<br></strong>Follow a ”lazy fetching” approach whenever optimal user experience incurs performance issues. Make information fetching journey-specific, instead of fetching them before they are needed. Slightly worsening the user experience might largely improve performance. In our case, the downstream systems were breaking when we try to fetch this permission on login, because it had complicated business logic. We made the user wait for around 500ms when entering the journey, in exchange for a healthier system on production</p><h4>2- Bottleneck in connection pools between systems</h4><p><strong>Observation<br></strong>On ramp-up, after reaching a specific threshold, a spike in response time is observed, the spike may recover and then it reappears again. No meaningful resource utilization is observed on the whole stack, including the database</p><p><strong>Illustration</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*G4hAwdOB_o3U6QNDUiiQVg.png" /><figcaption>Figure 4 connection bottlenecks in red</figcaption></figure><p>Response times spike when pools are exhausted</p><p>The DB can have faulty configuration to limit the number of connections it can accept. Or the number of HTTPS connections to System 1 might be exhausted.</p><p>While all systems have normal resource (CPU, RAM) utilization, the bottleneck and latency might come from waiting for an available connection</p><p>Please find below an example report</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*4Z66RQCV9wkFa5OGgJ5f0Q.png" /><figcaption>Figure 5 spikes observed in the test due to database connection pool exhaustion</figcaption></figure><p>The green line is the average response time. We can see spikes happening across the test with 2 large ones</p><p><strong>Solution<br></strong>Keep-alive HTTPS connections wherever possible (by setting the header). This reduces latencies, and removes the overhead of establishing and destroying connections. Also, look into all database connections and ensure the configured limits satisfy the required performance criteria</p><h4>3- Leverage Kibana tracing to help identifying performance bottlenecks</h4><p><strong>Observation<br></strong>A backend API exhibits performance issues. The given API is complex and involves making multiple service calls to downstream systems</p><p><strong>Illustration</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*UlLAo0_CiricT-pjMwaDYQ.png" /><figcaption>Figure 6 an example where an API would require backend to call resources from different systems</figcaption></figure><p>Consider the diagram above. There is no resource exhaustion on the backend. The overall API that calls multiple systems (can be more than 2) has a slow response. One of the systems has a low response, slowing down everything. This can grow complex to identify without proper tooling</p><p><strong>Solution<br></strong>Setup tracing in Kibana, for example, OpenTelemetry will collect metrics on all API calls made in our infrastructure, with detailed traces, and durations. We can navigate to /api-request in Kibana, inspect the traces, and identify the source of delay. It will show every single action our backend makes to fulfill the request. Below is an example Kibana trace of a simple API (calling only 1 other system, which is shown in blue)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Ls4IQ2dvidUMRp9Bt0Qa2A.png" /><figcaption>Figure 7 trace of a GET API</figcaption></figure><p>The trace shows execution time, step by step, in backend code. Different bar colors means this trace is from another instance (or Pod). We can click on a given step and get more details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*nn59xAIPDrXsVjFBNqhPPw.png" /><figcaption>Figure 8 trace details of a step</figcaption></figure><p>We click on the before last step <em>(POST 139ms)</em> and we see it’s an external network request showing the URL (redacted), and how much time it took. When there are multiple systems involved, more bars with different colors will appear, helping us track times on a granular level and identify non-performant parts of the API flow.</p><h4>4- Setup environment resources and configuration to be production-like</h4><p><strong>Observation<br></strong>Slowness in the system and spikes in response time, cause by an exhaustion of resources in one of the systems on the stack</p><p><strong>Illustration</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*HrUMRsdi7LujL3DyjAJBTw.png" /><figcaption>Figure 9 some systems may not have production-like configuration (physical or software)</figcaption></figure><p>In our case, all third-party systems had production-like configurations, except the integration layer and the database which were missed.</p><p>Significant amount of troubleshooting went into identifying this issue, especially the database resource issue because its impact was deep into the stack</p><p><strong>Solution<br></strong>Start preparing performance testing environment early on, and inspect all systems carefully before starting. Software configurations (like limits on CPU and RAM, limits on connections, etc ..) can also impact, which need to be checked alongside physical resources available</p><h4>5- Prepare testing data that are production-like</h4><p><strong>Observation<br></strong>crashes during the test, or slower or faster than expected response times with no clear reason</p><p><strong>Illustration</strong></p><ul><li><strong>Case 1: Faulty user data<br></strong>One of the test cases is money transfer, which some users may not have the permission to do so, and will not have access to the journey in the app. If included in the dataset, these users will result in 400s and 500s responses that reduce the quality of the performance test</li><li><strong>Case 2: biased user data<br></strong>Customers belong to 4 different segments (segment 1, 2, 3, and 4). To do a money transfer for a user in segment 4, we would have to additional checks, hence it would take more time. On production, 5% of users belong to segment 4, hence having 50% of users in segment 4 during performance test will give slow average response times. It’s important to mimic production customer base</li></ul><p><strong>Solution<br></strong>Commit extra time and resources to filter the data and ensure correctness. In our case, we built python scripts that looped through the users, fetched user info and filtered out inadequate users, and constructed user categories that are production-like. Smoke tests are also run before running a full perf test</p><h4><strong>Conclusion</strong></h4><p>Performance testing can help simulate real life usage of the application and identifying non-performant code or APIs early in the process, and have more confidence about the resilience of the application when going live. Using the right tools and investigating the right points of failure can help speed up improving performance and reaching the optimal user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca7a4e5f0c51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance testing POC for large-scale applications using K6]]></title>
            <link>https://medium.com/@mohammad.assaf/performance-testing-poc-for-large-scale-applications-using-k6-228ca7ed3732?source=rss-6439b21cb992------2</link>
            <guid isPermaLink="false">https://medium.com/p/228ca7ed3732</guid>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[k6]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Mohamad Assaf]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 15:20:09 GMT</pubDate>
            <atom:updated>2024-09-29T15:20:09.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*uzVtquVT0jGfbNAf7Qc1UQ.gif" /></figure><p><strong>By Erdem Senol, Pablo Taboas, Sallah Kokaina, and Mohamad Assaf</strong></p><p>Refer to our previous article</p><ul><li>Introduction to performance testing in modern large-scale applications <a href="https://medium.com/@mohammad.assaf/introduction-to-performance-testing-in-modern-large-scale-applications-830201f0a33b">here</a></li></ul><h4>What is K6</h4><p>K6 is a way to conduct performance tests. it’s an open-source framework, developed using Go. K6 provides multiple types of performance tests to test applications, including load testing, browser testing, and resilience testing. It also provides SaaS solutions to run distributed load testing.</p><p>K6 has an advantage of efficiency where it can simulate a large number of simultaneous users with limited resources, which is convenient for organizations that use cloud or on-prem Kubernetes-based infrastructures</p><p>other reasons why we used K6 include</p><ul><li>Easy to integrate with Grafana for visualizing results, with various dashboards available from the community</li><li>Test-As-Code where test cases can be developed and customized as scripts</li><li>Easy to integrate with CI/CD pipelines where developers can run load tests early in the software delivery process</li></ul><h4>How to setup K6</h4><p>We provide the POC below which can bootstrap conducting performance tests</p><p><a href="https://github.com/mohamadassaf96/perf-testing-poc">https://github.com/mohamadassaf96/perf-testing-poc</a></p><p>To run performance tests, the following needs to be prepared</p><ul><li>Have test users ready in form of a JSON file (username and password)</li><li>Prepare Required performance targets (for both endurance and load), along with the scenarios. For example, 10,000 concurrent logins, 2,000 concurrent users doing scenario X, 3,000 doing scenario Y, for a 1-hour duration</li></ul><h4>Code structure</h4><p>Automated performance test cases should be treated as production software, it should be maintainable, and this requires applying common architecture patterns</p><p>The code has 3 components</p><ul><li>Actions: this is where API calls are written (such as login)</li><li>Scenarios: this is where user journeys are written (user login, then get homepage data, then execute action), using the actions above as components</li><li>Main file: this where scenarios to run are listed, one by one</li></ul><p>The code structure is provided in the repo’s readme.</p><p>In the <em>infra/</em> folder, we include a docker compose file that launches Prometheus and Grafana locally to visualize the results. K6 will call APIs and push results into the Prometheus DB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*-5pqUUOydZfxIUdNHrcxNw.png" /><figcaption>Figure 1 architecture of performance testing asset</figcaption></figure><p>We give an example to run a load test on a dummy login endpoint, with 20 users, for 5 minutes. Please refer to the repository for the code</p><p><strong>Step 1: test users</strong><br>We prepare our test users and we insert them into data/users.json in a from of a JSON file</p><p><strong>Step 2: Define the APIs<br></strong>In actions/login, we define our API call, that will take a username and a password, and make the call to the remote API. We also define the sign out API</p><p><strong>Step 3: Define scenario<br></strong>In scenarios/login, define the execution function of the scenario (login the user, then sign out), along with the executor type. K6 provides various executors (https://k6.io/docs/using-k6/scenarios/executors/)</p><p><strong>Step 4: Build &amp; Run<br></strong>Define in main execution file (load.ts), build and run using the following commands</p><p>Launch Grafana and Prometheus locally using docker-compose</p><pre>cd infra/<br>docker-compose up -d</pre><p>In repository’s root, execute the below</p><pre>export K6_PROMETHEUS_RW_PUSH_INTERVAL=&quot;2s&quot; #push metrics every 2 seconds<br>export K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=&quot;true&quot; #push data to Prometheus as native histogram to visualize on Kibana<br>yarn build<br>k6 run - insecure-skip-tls-verify - tag testid=poc-111 - tag type=ms -o experimental-prometheus-rw dist/load.js #testid helps picking the test in Grafana. This is helpful when having multiple tests. -o specifies the output format</pre><p>Please note that the default Prometheus endpoint in K6 is localhost:9090</p><p>After that, we access Grafana on localhost:3000 (please refer to docker compose file) and we can visualize the report, as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Y-vsa1lVs7sLW7GZoL0CXA.png" /><figcaption>Figure 2 example performance test ran on a login endpoint</figcaption></figure><p>On Grafana we can see the total requests made <em>(4456 requests)</em>, and the P95 response time <em>(95.49ms)</em>. The charts shows us key metrics, such as</p><ul><li><strong>Active VUs</strong>: number of users in parallel</li><li><strong>Requests rate</strong>: number of requests per second. We can see the test ramps up at first, maintains a constant request rate, then ramps down</li><li><strong>Average response rates</strong>: key metric that measures the average response time of a given API, during a given duration (we define as 2s in the env variable)</li></ul><h4>How to integrate with CI/CD</h4><p>Running performance tests in CI/CD pipelines is straightforward. The following are the requirements</p><ul><li>Prometheus i and Grafana instances running</li><li>A runner with the necessary libraries installed (Node &amp; K6), with network access to Prometheus</li></ul><p>In the pipeline, the above commands can be run to execute the tests, while only altering the URL of the Prometheus API using the env variable below</p><blockquote>export K6_PROMETHEUS_REMOTE_WRITE_URL=”http://your-prometheus-server-url:port/api/v1/write&quot;</blockquote><h4>Conclusion</h4><p>To achieve the goals of application performance, it’s important to integrate performance testing in the process, similarly to unit testing and e2e testing. Frameworks like K6, that are cloud native and code-based, make it easy for developers and QAs to conduct performance testing and integrate it with the CI/CD pipeline, which allows seamless integration with the SDLC for better software quality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=228ca7ed3732" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to performance testing in modern large-scale applications]]></title>
            <link>https://medium.com/@mohammad.assaf/introduction-to-performance-testing-in-modern-large-scale-applications-830201f0a33b?source=rss-6439b21cb992------2</link>
            <guid isPermaLink="false">https://medium.com/p/830201f0a33b</guid>
            <category><![CDATA[performance-testing]]></category>
            <dc:creator><![CDATA[Mohamad Assaf]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 14:29:34 GMT</pubDate>
            <atom:updated>2024-09-29T14:29:34.046Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbZkLkcZ5Nu4j2afQY5bHA.jpeg" /></figure><p><strong>By Erdem Senol, Pablo Taboas, Sallah Kokaina, and Mohamad Assaf</strong></p><p>Following best practices, technology is built backwards starting with the customer, and then building our products. Consumers nowadays have low patience for slow loading products, which is driving the need to build faster products, along with the market competitiveness providing users with plenty of options. Given the complexity of modern applications, it’s important to have an effective and automated performance testing process to measure the performance of our application and identify bottlenecks to enhance the user experience.</p><p>Developing large scale systems often presents the following challenges</p><ul><li>Dependencies on third party systems that might not scale with our request rate</li><li>Inefficient data flow, such as retrieval of redundant data</li><li>Faulty code that puts pressure on instance resources</li></ul><p>Adding the additional performance testing step creates an additional challenge on developers to balance between quality of software and the frequency of releases. Hence, it’s important to have a robust performance testing process with the right tooling.</p><p>In this series of articles on performance testing, we introduce important performance testing concepts, describe an approach to conduct performance testing with CI/CD integration, and finally walk through a case study testing the performance of a large-scale application service 2+ million customers.</p><h4>Performance challenges in complex systems</h4><p>Large scale distributed systems can grow complex, often involving multiple components, where some are outside the control of the developer (such as 3rd party systems)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*X8oj_n2G2lupSNl0RJ7z3w.png" /><figcaption>Figure 1 Example architecture of a large-scale distributed system</figcaption></figure><p>Each level of the architecture above requires a different approach for performance testing. For example, for the frontend and user interface, we can use profiling available in web browsers, and in native IDEs such as Xcode and Android Studio. APIs, backend services, database, and infrastructure, with large number of closely interacting and interdependent components, create the need for a variety of tools and infrastructure assets to conduct performance testing.</p><p>With the increasing complexity of systems, several symptoms can be observed that indicate performance issues</p><ul><li><strong>Long startup time</strong>: Initial time it takes to render a website or start a mobile application, after common assets are loaded is longer than a few seconds</li><li><strong>Poor response time</strong>: The time it takes for an application to respond after the user submits data or performs an action is very long causing users to lose interest</li><li><strong>Client-side errors incl. dropped/reset sessions</strong>: The server cannot handle an increased request volume therefore returning errors (e.g., HTTP 5xx) and/or timing out leading to reduced user satisfaction/trust</li></ul><p>Typical causes that create the observed symptoms include</p><ul><li><strong>Low scalability</strong>: The application can’t handle growth in users or parallel requests and starts to degrade, responding slowly or returning errors (e.g., HTTP 5xx) potentially causing data integrity issues</li><li><strong>Lack of resources</strong>: The applications performance is degraded on web/mobile device or server-side due to over-utilized systems, networks or non-optimal code lacking proper usage and cleanup of resources (e.g., CPU or Memory utilization, disk usage, limitations of the operating system etc.)</li><li><strong>Bottlenecks</strong>: Longer time taken by server-side systems to handle requests due to architectural bottlenecks (e.g. limited connection pools in db or http) leading to excessive client-requests queueing and thus a degraded client experience</li></ul><h4>Establishing performance testing practices</h4><p>Highly mature organizations adopt a performance testing culture which incorporates these concerns into the daily actions across three key dimensions:</p><ul><li>Process</li><li>Technology</li><li>People &amp; Culture</li></ul><blockquote>Process</blockquote><ul><li>Defined Service Level Objectives (SLOs): SLOs for response time, throughput and scalability are defined and enforced by the agile software delivery process</li><li>Test infra embedded CI/CD pipeline: Development team code changes automatically triggering load tests in CI/CD pipeline as a required step before production deployment</li><li>Involvement of all impacted departments: Agile collaboration where all teams coordinate and troubleshoot together to identify performance issues</li></ul><blockquote>Technology</blockquote><ul><li>Productized tools: Internal or external productized performance testing tools for self-service adoption by app teams. Include wide-spread documentation and examples</li><li>Dedicated environment: Dedicated performance testing environment managed through Infrastructure as Code (IaC) on parity with production for effective execution of scripted test cases during the CI/CD process</li></ul><blockquote>People &amp; Culture</blockquote><ul><li>Distributed ownership: Product teams have full responsibility &amp; accountability for quality assurance of their products</li><li>Test knowledge embedded teams: Teams built with embedded knowledge and expertise on performance testing practices as an enabler of agile software delivery</li></ul><h4>Types of performance testing</h4><p>There are various test types of performance testing that applications need to pass to ensure optimal user experience</p><ul><li><strong>Load test</strong></li><li><strong>Stress test</strong></li><li><strong>Endurance test</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zNFD9WazEzTRH2_vI9cBA.png" /><figcaption>Figure 2 Types of performance testing</figcaption></figure><h4>Conclusion</h4><p>In later articles in this series, we will deep-dive into more technical topics, by providing a way to setup a performance testing tool and integrate it with CI/CD, and also provide a case study from a real context.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=830201f0a33b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>