Tuesday, November 27, 2018

Perform Load testing for Web API /Restful service in Postman

This blog demonstrates how to perform load testing of WEB API (restful service) by using postman tool.

Steps:
  1.  Create a Collection.
  2. Add Web API HTTP Request.
  3. Run ‘Runner’ to perform load testing.

Create a collections – which contains list of HTTP request

Ø  Click on New Button icon under Collections Tabs


 Postman Create a Collection


Ø  “Create a New Collection” screen will be displayed

 Postman Create a Collection


Add Web API HTTP Request:

Ø  Click on New Button:

Add Web API HTTP Request


Ø  Click on  “Create New -> Request (Under Building Block)” icon


Add Web API HTTP Request:

Ø  Save HTTP Request to ‘Load Restful Web APIs’

·        Give HTTP Request Name eg. HTTP Get Request

Add Web API HTTP Request:



·        Enter Web API URL and required information to submit request


Enter Web API URL


Run ‘Runner’ to perform load testing:

Ø  Click on “Runner” Button

Run ‘Runner’ to perform load testing:

Ø  Select Collection and provide value for below fields:
·        Environment
·        Iteration
·        Delay    

Collection Runner


Ø  Click Start RUN & after successfully RUN, will be display Load balance test result:

Load balance test result


Monday, November 26, 2018

Web API over WCF

While designing the service layer for new application, this debate is always happened in my team.

        Are we going to choose Web API over WCF or going with WCF?

Choosing right technology always contribute the major role of the success of application. If without understanding all possible factor and product requirement, you cherry-picked any technology, it could be a reason for application failure or performance issue and also it could limited the exposure of client.  

Let back on our topic ‘Web API vs WCF’. there is no doubt, WCF provides a lots of feature and it is much more versatile in case of supporting to many transport protocols (HTTP, TCP, Named Pipes etc.) and can easily build secure, reliable and transaction enabled service and much more in messaging like two –way communication (duplex channel) .

Web API if you need to build  a lightweight, restful service based HTTP protocol and it can leverage of the full feature of HTTP protocol like cache control, versioning etc and you want to expose your service to a broad range of client i.e. web browser, tables, mobile then web API always have advantage over WCF. WCF has very extensive configuration compare to web API and WEB API is very simple and light weight service and easily accessible in limited bandwidth device like smart phones and tablet. Web API supports any text format including XML so in performance, Web API is faster than WCF.

WCF:

WCF
WCF

·         Should support special scenarios such as one way messaging, message queues, duplex communication etc.
·         Should support fast transport channels when available, such as TCP, Named Pipes, or maybe even UDP (in WCF 4.5), and you also want to support HTTP when all other transport channels are unavailable.
·         Should be transaction enabled service or it will be called under other transaction scope.

Web API:


Web API
WEB API

·         Should be restful service over HTTP that can use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats).
·         Should be expose your service to a broad range of clients including browsers, mobiles, iPhone and tablets.

Thanks for visiting !!

Tuesday, November 6, 2018

C# - Polymorphism

Polymorphism is major concept of object programming and in general term, it stands for ‘Many Shape’, it means the one function can perform different thing depend on context.
In C#, Polymorphism can be categories in two group.
·                   Static Polymorphism
·                   Dynamic Polymorphism


Static Polymorphism:

In Static polymorphism, the calling method will be decided on compile time so it is also called Early Binding. In C#, it will be achieved by Function Overloading or Operator Overloading

Function Overloading: we can defined multiple function with same name but its signature will be different, it is called function overloading. In method signature, we are not considering return type.

The following code shows How same function ‘Render()’ render different shape based on passed input type ( Circle,  Rectangle).

public class RenderShape
    {
        public void Render(Circle circle)
        {
            Console.Writeline("Rendering Circle");
        }

        public void Render(Rectangle rectangle)
        {
            Console. Writeline ("Rendering Rectangle");
        }
    }

    public class RenderEngine
    {
        public void Render()
        {
            RenderShape renderShape = new RenderShape();

            renderShape.Render(new Circle());

            renderShape.Render(new Rectangle());

        }
    }


Output:

Rendering Circle
Rendering Rectangle



Dynamic Polymorphism –

In Dynamic polymorphism, the calling method will be decided on runtime so it is also called Late Binding.  In C#, it will be achieved by implementation of Abstract Class or Interface.

Abstract:  
In C#, Abstract class is used for partial implementation and it contains abstract method, which must be implemented by derived class eg. Circle, Rectangle. Abstract class can have some common code, which will be shared among all derived class.


        public abstract class Shape
            {
                public abstract void Render();
            }

        public class Circle : Shape
        {
            public override void Render()
            {
                Console.Write("Rendering Circle");
            }
        }

        public class Rectangle : Shape
        {
            public override void Render()
            {
                Console.Write("Rendering Rectangle");
            }
        }

  
       public class RenderEngine
        {
            public void Render()
            {
                Shape shape = new Circle();
                shape.Render();

                shape = new Rectangle();
                shape.Render();
            }
        }


Interface:
Interface is a basically contract, which have only signature of methods or property. the class which will be implement this interface have to define the signature.


        public interface IShape
            {
                void Render();
            }


        public class Circle : IShape
        {
            public void Render()
            {
                Console.Write("Rendering Circle");
            }
        }

        public class Rectangle : IShape
        {
            public void Render()
            {
                Console.Write("Rendering Rectangle");
            }
 }

        public class RenderEngine
        {
            public void Render()
            {
                IShape shape = new Circle();
                shape.Render();

                shape = new Rectangle();
                shape.Render();
            }
        }


Thanks for visiting !!

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...