Microservices Architecture: Building the Digital Future, One Service at a Time

In the fast-paced world of software development, adaptability, scalability, and efficiency are paramount. As businesses strive to meet the ever-evolving demands of their customers, they are increasingly turning to microservices architecture as a solution to their complex problems. In this blog post, we will explore the fascinating world of microservices architecture, its benefits, challenges, and why it's becoming the go-to approach for building modern digital applications.

What Are Microservices?

Microservices architecture is a software design pattern where an application is divided into a collection of loosely-coupled services that can be developed, deployed, and scaled independently. Each microservice is responsible for a specific piece of functionality and communicates with other microservices through well-defined APIs. This architectural style is a departure from the monolithic approach, where an entire application is tightly integrated into a single codebase.

The Benefits of Microservices

1. Scalability and Agility

Microservices allow for independent scaling of individual services. This means that if one part of your application experiences a surge in demand, you can allocate more resources to that specific microservice, ensuring optimal performance without affecting the rest of the application.

2. Faster Development

Smaller, focused teams can work on individual microservices, enabling faster development cycles. Developers can choose the most appropriate technology stack for each service, leading to better innovation and efficiency.

3. Fault Isolation

In a monolithic application, a bug or failure in one part of the code can bring down the entire system. With microservices, failures are contained within individual services, reducing the risk of widespread outages and making debugging easier.

4. Technology Agnosticism

Microservices architecture allows for flexibility in choosing the technology stack for each service. This enables organizations to adopt new technologies and tools without the need to overhaul the entire application.

Challenges of Microservices

While microservices offer numerous benefits, they also come with their own set of challenges:

1. Complexity

Managing a network of microservices can be complex, requiring robust service discovery, load balancing, and monitoring tools.

2. Data Management

Handling data consistency and ensuring that services can access and update data efficiently can be challenging in a microservices architecture.

3. Deployment and Testing

Deploying and testing multiple services across different environments can be more complicated than deploying a monolithic application.

4. Communication Overhead

Inter-service communication can introduce latency and potential points of failure, making it crucial to design resilient communication patterns.

Real-World Success Stories

Numerous tech giants and startups have embraced microservices architecture with great success. Companies like Netflix, Amazon, and Uber have leveraged microservices to achieve unparalleled scalability and agility.

For example, Netflix's microservices architecture allows them to deliver personalized content recommendations to millions of users worldwide. Each microservice handles a specific aspect of the recommendation algorithm, enabling rapid experimentation and continuous improvement.

Is Microservices Architecture Right for You?

While microservices offer tremendous advantages, they may not be the best fit for every project. The decision to adopt microservices should be based on factors like the complexity of your application, your team's expertise, and your organization's willingness to invest in the necessary infrastructure and tooling.

In conclusion, microservices architecture is reshaping the way we build and deploy software. Its ability to provide scalability, agility, and fault tolerance is revolutionizing the digital landscape. However, it's essential to approach microservices with a clear understanding of the challenges and trade-offs involved. With the right strategy and a commitment to best practices, microservices can help your organization thrive in the digital age, one service at a time.

Read more...

How to read App Settings values from Config.json or appsettings.json file in ASP.NET Core

In this article we are going to learn how can we get/read values from config.json or appsettings.json file in Asp.Net core.

Assume you have following settings in your config file

{
  "MySettings": {
        "key": "12345"
    }
}


Now, in order to read values from above config file, you need the Configuration object which is available in the namespace 'Microsoft.Extensions.Configuration'. 

Open your startup.cs file and add reference to 'Microsoft.Extensions.Configuration' namespace. You need to use dependency injection to get Configuration object in either your controller or any other class file. Dependency Injection is a built-in feature in .NET core.

To achieve this, add the following line inside ConfigureServices method in startup.cs file.

services.AddSingleton<IConfiguration>(Configuration);

Now, your new ConfigureServices method will be

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddSingleton < IConfiguration > (Configuration);
}

And, your startup.cs file should look like this



As we added dependency injection for IConfiguration, we can start using it in any controller or any other class.

Reading values from appsettings.json file:


We have to use the constructor injection in any controller for reading values from appsettings.json file. Just add a constructor in your controller which takes IConfiguration interface as input parameter. 
At runtime, when we the controller gets called, this Constructor [MyController(IConfiguration configuration)] will get called and it will get resolved by its concrete class [Configuration] which we have set in Startup class.

 public class MyController : Controller
    {
        private readonly IConfiguration Configuration;

        public MyController(IConfiguration config)
        {
            this.Configuration = config;
        }
}

Now as we have the reference to Configuration object in our controller we can now read the values from appsettings.json file using following code

            var value = this.config.GetSection("MySettings").GetSection("key").Value;

This is how we set or get values from appsettings.json file in  .Net core projects.

For more useful articles on .Net core visit: Asp.Net core


Read more...

How to remove old and unused Docker images or stop Docker Containers or remove Docker Volumes

This post explains how to remove old or unused docker images, how to remove stopped containers, how to remove unused volumes, how to remove unused networks or a single command to run all prunes at a time

Note: These command works for Docker with version 1.13 or higher

Command to remove unused Images

docker image prune

Command to removed stopped Containers


docker container prune

Command to remove unused Volumes


docker volume prune

Command to remove unused Networks


docker network prune

Command to run all Prunes at a time


docker system prune

It is suggested that not to use system prune command. This may remove the things which users doesn't want to remove.

This is how we remove old or unused docker images, or remove stopped containers, or remove unused volumes, or remove unused networks or run all prunes at a time.

For more posts on Docker please visit: docker

Read more...

angular ng grid not displaying data when there is a special character in column name

In this post am going to explain how to show data in ng-grid when there is a special character in column name.

Assume you have following columnDefs in gridOptions

columnDefs: [{
      name: "parent.name",
      displayName: 'Name',
      type:'string'

    }, {
      name: 'lastName',
      displayName: 'Surname'
    }]
  };

As you see, our first column has name as parent.name. It has dot ('.') in it's name. So if you use this columnDefs in your ng-grid it will not show data in that column as the name has special characters in it. To make it work you need to add following flag to your gridOptions

gridOptions.flatEntityAccess = true;

So your final gridOptions will look something like below

  $scope.gridOptions = {

    columnDefs: [{
      name: "parent.name",
      displayName: 'Name',
      type:'string'

    }, {
      name: 'lastName',
      displayName: 'Surname'
    }]
  };

  $scope.gridOptions.data = [{
    "parent.name": "John",
    "lastName": "Cena"
  }];

 $scope.gridOptions.flatEntityAccess = true;

Check the following plunkr for working example.

ng-grid show data when there is a special character in column name

This is how we can show data in ng-grid even if the column name is having special character in it.

For more posts on angularJs refer: AgngularJs

Read more...

how to merge a specific commit in Git

In this article am going to explain how to merge(cherry pick) specific commit in Git

When you are working on two different branches you often merge code from one branch to another. But if you want to merge specific changes to another branch you can do it by cherry picking specific commit.

Using Git Extensions you can easily merge a specific commit. (Download Git Extensions from link1 or from here link2)

In Git Extensions open your repository. It will show you all the commits. Select any specific commit and right click on it. Then select cherry pick commit. Check the below screenshot for reference


Once you select Cherry pick commit it opens another small popup as shown below


Check "Automatically create a commit" if you want to automatically commit this changes into current branch or if you want to manually commit, keep the box unchecked and click on "Cherry pick".

In this way you can merge a specific commit in Git
Read more...