The programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.
Algorithm Introduction
Introduction and Characteristics of Algorithms, Algorithm is a step-by-step programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.
As we saw in this article about Algorithm, Let us see in details here.
Algorithm is step-by-step procedure for solving a problem in finite number of steps. In other words it is finite set of well-defined instructions written in human readable language for solving a given problem. An algorithm is division of a problem into small steps which are in sequence. Algorithm is very important way for computers to understand the problem and process the information accordingly.
Problem can always be solved in multiple ways or can have multiple solutions to solve. Similarly Algorithms also can be written any number ways to solve the problem. Let us see the characteristic of an Algorithm.
The programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.
Algorithms
Algorithms is a step-by-step e programmatic way of storing data, so that it can be used efficiently. Almost every enterprise application uses various types of data structures in one or the other way.
Why do we need to learn Data Structures and Algorithms?
Every day the complexity of applications are increasing which result in more complex and rich sets of data, due to the complexity we generally face the following 3 types of problems every day.
Problems faced by the large enterprise or corporate (service and data):
Data Searching: Consider users registered in social app is more than 1 million, if we want to search for one person in that 1 million, the search operation need to be performed on that 1 million user records. Thus the search operation slows down every time new user data is stored.
Processor capacity/speed: Capacity of processor need to be very high to handle such large sets of data. Failing to do so will cause poor performance and bad experience to the users.
Too-many requests: Everyone hold PC/Laptop, Mobile devices and IoT gadgets which connects to the service to perform some operation on the data. Thus the number of service request sent and received by the devices and the server are way many. Even the fastest server might fail to respond sometimes.
How to solve the above problems?
To solve the above 3 problems (Data Searching, Processor capacity/speed & Too-many requests) we can use the Data Structures.
Data can be organized in a way that data is categorized and sorted before searching, thus allowing us to search instantly.
Exactly what is that we are going to do with Data structures and algorithms?
As we already know the Algorithms is step-by-step procedure for performing an operation. And that operations are used for manipulating the data. Let’s us see the operations or the categories of algorithms.
Categories of algorithms:
Search
Sort
Insert
Update
Delete
In the next article in details about the algorithms and the data structures implementation with example.
Today we will see what is Chained or Chain of Responsibility Design Pattern is.
What is Chained or Chain of Responsibility Design Pattern?
The chained or Chain of responsibility pattern produces a single response which is a combination of multiple chained responses.
Example:
Consider we have Contact, Student & Fees three microservices, each web service communicates with the following or next service as in waterfall.
Yes, Contact service calls Student service and Student service calls Fees service. Response of Fees and Student will be returned back to Contact service.
Chained Or Chain Of Responsibility Design Pattern in Microservice
Here the Client must wait till the response comes back after the consolidated response is available, meaning the Client will be waiting for the chain of response to be returned back as a response.
Use this service where the client is not expecting any response. (Something like calling a batch job, synchronous tasks or orchestrated flow of actions.
All these services use the HTTP request or response for communicating,
Note: Each service request and response looks different from the chained flow.
In the next article, we will see Asynchronous Messaging design pattern.
Today we will see what is API Gateway Design Pattern is.
What is API Gateway Design Pattern?
Microservice is built in such a way that each service acts differently on its own. So, when a web application is drilled down into smaller pieces there could be problems we face.
The problems are as follows.
How to get data from various microservices?
A different front-end application is required to manage the same database, just that it uses multiple web services.
How to respond with the data for different consumer to satisfy their requirement. So that we can have reusable microservices.
Handle multiple protocol requests.
Seems the list is small here, but in reality, it is even wider. The solution for these problems is to use the API Gateway design pattern. The API Gateway design pattern addresses many other problems apart from the ones mentioned above. We can also use this design pattern as a proxy service for routing the request.
API Gateway acts as the entry point for all the endpoints of the microservice, it can help in converting the various protocol request from one type to another. Also, it can disburden the responsibility of authentication/authorization in the microservice.
So, once the client sends the request, requests are passed through the API gateway which manages the entry point and re-routes the client’s request to the appropriate microservice. Then with the help of the load balancer, it distributes the client’s request to the microservice.
Microservice uses the service discovery which maintains the available microservices and their available entry points to communicate with each other
API Gateway Design pattern
In the next article, we will see Chained or Chain of Responsibility design pattern.