<?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>DEV Community: Neer S</title>
    <description>The latest articles on DEV Community by Neer S (@neers).</description>
    <link>https://dev.to/neers</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%2F1182373%2F37d92a67-c6cf-4377-a299-cb31286e008f.jpeg</url>
      <title>DEV Community: Neer S</title>
      <link>https://dev.to/neers</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/neers"/>
    <language>en</language>
    <item>
      <title>Ultimate guide of Linux commands for Monitoring</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Wed, 22 Jan 2025 14:59:42 +0000</pubDate>
      <link>https://dev.to/neers/ultimate-useful-linux-commands-for-monitoring-1ej8</link>
      <guid>https://dev.to/neers/ultimate-useful-linux-commands-for-monitoring-1ej8</guid>
      <description>&lt;p&gt;Here are some essential commands to monitor the health and CPU utilization of your Ubuntu 22.04 server:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. General System Information&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;View system information:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check uptime and load average:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;uptime&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;View system memory and swap usage:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  free &lt;span class="nt"&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. CPU Utilization&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Display real-time CPU and memory usage:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  top
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;code&gt;q&lt;/code&gt; to exit.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Better interactive process viewer:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  htop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(You may need to install it: &lt;code&gt;sudo apt install htop&lt;/code&gt;)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Display CPU usage statistics:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  mpstat 1 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Install with: &lt;code&gt;sudo apt install sysstat&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Disk Usage&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check disk space usage:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Analyze disk usage in detail:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;du&lt;/span&gt; &lt;span class="nt"&gt;-sh&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;4. Network Monitoring&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;View network statistics:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  ifconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Install with: &lt;code&gt;sudo apt install net-tools&lt;/code&gt; if not available)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monitor network traffic in real-time:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  nload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Install with: &lt;code&gt;sudo apt install nload&lt;/code&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. System Logs&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;View system logs:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  journalctl &lt;span class="nt"&gt;-xe&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tail system logs in real-time:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /var/log/syslog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;6. Hardware Information&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;View CPU information:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  lscpu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check hardware information:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  lshw &lt;span class="nt"&gt;-short&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Install with: &lt;code&gt;sudo apt install lshw&lt;/code&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;7. Resource Monitoring Utilities&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install &lt;code&gt;sysstat&lt;/code&gt; for detailed monitoring tools:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;sysstat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then use commands like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;iostat&lt;/code&gt; (for I/O stats)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;sar&lt;/code&gt; (system performance stats)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monitor system resource usage with &lt;code&gt;glances&lt;/code&gt;:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;glances
  glances
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;8. Check Running Services&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;List running services:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  systemctl list-units &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;service &lt;span class="nt"&gt;--state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;running
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;9. Temperature and Sensors&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install and check hardware sensors:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;lm-sensors
  &lt;span class="nb"&gt;sudo &lt;/span&gt;sensors-detect
  sensors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Would you like a script to combine these into a single health check?&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>linux</category>
    </item>
    <item>
      <title>Implement Circuit Breaker using Polly in .Net Core 8</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Sun, 22 Dec 2024 04:17:32 +0000</pubDate>
      <link>https://dev.to/neers/implement-circuit-breaker-using-polly-in-net-core-8-5gm1</link>
      <guid>https://dev.to/neers/implement-circuit-breaker-using-polly-in-net-core-8-5gm1</guid>
      <description>&lt;h2&gt;
  
  
  Overview of the Circuit Breaker Pattern
&lt;/h2&gt;

&lt;p&gt;The Circuit Breaker pattern is used to handle faults in distributed systems, especially in a microservices architecture. It prevents cascading failures by detecting failing services and stopping their interaction for a specified period.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why and When to Use Circuit Breaker:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fail Fast: Stops unnecessary calls to failing services and saves system resources.&lt;/li&gt;
&lt;li&gt;Service Stability: Helps maintain overall application responsiveness.&lt;/li&gt;
&lt;li&gt;Recovery: Provides time for failing services to recover.&lt;/li&gt;
&lt;li&gt;Example Scenarios:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;External service downtime.&lt;/li&gt;
&lt;li&gt;Database outages.&lt;/li&gt;
&lt;li&gt;High latency in dependent services.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step By Step Implementation in .NET Core 8
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install Necessary NuGet Package&lt;/strong&gt;&lt;br&gt;
Install the Polly library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet add package Polly
dotnet add package Microsoft.Extensions.Http.Polly

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Create a Resilient HTTP Client with Circuit Breaker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set up resilient HTTP clients for ProductService, CartService, and OrderService.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.Extensions.DependencyInjection;
using Polly;
using Polly.CircuitBreaker;
using Polly.Extensions.Http;
using System;
using System.Net.Http;

var builder = WebApplication.CreateBuilder(args);

// Register HTTP Clients with Circuit Breaker
builder.Services.AddHttpClient("ProductService", client =&amp;gt;
{
    client.BaseAddress = new Uri("https://api.example.com/products");
})
.AddPolicyHandler(GetCircuitBreakerPolicy());

builder.Services.AddHttpClient("CartService", client =&amp;gt;
{
    client.BaseAddress = new Uri("https://api.example.com/cart");
})
.AddPolicyHandler(GetCircuitBreakerPolicy());

builder.Services.AddHttpClient("OrderService", client =&amp;gt;
{
    client.BaseAddress = new Uri("https://api.example.com/orders");
})
.AddPolicyHandler(GetCircuitBreakerPolicy());

var app = builder.Build();
app.Run();

// Circuit Breaker Policy
IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetCircuitBreakerPolicy()
{
    return HttpPolicyExtensions
        .HandleTransientHttpError()
        .CircuitBreakerAsync(
            handledEventsAllowedBeforeBreaking: 3,
            durationOfBreak: TimeSpan.FromSeconds(30),
            onBreak: (exception, breakDelay) =&amp;gt;
            {
                Console.WriteLine($"Circuit broken: {exception.Message}");
            },
            onReset: () =&amp;gt;
            {
                Console.WriteLine("Circuit reset");
            },
            onHalfOpen: () =&amp;gt;
            {
                Console.WriteLine("Circuit in half-open state");
            });
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Create a Service Layer to Call HTTP Clients&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Encapsulate HTTP client logic in services.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ProductService
{
    private readonly HttpClient _httpClient;

    public ProductService(IHttpClientFactory httpClientFactory)
    {
        _httpClient = httpClientFactory.CreateClient("ProductService");
    }

    public async Task&amp;lt;string&amp;gt; GetProductsAsync()
    {
        var response = await _httpClient.GetAsync("/list");
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync();
    }
}

public class CartService
{
    private readonly HttpClient _httpClient;

    public CartService(IHttpClientFactory httpClientFactory)
    {
        _httpClient = httpClientFactory.CreateClient("CartService");
    }

    public async Task&amp;lt;string&amp;gt; GetCartDetailsAsync()
    {
        var response = await _httpClient.GetAsync("/details");
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync();
    }
}

public class OrderService
{
    private readonly HttpClient _httpClient;

    public OrderService(IHttpClientFactory httpClientFactory)
    {
        _httpClient = httpClientFactory.CreateClient("OrderService");
    }

    public async Task&amp;lt;string&amp;gt; GetOrderDetailsAsync()
    {
        var response = await _httpClient.GetAsync("/details");
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync();
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Register Services in Dependency Injection&lt;/strong&gt;&lt;br&gt;
Add the service classes to the dependency injection container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;builder.Services.AddScoped&amp;lt;ProductService&amp;gt;();
builder.Services.AddScoped&amp;lt;CartService&amp;gt;();
builder.Services.AddScoped&amp;lt;OrderService&amp;gt;();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Use Services in a Controller&lt;/strong&gt;&lt;br&gt;
Consume the services in a controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("api/[controller]")]
public class ShopController : ControllerBase
{
    private readonly ProductService _productService;
    private readonly CartService _cartService;
    private readonly OrderService _orderService;

    public ShopController(ProductService productService, CartService cartService, OrderService orderService)
    {
        _productService = productService;
        _cartService = cartService;
        _orderService = orderService;
    }

    [HttpGet("products")]
    public async Task&amp;lt;IActionResult&amp;gt; GetProducts()
    {
        var products = await _productService.GetProductsAsync();
        return Ok(products);
    }

    [HttpGet("cart")]
    public async Task&amp;lt;IActionResult&amp;gt; GetCart()
    {
        var cartDetails = await _cartService.GetCartDetailsAsync();
        return Ok(cartDetails);
    }

    [HttpGet("orders")]
    public async Task&amp;lt;IActionResult&amp;gt; GetOrders()
    {
        var orderDetails = await _orderService.GetOrderDetailsAsync();
        return Ok(orderDetails);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1. Isolate Circuit Breakers:&lt;/strong&gt; Use separate circuit breakers for each service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To avoid cascading failures and ensure independent service handling, use separate circuit breakers for each service.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use named HTTP clients with unique circuit breaker policies for each service.&lt;/li&gt;
&lt;li&gt;Avoid sharing circuit breaker policies across multiple services.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;builder.Services.AddHttpClient("ProductService", client =&amp;gt;
{
    client.BaseAddress = new Uri("https://api.example.com/products");
})
.AddPolicyHandler(GetProductServiceCircuitBreakerPolicy());

builder.Services.AddHttpClient("CartService", client =&amp;gt;
{
    client.BaseAddress = new Uri("https://api.example.com/cart");
})
.AddPolicyHandler(GetCartServiceCircuitBreakerPolicy());

builder.Services.AddHttpClient("OrderService", client =&amp;gt;
{
    client.BaseAddress = new Uri("https://api.example.com/orders");
})
.AddPolicyHandler(GetOrderServiceCircuitBreakerPolicy());

IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetProductServiceCircuitBreakerPolicy() =&amp;gt;
    HttpPolicyExtensions
        .HandleTransientHttpError()
        .CircuitBreakerAsync(3, TimeSpan.FromSeconds(30));

IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetCartServiceCircuitBreakerPolicy() =&amp;gt;
    HttpPolicyExtensions
        .HandleTransientHttpError()
        .CircuitBreakerAsync(2, TimeSpan.FromSeconds(20));

IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetOrderServiceCircuitBreakerPolicy() =&amp;gt;
    HttpPolicyExtensions
        .HandleTransientHttpError()
        .CircuitBreakerAsync(5, TimeSpan.FromSeconds(60));

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;2. Monitor and Log:&lt;/strong&gt; Continuously monitor circuit breaker events for debugging and alerting. Monitor events such as circuit breaking, resetting, and transitioning to a half-open state. This helps in debugging and tracking the health of services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use onBreak, onReset, and onHalfOpen callbacks for logging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leverage monitoring tools like Application Insights or ELK Stack for observability.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetCircuitBreakerPolicyWithLogging()
{
    return HttpPolicyExtensions
        .HandleTransientHttpError()
        .CircuitBreakerAsync(
            handledEventsAllowedBeforeBreaking: 3,
            durationOfBreak: TimeSpan.FromSeconds(30),
            onBreak: (exception, timespan) =&amp;gt;
            {
                Console.WriteLine($"Circuit broken due to: {exception.Message}. Duration: {timespan}");
                // Log to Application Insights or other tools
            },
            onReset: () =&amp;gt;
            {
                Console.WriteLine("Circuit reset to closed state.");
            },
            onHalfOpen: () =&amp;gt;
            {
                Console.WriteLine("Circuit in half-open state. Testing health...");
            });
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;3. Graceful Fallback:&lt;/strong&gt; Provide meaningful fallback responses when a service is unavailable. This enhances user experience and ensures the application remains functional.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Polly's Fallback policy in conjunction with Circuit Breaker.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Return cached or default data.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetCircuitBreakerWithFallback()
{
    return Policy.WrapAsync(
        Policy&amp;lt;HttpResponseMessage&amp;gt;
            .Handle&amp;lt;Exception&amp;gt;()
            .FallbackAsync(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent("Service temporarily unavailable. Using fallback.")
            }),
        HttpPolicyExtensions
            .HandleTransientHttpError()
            .CircuitBreakerAsync(3, TimeSpan.FromSeconds(30))
    );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Graceful Degradation and Feature Toggles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When critical services fail, gracefully degrade functionality using feature toggles. Tools like LaunchDarkly or FeatureManagement in Azure App Configuration can help.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Use Centralized Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Store circuit breaker configurations in a centralized location for easier updates and management. Tools like Azure App Configuration or Consul are ideal for this purpose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class CircuitBreakerSettings
{
    public int HandledEventsAllowedBeforeBreaking { get; set; }
    public int DurationOfBreakInSeconds { get; set; }
}

builder.Services.Configure&amp;lt;CircuitBreakerSettings&amp;gt;(
    builder.Configuration.GetSection("CircuitBreaker"));

IAsyncPolicy&amp;lt;HttpResponseMessage&amp;gt; GetCircuitBreakerPolicyWithConfig(IOptionsMonitor&amp;lt;CircuitBreakerSettings&amp;gt; options)
{
    var settings = options.CurrentValue;
    return HttpPolicyExtensions
        .HandleTransientHttpError()
        .CircuitBreakerAsync(
            settings.HandledEventsAllowedBeforeBreaking,
            TimeSpan.FromSeconds(settings.DurationOfBreakInSeconds));
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tools for Monitoring and Testing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Application Insights:&lt;/strong&gt;&lt;br&gt;
For logging Circuit Breaker events and tracking service health.&lt;br&gt;
Azure Application Insights&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ELK Stack:&lt;/strong&gt;&lt;br&gt;
ElasticSearch, Logstash, and Kibana for centralized logging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gremlin:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A chaos engineering tool for simulating service failures.&lt;/li&gt;
&lt;li&gt;Gremlin&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Postman/Newman:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For manual or automated testing of APIs under failure conditions.&lt;/li&gt;
&lt;li&gt;Postman&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Polly Dashboard:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Community-based dashboard for monitoring Polly policies.&lt;/li&gt;
&lt;li&gt;Polly Dashboard GitHub&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Online Resources
&lt;/h2&gt;

&lt;p&gt;Polly Documentation: &lt;a href="https://github.com/App-vNext/Polly" rel="noopener noreferrer"&gt;Polly Official Site&lt;/a&gt;&lt;br&gt;
Circuit Breaker Design Pattern: &lt;a href="https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker" rel="noopener noreferrer"&gt;Microsoft Learn&lt;/a&gt;&lt;br&gt;
Microservices Best Practices: &lt;a href="https://learn.microsoft.com/en-us/dotnet/architecture/microservices/" rel="noopener noreferrer"&gt;Microservices on .NET&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>microservices</category>
      <category>circuitbreaker</category>
      <category>netcore</category>
    </item>
    <item>
      <title>Implement Paging, Sorting, and Searching in API (C#) and angular</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Sat, 21 Dec 2024 09:30:14 +0000</pubDate>
      <link>https://dev.to/neers/implement-paging-sorting-and-searching-in-api-c-and-angular-44j2</link>
      <guid>https://dev.to/neers/implement-paging-sorting-and-searching-in-api-c-and-angular-44j2</guid>
      <description>&lt;h2&gt;
  
  
  Step 1: Implement Paging, Sorting, and Searching Parameters in API (C#)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Create a Base Class for API Controllers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a base class BaseApiController that includes properties for paging, sorting, and searching.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public abstract class BaseApiController : ControllerBase
{
    protected int DefaultPageSize { get; } = 10;

    protected int MaxPageSize { get; } = 50;

    protected BaseApiController()
    {
        DefaultPageSize = 10;
        MaxPageSize = 50;
    }

    protected int GetPageSize(int pageSize)
    {
        return pageSize &amp;gt; MaxPageSize ? MaxPageSize : pageSize;
    }

    protected int GetPageNumber(int pageNumber)
    {
        return pageNumber &amp;lt; 1 ? 1 : pageNumber;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create a Model for Request Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a model to hold the paging, sorting, and searching parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class QueryParameters
{
    public int PageNumber { get; set; } = 1;

    private int _pageSize = 10;
    public int PageSize
    {
        get =&amp;gt; _pageSize;
        set =&amp;gt; _pageSize = value &amp;gt; 50 ? 50 : value;
    }

    public string SortBy { get; set; }

    public string SearchTerm { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use Parameters in API Controller:&lt;/p&gt;

&lt;p&gt;Use these parameters in your API controllers to filter and paginate data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Route("api/[controller]")]
[ApiController]
public class ProductsController : BaseApiController
{
    private readonly IProductService _productService;

    public ProductsController(IProductService productService)
    {
        _productService = productService;
    }

    [HttpGet]
    public IActionResult GetProducts([FromQuery] QueryParameters parameters)
    {
        var products = _productService.GetProducts(parameters);

        return Ok(products);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Implement Pagination, Sorting, and Searching in Service:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implement the actual logic in your service layer to apply these parameters to your data queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface IProductService
{
    IEnumerable&amp;lt;Product&amp;gt; GetProducts(QueryParameters parameters);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ProductService : IProductService
{
    private readonly AppDbContext _dbContext;

    public ProductService(AppDbContext dbContext)
    {
        _dbContext = dbContext;
    }

    public IEnumerable&amp;lt;Product&amp;gt; GetProducts(QueryParameters parameters)
    {
        var query = _dbContext.Products.AsQueryable();

        // Filtering
        if (!string.IsNullOrWhiteSpace(parameters.SearchTerm))
        {
            query = query.Where(p =&amp;gt; p.Name.Contains(parameters.SearchTerm));
        }

        // Sorting
        if (!string.IsNullOrWhiteSpace(parameters.SortBy))
        {
            query = query.OrderByDynamic(parameters.SortBy);
        }

        // Paging
        var skipAmount = (parameters.PageNumber - 1) * parameters.PageSize;
        query = query.Skip(skipAmount).Take(parameters.PageSize);

        return query.ToList();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Angular 14 Frontend
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Create Angular Service:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a service to interact with the API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Product } from './product.model';

@Injectable({
  providedIn: 'root'
})
export class ProductService {
  private apiUrl = 'https://localhost:5001/api/products';

  constructor(private http: HttpClient) { }

  getProducts(pageNumber: number, pageSize: number, sortBy: string, searchTerm: string): Observable&amp;lt;Product[]&amp;gt; {
    let params = new HttpParams()
      .set('pageNumber', pageNumber.toString())
      .set('pageSize', pageSize.toString())
      .set('sortBy', sortBy)
      .set('searchTerm', searchTerm);

    return this.http.get&amp;lt;Product[]&amp;gt;(this.apiUrl, { params });
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create Angular Component:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a component to display and interact with the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component, OnInit } from '@angular/core';
import { ProductService } from './product.service';
import { Product } from './product.model';

@Component({
  selector: 'app-product-list',
  templateUrl: './product-list.component.html',
  styleUrls: ['./product-list.component.css']
})
export class ProductListComponent implements OnInit {
  products: Product[] = [];
  pageNumber = 1;
  pageSize = 10;
  sortBy = '';
  searchTerm = '';

  constructor(private productService: ProductService) { }

  ngOnInit(): void {
    this.loadProducts();
  }

  loadProducts(): void {
    this.productService.getProducts(this.pageNumber, this.pageSize, this.sortBy, this.searchTerm)
      .subscribe(products =&amp;gt; {
        this.products = products;
      });
  }

  onPageChange(page: number): void {
    this.pageNumber = page;
    this.loadProducts();
  }

  onSortChange(sortBy: string): void {
    this.sortBy = sortBy;
    this.loadProducts();
  }

  onSearch(searchTerm: string): void {
    this.searchTerm = searchTerm;
    this.loadProducts();
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HTML Template for Component:&lt;/p&gt;

&lt;p&gt;Create an HTML template to display the products, pagination controls, sorting options, and search input.&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;div&amp;gt;
  &amp;lt;input type="text" placeholder="Search..." (input)="onSearch($event.target.value)" /&amp;gt;

  &amp;lt;select (change)="onSortChange($event.target.value)"&amp;gt;
    &amp;lt;option value=""&amp;gt;Sort By&amp;lt;/option&amp;gt;
    &amp;lt;option value="name"&amp;gt;Name&amp;lt;/option&amp;gt;
    &amp;lt;option value="price"&amp;gt;Price&amp;lt;/option&amp;gt;
  &amp;lt;/select&amp;gt;

  &amp;lt;ul&amp;gt;
    &amp;lt;li *ngFor="let product of products"&amp;gt;
      {{ product.name }} - {{ product.price }}
    &amp;lt;/li&amp;gt;
  &amp;lt;/ul&amp;gt;

  &amp;lt;div&amp;gt;
    &amp;lt;button (click)="onPageChange(pageNumber - 1)" [disabled]="pageNumber === 1"&amp;gt;Previous&amp;lt;/button&amp;gt;
    &amp;lt;span&amp;gt;Page {{ pageNumber }}&amp;lt;/span&amp;gt;
    &amp;lt;button (click)="onPageChange(pageNumber + 1)"&amp;gt;Next&amp;lt;/button&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this setup, the Angular component ProductListComponent interacts with the ProductService to fetch products from the API.&lt;br&gt;
The component includes methods to handle paging, sorting, and searching actions, which in turn call the appropriate methods in the service.&lt;/p&gt;

&lt;p&gt;The API controller ProductsController receives the query parameters from the frontend and passes them to the ProductService to filter, sort, and paginate the data.&lt;/p&gt;

&lt;p&gt;The ProductService implements the actual logic to apply these parameters to the LINQ queries against the Product entities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;br&gt;
This is a basic example. You may need to adjust the code according to your specific requirements.&lt;br&gt;
For sorting, you might want to add options for ascending and descending order.&lt;br&gt;
For searching, you may want to implement more complex search criteria depending on your data model.&lt;br&gt;
Error handling, validation, and security considerations are important aspects to add in a production-ready application.&lt;/p&gt;

&lt;p&gt;This code provides a foundation for reusable paging, sorting, and searching features in your .NET Core 6 API with an Angular 14 frontend.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>csharp</category>
      <category>pagination</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Generate 6 or 8 digit alpha numeric code using best performance in C#</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Sat, 21 Dec 2024 09:15:44 +0000</pubDate>
      <link>https://dev.to/neers/generate-6-or-8-digit-alpha-numeric-code-using-best-performance-in-c-2g8h</link>
      <guid>https://dev.to/neers/generate-6-or-8-digit-alpha-numeric-code-using-best-performance-in-c-2g8h</guid>
      <description>&lt;p&gt;Generating a 6 or 8-digit alphanumeric code in C# involves creating a string consisting of random letters and numbers. Here is a C# example using best practices and focusing on performance:&lt;/p&gt;

&lt;p&gt;Use a StringBuilder for efficient string concatenation.&lt;br&gt;
Use RandomNumberGenerator for cryptographic security.&lt;/p&gt;

&lt;p&gt;Cache the character array to avoid creating it repeatedly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Security.Cryptography;
using System.Text;

public class AlphaNumericCodeGenerator
{
    private static readonly char[] chars =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".ToCharArray();

    public static string GenerateCode(int length)
    {
        if (length != 6 &amp;amp;&amp;amp; length != 8)
        {
            throw new ArgumentException("Code length must be either 6 or 8.", nameof(length));
        }

        using (var rng = RandomNumberGenerator.Create())
        {
            var bytes = new byte[length];
            rng.GetBytes(bytes);

            var result = new StringBuilder(length);
            foreach (var byteValue in bytes)
            {
                result.Append(chars[byteValue % chars.Length]);
            }

            return result.ToString();
        }
    }

    public static void Main()
    {
        string code6 = GenerateCode(6);
        Console.WriteLine($"6-digit code: {code6}");

        string code8 = GenerateCode(8);
        Console.WriteLine($"8-digit code: {code8}");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Character Array:&lt;/strong&gt; A cached array of characters (both upper and lower case letters and digits) to avoid creating it repeatedly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Random Number Generator:&lt;/strong&gt; RandomNumberGenerator is used for better randomness and security compared to Random.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;StringBuilder:&lt;/strong&gt; Used for efficient string concatenation.&lt;br&gt;
Argument Validation: Ensures the length is either 6 or 8.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Random Bytes:&lt;/strong&gt; Generates random bytes and maps each byte to a character in the chars array.&lt;/p&gt;

&lt;p&gt;Modulo Operation: Maps each byte to a valid index in the chars array.&lt;/p&gt;

&lt;p&gt;This code ensures the generated string is both secure and efficient.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>performance</category>
      <category>bestpractices</category>
      <category>generate6digit</category>
    </item>
    <item>
      <title>Create scalable and fault-tolerant microservices architecture</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Sat, 21 Dec 2024 09:02:52 +0000</pubDate>
      <link>https://dev.to/neers/create-scalable-and-fault-tolerant-microservices-architecture-50k0</link>
      <guid>https://dev.to/neers/create-scalable-and-fault-tolerant-microservices-architecture-50k0</guid>
      <description>&lt;p&gt;To make a .NET Core microservices architecture scalable, fault-tolerant, and more performant, you can utilize various tools and technologies tailored for the .NET ecosystem. Here are some key components and best practices:&lt;/p&gt;

&lt;h2&gt;
  
  
  Scalability
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Containerization and Orchestration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker: For containerizing .NET Core microservices to ensure consistency across different environments.&lt;br&gt;
Kubernetes (with Azure Kubernetes Service - AKS): For orchestrating and managing containers at scale, providing automated deployment, scaling, and management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Service Discovery and Load Balancing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consul: For service discovery and configuration.&lt;br&gt;
Steeltoe: Provides service discovery (Eureka) and load balancing capabilities.&lt;br&gt;
NGINX or HAProxy: For load balancing requests across multiple instances of microservices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fault Tolerance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Circuit Breakers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Polly: For implementing the circuit breaker pattern, retries, and timeouts in .NET Core applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Monitoring and Logging:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prometheus &amp;amp; Grafana: For monitoring system metrics and visualizing them.&lt;br&gt;
Elastic Stack (Elasticsearch, Logstash, Kibana): For centralized logging and monitoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Service Mesh:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Istio: For managing microservices traffic, security, and monitoring. It provides fine-grained control over traffic behavior and resilience features like retries, failovers, and circuit breaking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. API Gateway:&lt;/strong&gt;&lt;br&gt;
Ocelot: A .NET Core API Gateway for managing API traffic, including rate limiting, authentication, and load balancing.&lt;br&gt;
Azure API Management: For a fully managed API gateway service in Azure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Caching:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Redis: For in-memory data caching to reduce database load, can be used with StackExchange.Redis client for .NET Core.&lt;br&gt;
MemoryCache: Built-in .NET Core caching for small-scale caching needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Database Sharding and Replication:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implementing sharding and replication strategies using Entity Framework Core and database-specific features to distribute load and improve read/write performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Asynchronous Communication:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure Service Bus: For reliable messaging and communication between microservices.&lt;br&gt;
RabbitMQ: For robust message queuing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Development and CI/CD
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. CI/CD Pipelines:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure DevOps: For automating the building, testing, and deployment of .NET Core microservices.&lt;br&gt;
GitHub Actions: For integrated version control and continuous integration/continuous deployment pipelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Infrastructure as Code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Terraform: For provisioning and managing infrastructure with code.&lt;br&gt;
Azure Resource Manager (ARM) templates: For automating Azure resource deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Identity and Access Management:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure Active Directory (Azure AD): For securing APIs and managing authentication and authorization.&lt;br&gt;
IdentityServer4: For implementing OAuth2 and OpenID Connect in .NET Core applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Secret Management:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure Key Vault: For securely storing and accessing secrets and sensitive data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Distributed Tracing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OpenTelemetry: For tracing requests across multiple microservices to diagnose performance issues and latency.&lt;br&gt;
Application Insights: For comprehensive monitoring and tracing in Azure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Blue-Green Deployments and Canary Releases:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Azure DevOps and Azure App Services: For minimizing downtime and reducing risk during deployments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Health Checks and Self-Healing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ASP.NET Core Health Checks: For implementing health checks to automatically detect and replace unhealthy instances.&lt;/p&gt;

&lt;p&gt;By integrating these tools and practices specifically suited for .NET Core, you can build a microservices architecture that is not only scalable and fault-tolerant but also highly performant and secure.&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>eventdriven</category>
      <category>pubsub</category>
      <category>netcore</category>
    </item>
    <item>
      <title>Difference between AddScoped, AddTransient and AddSingleton in .netcore</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Sat, 21 Dec 2024 08:57:07 +0000</pubDate>
      <link>https://dev.to/neers/difference-between-addscoped-addtransient-and-addsingleton-in-netcore-2c8f</link>
      <guid>https://dev.to/neers/difference-between-addscoped-addtransient-and-addsingleton-in-netcore-2c8f</guid>
      <description>&lt;p&gt;In .NET Core (now called .NET 5 and later), when you register services in the dependency injection (DI) container, you have different options for specifying how instances of those services are created and managed. The three main lifetime options are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Singleton: Only one instance of the service is created for the entire application, and it is reused for each request.&lt;br&gt;
services.AddSingleton();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scoped: A new instance of the service is created for each HTTP request within the scope of that request.&lt;br&gt;
services.AddScoped();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transient: A new instance of the service is created every time it is requested.&lt;br&gt;
services.AddTransient();&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Additionally, there is also a method called &lt;code&gt;TryAddSingleton&lt;/code&gt;. This method is similar to &lt;code&gt;AddSingleton&lt;/code&gt;, but it only adds the service if it hasn't been registered before. This can be useful when you want to ensure that a particular service is only registered once.&lt;br&gt;
services.AddTransient();&lt;/p&gt;

&lt;p&gt;Here's a brief summary of each:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Singleton:&lt;br&gt;
 - One instance for the entire application.&lt;br&gt;
 - Shared across all requests.&lt;br&gt;
 - Useful for stateless services or services that can be shared safely.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scoped:&lt;br&gt;
 - One instance per HTTP request.&lt;br&gt;
 - Shared within the scope of an HTTP request.&lt;br&gt;
 - Useful for services that need to maintain state within the context of a single request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transient:&lt;br&gt;
 - A new instance every time it is requested.&lt;br&gt;
 - No sharing between different parts of the application.&lt;br&gt;
 - Useful for lightweight, stateless services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TryAddSingleton:&lt;br&gt;
 - Adds the service as a singleton if it hasn't been registered before.&lt;br&gt;
 - Useful to avoid unintentional duplicate registrations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choosing the appropriate lifetime for your services depends on the specific requirements of your application and how you want instances of those services to be managed and shared.&lt;/p&gt;

</description>
      <category>netcore</category>
      <category>dependencyinversion</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>SEO Tools for Testing and Techniques</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Fri, 20 Dec 2024 05:44:07 +0000</pubDate>
      <link>https://dev.to/neers/seo-tools-for-testing-and-techniques-261k</link>
      <guid>https://dev.to/neers/seo-tools-for-testing-and-techniques-261k</guid>
      <description>&lt;h2&gt;
  
  
  Tools to test SEO Technique
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Keyword Research and Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Google Keyword Planner&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SEMrush&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ahrefs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ubersuggest&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyze keyword search volume, competition, and relevance.&lt;/li&gt;
&lt;li&gt;Check the ranking of targeted keywords on SERPs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Website Audit
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Screaming Frog SEO Spider&lt;/li&gt;
&lt;li&gt;Ahrefs Site Audit&lt;/li&gt;
&lt;li&gt;SEMrush Site Audit&lt;/li&gt;
&lt;li&gt;Google Search Console&lt;/li&gt;
&lt;li&gt;Moz Pro&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check for broken links (404 errors).&lt;/li&gt;
&lt;li&gt;Evaluate meta tags (title, description, headers).&lt;/li&gt;
&lt;li&gt;Identify duplicate content and thin pages.&lt;/li&gt;
&lt;li&gt;Analyze website speed and mobile-friendliness.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Backlink Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ahrefs&lt;/li&gt;
&lt;li&gt;Majestic SEO&lt;/li&gt;
&lt;li&gt;SEMrush Backlink Analytics&lt;/li&gt;
&lt;li&gt;Moz Link Explorer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assess the quality and quantity of backlinks.&lt;/li&gt;
&lt;li&gt;Check for spammy or toxic links.&lt;/li&gt;
&lt;li&gt;Monitor backlinks regularly to track changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Technical SEO Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google PageSpeed Insights&lt;/li&gt;
&lt;li&gt;GTmetrix&lt;/li&gt;
&lt;li&gt;WebPageTest&lt;/li&gt;
&lt;li&gt;Lighthouse (built into Chrome DevTools)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test website speed and performance.&lt;/li&gt;
&lt;li&gt;Evaluate Core Web Vitals: LCP, FID, CLS.&lt;/li&gt;
&lt;li&gt;Ensure proper XML sitemap and robots.txt configurations.&lt;/li&gt;
&lt;li&gt;Check for proper URL structures and canonical tags.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Content Quality Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grammarly for content quality&lt;/li&gt;
&lt;li&gt;Copyscape or Plagiarism Checker for originality&lt;/li&gt;
&lt;li&gt;Clearscope or SurferSEO for content optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Evaluate content relevance, readability, and keyword usage.&lt;/li&gt;
&lt;li&gt;Ensure the content aligns with user intent.&lt;/li&gt;
&lt;li&gt;Check for proper internal linking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Mobile-Friendliness
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Mobile-Friendly Test&lt;/li&gt;
&lt;li&gt;BrowserStack for device testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test website responsiveness on various devices.&lt;/li&gt;
&lt;li&gt;Check for viewport settings and touch-friendly designs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. On-Page SEO Testing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yoast SEO (WordPress Plugin)&lt;/li&gt;
&lt;li&gt;Rank Math&lt;/li&gt;
&lt;li&gt;SEOptimer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check meta tags, headers, and keyword placement.&lt;/li&gt;
&lt;li&gt;Validate alt attributes for images.&lt;/li&gt;
&lt;li&gt;Optimize internal links for better navigation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Analytics and Performance Tracking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Analytics&lt;/li&gt;
&lt;li&gt;Google Search Console&lt;/li&gt;
&lt;li&gt;Matomo Analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Monitor organic traffic trends and bounce rates.&lt;/li&gt;
&lt;li&gt;Track user behavior and engagement metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  10. Competitor Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ahrefs&lt;/li&gt;
&lt;li&gt;SEMrush&lt;/li&gt;
&lt;li&gt;SimilarWeb&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Benchmark against competitors' keywords and backlinks.&lt;/li&gt;
&lt;li&gt;Analyze competitor site architecture and content strategies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  12. Testing for Indexing Issues
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Search Console&lt;/li&gt;
&lt;li&gt;Bing Webmaster Tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the "Coverage" report to check index status.&lt;/li&gt;
&lt;li&gt;Perform a manual site search (e.g., site:example.com) to confirm indexed pages.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>seo</category>
      <category>serversiderendering</category>
      <category>googleseo</category>
      <category>programming</category>
    </item>
    <item>
      <title>Beginner SEO in React JS - React Helmet</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Fri, 20 Dec 2024 05:41:03 +0000</pubDate>
      <link>https://dev.to/neers/beginner-seo-in-react-js-react-helmet-5kk</link>
      <guid>https://dev.to/neers/beginner-seo-in-react-js-react-helmet-5kk</guid>
      <description>&lt;h2&gt;
  
  
  Using react-helmet
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Install the library:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-helmet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Update your component to use react-helmet:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Helmet } from 'react-helmet';

const App = () =&amp;gt; {
    const appName = "Your Application Name";
    const dynamicPageTitle = `Welcome to ${appName}`;

    return (
        &amp;lt;div&amp;gt;
            &amp;lt;Helmet&amp;gt;
                &amp;lt;title&amp;gt;{dynamicPageTitle}&amp;lt;/title&amp;gt;
            &amp;lt;/Helmet&amp;gt;
            &amp;lt;h1&amp;gt;Welcome to {appName}&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

export default App;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The page title will dynamically update, and search engines will be able to pick it up when indexing.&lt;br&gt;
Using JavaScript (document.title)&lt;br&gt;
You can also directly set the title in the useEffect hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useEffect } from 'react';

const App = () =&amp;gt; {
    const appName = "Your Application Name";

    useEffect(() =&amp;gt; {
        document.title = `Welcome to ${appName}`;
    }, [appName]);

    return (
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;Welcome to {appName}&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices for SEO
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unique Titles:&lt;/strong&gt; Ensure each page in your app has a unique and descriptive title.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server-Side Rendering (SSR):&lt;/strong&gt; If your app needs better SEO, consider using frameworks like Next.js, which support server-side rendering.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Meta Tags:&lt;/strong&gt; Along with the title, update meta tags using react-helmet or other similar methods to include descriptions, keywords, and canonical URLs.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Helmet&amp;gt;
    &amp;lt;title&amp;gt;{dynamicPageTitle}&amp;lt;/title&amp;gt;
    &amp;lt;meta name="description" content="Description of the application or page" /&amp;gt;
    &amp;lt;meta name="keywords" content="your, keywords, here" /&amp;gt;
&amp;lt;/Helmet&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These steps ensure your React app's title is dynamically updated and optimized for search engines like Google.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools to test SEO Technique
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Keyword Research and Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Google Keyword Planner&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SEMrush&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ahrefs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ubersuggest&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyze keyword search volume, competition, and relevance.&lt;/li&gt;
&lt;li&gt;Check the ranking of targeted keywords on SERPs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Website Audit
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Screaming Frog SEO Spider&lt;/li&gt;
&lt;li&gt;Ahrefs Site Audit&lt;/li&gt;
&lt;li&gt;SEMrush Site Audit&lt;/li&gt;
&lt;li&gt;Google Search Console&lt;/li&gt;
&lt;li&gt;Moz Pro&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check for broken links (404 errors).&lt;/li&gt;
&lt;li&gt;Evaluate meta tags (title, description, headers).&lt;/li&gt;
&lt;li&gt;Identify duplicate content and thin pages.&lt;/li&gt;
&lt;li&gt;Analyze website speed and mobile-friendliness.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Backlink Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ahrefs&lt;/li&gt;
&lt;li&gt;Majestic SEO&lt;/li&gt;
&lt;li&gt;SEMrush Backlink Analytics&lt;/li&gt;
&lt;li&gt;Moz Link Explorer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assess the quality and quantity of backlinks.&lt;/li&gt;
&lt;li&gt;Check for spammy or toxic links.&lt;/li&gt;
&lt;li&gt;Monitor backlinks regularly to track changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Technical SEO Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google PageSpeed Insights&lt;/li&gt;
&lt;li&gt;GTmetrix&lt;/li&gt;
&lt;li&gt;WebPageTest&lt;/li&gt;
&lt;li&gt;Lighthouse (built into Chrome DevTools)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test website speed and performance.&lt;/li&gt;
&lt;li&gt;Evaluate Core Web Vitals: LCP, FID, CLS.&lt;/li&gt;
&lt;li&gt;Ensure proper XML sitemap and robots.txt configurations.&lt;/li&gt;
&lt;li&gt;Check for proper URL structures and canonical tags.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Content Quality Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grammarly for content quality&lt;/li&gt;
&lt;li&gt;Copyscape or Plagiarism Checker for originality&lt;/li&gt;
&lt;li&gt;Clearscope or SurferSEO for content optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Evaluate content relevance, readability, and keyword usage.&lt;/li&gt;
&lt;li&gt;Ensure the content aligns with user intent.&lt;/li&gt;
&lt;li&gt;Check for proper internal linking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Mobile-Friendliness
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Mobile-Friendly Test&lt;/li&gt;
&lt;li&gt;BrowserStack for device testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test website responsiveness on various devices.&lt;/li&gt;
&lt;li&gt;Check for viewport settings and touch-friendly designs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. On-Page SEO Testing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yoast SEO (WordPress Plugin)&lt;/li&gt;
&lt;li&gt;Rank Math&lt;/li&gt;
&lt;li&gt;SEOptimer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check meta tags, headers, and keyword placement.&lt;/li&gt;
&lt;li&gt;Validate alt attributes for images.&lt;/li&gt;
&lt;li&gt;Optimize internal links for better navigation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Analytics and Performance Tracking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Analytics&lt;/li&gt;
&lt;li&gt;Google Search Console&lt;/li&gt;
&lt;li&gt;Matomo Analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Monitor organic traffic trends and bounce rates.&lt;/li&gt;
&lt;li&gt;Track user behavior and engagement metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  10. Competitor Analysis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ahrefs&lt;/li&gt;
&lt;li&gt;SEMrush&lt;/li&gt;
&lt;li&gt;SimilarWeb&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Benchmark against competitors' keywords and backlinks.&lt;/li&gt;
&lt;li&gt;Analyze competitor site architecture and content strategies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  12. Testing for Indexing Issues
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Search Console&lt;/li&gt;
&lt;li&gt;Bing Webmaster Tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Techniques:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the "Coverage" report to check index status.&lt;/li&gt;
&lt;li&gt;Perform a manual site search (e.g., site:example.com) to confirm indexed pages.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>reactjsdevelopment</category>
      <category>seo</category>
      <category>ssr</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Image compression in Angular 15+ and .NET Core 7</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Fri, 20 Dec 2024 05:28:36 +0000</pubDate>
      <link>https://dev.to/neers/image-compression-in-angular-15-and-net-core-7-35nb</link>
      <guid>https://dev.to/neers/image-compression-in-angular-15-and-net-core-7-35nb</guid>
      <description>&lt;p&gt;To edit and change the aspect ratio of an image in an Angular and .NET Core 7 application, you'll need to handle image manipulation on both the client side (Angular) and the server side (.NET Core 7). Here's a general approach:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Client-Side (Angular) - Adjusting Aspect Ratio Before Upload
&lt;/h2&gt;

&lt;p&gt;You can allow the user to upload an image, adjust the aspect ratio on the client side, and then send the modified image to the .NET Core API.&lt;/p&gt;

&lt;p&gt;Steps in Angular:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use an HTML  file field to select the image.&lt;/li&gt;
&lt;li&gt;Use the HTML5 Canvas API to adjust the aspect ratio before sending the image to the server.&lt;/li&gt;
&lt;li&gt;Convert the image to a base64 or a Blob to send it to the backend API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example 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;!-- HTML for file input --&amp;gt;
&amp;lt;input type="file" (change)="onFileSelected($event)" /&amp;gt;
&amp;lt;canvas #canvas&amp;gt;&amp;lt;/canvas&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Angular component
import { Component, ViewChild, ElementRef } from '@angular/core';

@Component({
  selector: 'app-image-resize',
  templateUrl: './image-resize.component.html',
})
export class ImageResizeComponent {
  @ViewChild('canvas', { static: false }) canvas: ElementRef&amp;lt;HTMLCanvasElement&amp;gt;;

  onFileSelected(event: any) {
    const file = event.target.files[0];
    if (file) {
      const img = new Image();
      const reader = new FileReader();

      reader.onload = (e: any) =&amp;gt; {
        img.src = e.target.result;

        img.onload = () =&amp;gt; {
          const ctx = this.canvas.nativeElement.getContext('2d');
          const desiredAspectRatio = 16 / 9; // Set desired aspect ratio

          // Resize logic
          const width = img.width;
          const height = img.height;
          const currentAspectRatio = width / height;

          let newWidth = width;
          let newHeight = height;

          if (currentAspectRatio &amp;gt; desiredAspectRatio) {
            // Crop width to match aspect ratio
            newWidth = height * desiredAspectRatio;
          } else if (currentAspectRatio &amp;lt; desiredAspectRatio) {
            // Crop height to match aspect ratio
            newHeight = width / desiredAspectRatio;
          }

          // Resize and draw the image to the canvas
          this.canvas.nativeElement.width = newWidth;
          this.canvas.nativeElement.height = newHeight;
          ctx?.drawImage(img, 0, 0, newWidth, newHeight);

          // Convert canvas back to Blob or base64 for upload
          this.canvas.nativeElement.toBlob((blob) =&amp;gt; {
            // Send blob to the .NET Core backend
            this.uploadImage(blob);
          }, 'image/jpeg');
        };
      };
      reader.readAsDataURL(file);
    }
  }

  uploadImage(blob: Blob) {
    const formData = new FormData();
    formData.append('file', blob, 'resized-image.jpg');

    // Make HTTP request to upload the image
    // this.httpClient.post('your-api-url', formData).subscribe();
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Server-Side (.NET Core 7) - Handling the Image
&lt;/h2&gt;

&lt;p&gt;On the server side, you can receive the uploaded image, process it further if needed (e.g., validation, additional resizing), and save it.&lt;/p&gt;

&lt;p&gt;Steps in .NET Core:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receive the image using an API controller.&lt;/li&gt;
&lt;li&gt;Use libraries like ImageSharp or SkiaSharp for image manipulation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example Code in .NET Core 7:&lt;/p&gt;

&lt;p&gt;Install ImageSharp via NuGet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet add package SixLabors.ImageSharp --version 2.1.3

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// .NET Core API Controller
[HttpPost("upload")]
public async Task&amp;lt;IActionResult&amp;gt; UploadImage(IFormFile file)
{
    if (file != null &amp;amp;&amp;amp; file.Length &amp;gt; 0)
    {
        using var image = await Image.LoadAsync(file.OpenReadStream());

        // Resize the image if necessary
        int newWidth = 1920;
        int newHeight = (int)(newWidth / (16.0 / 9)); // Maintain 16:9 aspect ratio

        image.Mutate(x =&amp;gt; x.Resize(newWidth, newHeight));

        // Save the image
        var savePath = Path.Combine("wwwroot", "uploads", "resized-image.jpg");
        await image.SaveAsync(savePath);

        return Ok(new { filePath = savePath });
    }

    return BadRequest("Invalid image file.");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Upload Flow
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The user selects an image in Angular.&lt;/li&gt;
&lt;li&gt;The image is resized or cropped on the client side using Canvas.&lt;/li&gt;
&lt;li&gt;The modified image is uploaded to the .NET Core API.&lt;/li&gt;
&lt;li&gt;The API processes the image (if necessary) and saves it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Additional Considerations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Validation:&lt;/strong&gt; Ensure the image meets size, format, and resolution requirements before resizing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling:&lt;/strong&gt; Implement error handling for failed uploads, invalid image formats, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Storage:&lt;/strong&gt; Choose appropriate storage, such as local file system, Azure Blob Storage, or AWS S3, for storing the resized images.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This setup allows you to change the aspect ratio of an image before uploading and handle it in .NET Core.&lt;/p&gt;

&lt;h2&gt;
  
  
  BONUS Content
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Client-Server Flow&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The user selects an image on the client side.&lt;/li&gt;
&lt;li&gt;Angular resizes and compresses the image using the  element and the toBlob method.&lt;/li&gt;
&lt;li&gt;The compressed image is sent to the .NET Core backend via an HTTP POST request.&lt;/li&gt;
&lt;li&gt;Optionally, the server can further compress or process the image and then save it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Client-Side Compression:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduces file size before sending to the server, which saves bandwidth.&lt;/li&gt;
&lt;li&gt;Provides immediate feedback to users about image quality.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Server-Side Compression:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adds an extra layer of image handling, ensuring the image meets size and quality requirements.&lt;/li&gt;
&lt;li&gt;Allows for bulk image processing after upload.&lt;/li&gt;
&lt;li&gt;By using this approach, you can significantly reduce the image size on the client side and, if necessary, further compress it on the server side.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Best practices to Implement RTL in React Js</title>
      <dc:creator>Neer S</dc:creator>
      <pubDate>Fri, 20 Dec 2024 05:27:42 +0000</pubDate>
      <link>https://dev.to/neers/best-practices-to-implement-rtl-in-react-js-1ckg</link>
      <guid>https://dev.to/neers/best-practices-to-implement-rtl-in-react-js-1ckg</guid>
      <description>&lt;p&gt;&lt;strong&gt;1 Install RTL-Support Libraries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install the necessary packages for managing RTL layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install rtlcss postcss-rtl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Update CSS/SCSS Styles&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use postcss-rtl for automatic conversion of styles.&lt;/li&gt;
&lt;li&gt;Modify your CSS files to include logical properties like margin-inline-start and avoid hardcoded left/right styles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Configure PostCSS for RTL&lt;/strong&gt;&lt;br&gt;
Add a PostCSS configuration in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// postcss.config.js
module.exports = {
  plugins: {
    'postcss-rtl': {},
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Detect Language Direction&lt;/strong&gt; Use a utility function to detect and apply dir="rtl":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const isRTL = (lang) =&amp;gt; ['ar', 'he'].includes(lang);
document.documentElement.dir = isRTL(language) ? 'rtl' : 'ltr';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Dynamic Language Switching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use a state management library (e.g., Redux, Context API) to toggle between ltr and rtl.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test with RTL-Languages
&lt;/h2&gt;

&lt;p&gt;Use Chrome DevTools to force RTL mode for testing.&lt;/p&gt;

&lt;p&gt;Common Guidelines&lt;br&gt;
Use Constants for Alignment: Define alignment constants:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ALIGN_START = isRTL ? 'right' : 'left';
const ALIGN_END = isRTL ? 'left' : 'right';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test Early and Often: Validate UI components for both LTR and RTL layouts.&lt;br&gt;
Leverage Tools for Translation: Use services like Google Translate for preliminary translations and hire native speakers for accuracy.&lt;/p&gt;

</description>
      <category>react</category>
      <category>rtl</category>
      <category>webdev</category>
      <category>basic</category>
    </item>
  </channel>
</rss>
