<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sonu Jangra</title>
    <description>The latest articles on Forem by Sonu Jangra (@im_sonujangra).</description>
    <link>https://forem.com/im_sonujangra</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2790874%2F8563caea-a331-47b3-915d-a7fec41f9e6a.png</url>
      <title>Forem: Sonu Jangra</title>
      <link>https://forem.com/im_sonujangra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/im_sonujangra"/>
    <language>en</language>
    <item>
      <title>The Secret Sauce to Building Scalable Systems</title>
      <dc:creator>Sonu Jangra</dc:creator>
      <pubDate>Fri, 31 Jan 2025 15:10:09 +0000</pubDate>
      <link>https://forem.com/im_sonujangra/the-secret-sauce-to-building-scalable-systems-4920</link>
      <guid>https://forem.com/im_sonujangra/the-secret-sauce-to-building-scalable-systems-4920</guid>
      <description>&lt;p&gt;Scalability in system design refers to the capability of a system to handle growing amounts of work or accommodate increased user traffic without sacrificing performance. It ensures that as demand grows, the system can maintain efficiency, speed, and reliability.&lt;/p&gt;

&lt;p&gt;Imagine a restaurant that starts with just a few tables and a single chef. As more customers arrive, the restaurant can add more tables, hire additional chefs, or even open new branches to handle the increasing demand without compromising service quality. In the digital world, scalable systems work similarly—they adapt to increasing demands seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Can a System Grow?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are different ways a system can grow to handle increased demands. Let's break them down with unique examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Vertical Scaling (Scaling Up)&lt;/strong&gt;&lt;br&gt;
This involves adding more resources (CPU, RAM, storage) to an existing server.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Upgrading the kitchen equipment to cook more meals at the same time.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A database server upgraded with more memory to handle larger datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Horizontal Scaling (Scaling Out)&lt;/strong&gt;&lt;br&gt;
Adding more servers to distribute the workload.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Adding more dining areas and hiring additional chefs to serve more customers simultaneously.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A social media platform adding more servers to support millions of concurrent users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Scale a System&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Load Balancing&lt;/strong&gt;&lt;br&gt;
Distributes incoming traffic across multiple servers to ensure no single server is overwhelmed.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Assigning customers to different waiters based on table availability to ensure efficient service.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; An online ticketing system using NGINX to balance traffic during the launch of a popular event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Database Scaling&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Vertical Scaling:&lt;/strong&gt; Upgrading the database hardware.&lt;br&gt;
&lt;strong&gt;Horizontal Scaling:&lt;/strong&gt; Partitioning the database to distribute data.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Splitting kitchen tasks between different chefs for efficiency.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A global e-commerce platform partitioning customer data by geographic regions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Caching&lt;/strong&gt;&lt;br&gt;
Storing frequently accessed data in memory for faster retrieval.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Preparing popular dishes in advance to reduce waiting times.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A news website caching headlines to reduce database queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Microservices Architecture&lt;/strong&gt;&lt;br&gt;
Breaking down a monolithic application into smaller, independent services.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Assigning different chefs specialized in appetizers, main courses, and desserts.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A ride-sharing app with separate services for driver matching, payments, and notifications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Content Delivery Network (CDN)&lt;/strong&gt;&lt;br&gt;
Distributes static content across geographically dispersed servers.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Setting up multiple beverage stations throughout the restaurant to serve drinks faster.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A video streaming platform using a CDN to deliver content globally with minimal buffering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Auto-scaling&lt;/strong&gt;&lt;br&gt;
Automatically adjusts the number of server instances based on demand.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Calling in additional staff during busy dinner hours.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A retail website automatically scaling up server instances during Black Friday sales.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Message Queues and Asynchronous Processing&lt;/strong&gt;&lt;br&gt;
Handling tasks asynchronously to avoid blocking operations.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; A restaurant pager system that notifies customers when their table is ready.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; An email marketing service queuing bulk email sends to avoid system overload.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Monitoring and Alerts&lt;/strong&gt;&lt;br&gt;
Tracking system performance to detect bottlenecks and trigger scaling actions.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Having a manager monitor table turnover and kitchen efficiency to adjust staffing.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A cloud service provider using Prometheus and Grafana to monitor system health.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Stateless Services&lt;/strong&gt;&lt;br&gt;
Designing services that do not maintain session state, making them easier to scale.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Self-service kiosks where customers place orders independently.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; An API gateway handling thousands of requests independently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Containerization and Orchestration&lt;/strong&gt;&lt;br&gt;
Using containers for application deployment and orchestration tools to manage scaling.&lt;br&gt;
&lt;strong&gt;Example:&lt;/strong&gt; Portable food stations that can be quickly set up during food festivals.&lt;br&gt;
&lt;strong&gt;Use Case:&lt;/strong&gt; A microservices-based application running on Kubernetes clusters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best Practices for System Scalability&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Plan for Scalability from the Start: Build systems with scalability in mind to avoid costly refactoring.&lt;/li&gt;
&lt;li&gt;Optimize Before Scaling: Identify and optimize bottlenecks before scaling resources.&lt;/li&gt;
&lt;li&gt;Use Distributed Architectures: Favor distributed systems for better scalability and fault tolerance.&lt;/li&gt;
&lt;li&gt;Leverage Cloud Services: Cloud providers offer scalable infrastructure and managed services.&lt;/li&gt;
&lt;li&gt;Monitor Continuously: Regularly monitor system performance and resource utilization.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>softwareengineering</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React vs Svelte: A Performance Benchmarking</title>
      <dc:creator>Sonu Jangra</dc:creator>
      <pubDate>Thu, 30 Jan 2025 12:54:39 +0000</pubDate>
      <link>https://forem.com/im_sonujangra/react-vs-svelte-a-performance-benchmarking-33n4</link>
      <guid>https://forem.com/im_sonujangra/react-vs-svelte-a-performance-benchmarking-33n4</guid>
      <description>&lt;p&gt;In the world of frontend frameworks, React and Svelte are two of the most popular choices among developers. React, with its large ecosystem and community, has been a dominant player in the JavaScript landscape for years. On the other hand, Svelte, a newer and more innovative framework, offers a fresh approach by shifting much of the work from the browser to compile time. In this blog post, we’ll dive deep into a performance benchmarking comparison of React vs Svelte, examining key metrics such as load time, rendering performance, bundle size, and memory usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Makes Svelte and React Different?&lt;/strong&gt;&lt;br&gt;
Before jumping into the benchmark results, let’s quickly understand the primary difference between React and Svelte:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React:&lt;/strong&gt; React is a component-based UI library that uses a virtual DOM to update the UI efficiently. It follows the declarative paradigm and manages state changes in an application by comparing the virtual DOM with the real DOM, calculating the minimal set of changes, and updating the UI accordingly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Svelte:&lt;/strong&gt; Svelte is a relatively new framework that takes a radically different approach. Instead of using a virtual DOM or relying on runtime overhead, Svelte compiles the app’s components into efficient imperative code at build time. This results in a smaller runtime and fewer resources spent on updating the UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Metrics for Performance Benchmarking&lt;/strong&gt;&lt;br&gt;
To perform a fair comparison, we’ll benchmark both frameworks across the following key performance metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bundle Size:&lt;/strong&gt; Smaller bundle sizes lead to faster load times and better performance, particularly on mobile devices or slower networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Initial Load Time:&lt;/strong&gt; This is the time it takes for the application to load for the first time and render the content on the screen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Render Time / Updates:&lt;/strong&gt; How fast the framework can render and update the UI in response to state changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Usage:&lt;/strong&gt; Efficient memory usage is essential for large applications. We’ll look at how much memory is used as the application grows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CPU Usage:&lt;/strong&gt; High CPU usage during UI rendering or state changes can degrade performance, especially on lower-end devices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgla8d2xjdxcraivfzr6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgla8d2xjdxcraivfzr6.png" alt="react-vs-svelte-benchmarking" width="800" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Summary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; Svelte excels in terms of bundle size, initial load time, render time, memory usage, and CPU usage due to its compile-time optimizations and lack of virtual DOM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ecosystem and Tooling:&lt;/strong&gt; React offers a more mature ecosystem with a wide range of libraries, third-party tools, and a larger community, making it ideal for complex, large-scale applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best Choice:&lt;/strong&gt; If you prioritize performance and lightweight applications, Svelte is the winner. However, if you're looking for a mature, scalable framework with extensive ecosystem support, React remains a top choice.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>svelte</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Setting Up AG Grid in SvelteJS</title>
      <dc:creator>Sonu Jangra</dc:creator>
      <pubDate>Thu, 30 Jan 2025 12:18:47 +0000</pubDate>
      <link>https://forem.com/im_sonujangra/setting-up-ag-grid-in-sveltejs-390i</link>
      <guid>https://forem.com/im_sonujangra/setting-up-ag-grid-in-sveltejs-390i</guid>
      <description>&lt;p&gt;AG Grid is a powerful and feature-rich grid component for displaying large datasets in a flexible and efficient way. If you're using SvelteJS version 5.0.0 and want to integrate AG Grid into your project, you're in the right place! In this blog, I'll walk you through the process of setting up AG Grid in Svelte, including installing the necessary dependencies, configuring the grid, and rendering it in your Svelte components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
Before we start, make sure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js installed (Preferably the latest stable version).&lt;/li&gt;
&lt;li&gt;A Svelte project setup (If not, you can create one by running npm create svelte@latest).&lt;/li&gt;
&lt;li&gt;Basic understanding of SvelteJS and its component-based structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Installing Dependencies&lt;/strong&gt;&lt;br&gt;
To begin, you need to install AG Grid and its necessary styles in your Svelte project. Open your terminal and run the following commands:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install --save ag-grid-community&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Step 2: Creating the AG Grid Component&lt;/strong&gt;&lt;br&gt;
Now that we have the necessary dependencies installed, let’s create a Svelte component to render the grid.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In your src/routes (or src/components/common/) folder, create a new file called Grid.svelte.&lt;/li&gt;
&lt;li&gt;Add the following code to initialize and render the AG Grid:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script lang="ts"&amp;gt;
    import { onMount } from 'svelte';
    import {
        createGrid,
        ModuleRegistry,
        ClientSideRowModelModule,
        type GridOptions,
        themeQuartz,
        colorSchemeDarkBlue
    } from 'ag-grid-community';

    // Register AG Grid Modules
    ModuleRegistry.registerModules([ClientSideRowModelModule]);

    export let columnDefs: Array&amp;lt;any&amp;gt; = [];
    export let rowData: Array&amp;lt;any&amp;gt; = [];

    // Create a custom dark theme using Theming API
    const darkTheme = themeQuartz.withPart(colorSchemeDarkBlue).withParams({
        backgroundColor: '#212121',
        foregroundColor: '#ffffff',
        headerBackgroundColor: '#37474f',
        headerTextColor: '#cfd8dc',
        oddRowBackgroundColor: '#263238'
    });

    let gridDiv: HTMLDivElement;

    onMount(() =&amp;gt; {
        const gridOptions: GridOptions&amp;lt;any&amp;gt; = {
            theme: darkTheme, // Apply custom dark theme
            columnDefs,
            rowData,
            defaultColDef: {
                sortable: true,
                filter: true
            }
        };

        if (gridDiv) {
            createGrid(gridDiv, gridOptions); // Create the grid with custom options
        }
    });
&amp;lt;/script&amp;gt;

&amp;lt;!-- Grid Container --&amp;gt;
&amp;lt;div bind:this={gridDiv} style="height: 400px; width: 100%;"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here’s a breakdown of the code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;columnDefs&lt;/strong&gt;: Defines the columns you want in your grid, including the headers and the field names from the row data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;rowData&lt;/strong&gt;: Holds the data that will populate the grid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Using the AG Grid Component&lt;/strong&gt;&lt;br&gt;
Next, let’s use the Grid.svelte component we just created in the main Svelte component (usually App.svelte).&lt;/p&gt;

&lt;p&gt;Open src/App.svelte and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    import Grid from '../../components/common/Grid.svelte';
    const columns = [
        { headerName: 'Course', field: 'course' },
        { headerName: 'Instructor', field: 'instructor' },
        { headerName: 'Duration', field: 'duration' },
        { headerName: 'Location', field: 'location' },
        { headerName: 'Rating', field: 'rating' }
    ];

    const rows = [
        {
            course: 'JavaScript Basics',
            instructor: 'John Doe',
            duration: '5 hours',
            location: 'Delhi',
            rating: '3'
        },
        {
            course: 'Svelte Fundamentals',
            instructor: 'Jane Smith',
            duration: '3 hours',
            location: 'Delhi',
            rating: '2'
        },
        {
            course: 'Advanced React',
            instructor: 'Jake White',
            duration: '6 hours',
            location: 'Delhi',
            rating: '5'
        }
    ];
&amp;lt;/script&amp;gt;

&amp;lt;h1&amp;gt;Training Courses&amp;lt;/h1&amp;gt;
&amp;lt;Grid columnDefs={columns} rowData={rows} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Run Your Project&lt;/strong&gt;&lt;br&gt;
Now that everything is set up, it’s time to run your project. In the terminal, run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run dev&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
This will start the Svelte development server, and you should be able to navigate to your app in the browser. If everything is set up correctly, you should see the AG Grid displaying the data we defined in the Grid.svelte component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8wsv4lgrjvncbqspxft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8wsv4lgrjvncbqspxft.png" alt="setting-up-ag-grid-in-sveltejs" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>svelte</category>
      <category>javascript</category>
      <category>aggrid</category>
    </item>
  </channel>
</rss>
