Architecture is the core foundation. Be it Web technology or Mobile app. Without a proper foundation, there is a good chance that you might come back to restructure things partially or in worst cases from scratch.
With the architecture, we will be able to highlight early design decisions that will make us think about possible blockers ahead of time, helps us deciding tech stack which is the best fit for the project.
The Web Architecture describes the interactions between components like applications, databases, message queue, cache, all running in conjunction with each other to form an online service.
Before we move further, let’s talk about Tiers.
It is a physical structure of an application or a service. We separate components like database, UI, cache, etc on a physical level to form a structure that will help us achieve a higher degree of scalability.
If you heard about layers then it’s nothing but the logical separation of code. example: User Interface Layer, Business Logic Layer, and Data Access Layer.
There are four types of Tiers:
A single-tier Application involves components like user interface, backend business logic and the database all reside in the same machine or platform.
Examples are Desktop applications like MS Office. Music editing software.
There are few advantages of single-tier applications like user data stays in the same machine without involving network activity, and access to data gets easier as it’s in the same machine but performance depends on the machine’s specs.
A two-tier application involves a client and a server. The client contains the user interface and the business logic in one machine. Meanwhile, the backend server includes the database running on a different machine.
In a three-tier application, the user interface, application logic, and the database all lie on different machines and, thus, have different tiers. They are physically separated.
An n-tier application is an application that has more than three components involved. example load balancers, caching mechanism, Message queues. With N tier application we can distribute single responsibility and separate the concerns so that each component will be responsible for itself.
The foundation of web is the client server architecture. It works on a request-response model. The client sends the request to the server for data and the server responds with it.
The client is something or someone that represents the presentation part of the application. It is the UI. The client can be a mobile app, a browser or it can also be a web-based console.
A webserver is something that receives requests from clients and provides response after processing the requested part from the client.
There are different kinds of servers that are meant to execute specific tasks assigned to them like, proxy server, file server, virtual server, etc. To host websites we would use Apache Server.
The HTTP protocol is responsible for the communication to exchange data that happens over the web. The HTTP protocol is a request-response or client-server protocol that means requests are initiated by the client, and a response is sent by the server.
REST stands for Representational State Transfer. It’s a software architectural style for implementing web services. Web services implemented using the REST architectural style are known as the RESTful Web services. Rest endpoint is usually the URL for a service.
The Rest API acts as Gateway where it encapsulates the logic and forwards client requests and if required works with authorization authentication and cleans the input data before providing a response.
In HTTP, time-to-live is the number of seconds it takes for cached web content to return before the webserver has to check again to ensure that the content is “fresh.”
There are two modes of data transfer between the client and the server. HTTP PUSH and HTTP PULL.
In HTTP PULL, the client sends a request and the server responds to that request. It’s like pulling the data from the server whenever it is needed by creating a new connection. This method is always initiated first by the client.
The issue with this method is excessive pulls by the client can bring the server down or unnecessary pulls when there is no update which can waste the bandwidth.
There is a dynamic technique of requesting information from the server after regular intervals is known as HTTP Pull Polling.
This method was introduced to overcome the limitations of the PULL method. This client opens a connection to the server by requesting only for the first time and the server keeps pushing the updates to the client whenever there is any. This is called the publisher/subscriber model.
Few technologies involved in the HTTP PUSH methods are Ajax long polling, web sockets, Server-Sent Events with HTML5 event source, Message Queues, Streaming over HTTP.
This post is just a part of Web Architecture where there are many more components to discuss. Stay tuned for the second and third parts of this post which will involve more exciting topics like caching, load balancing, etc.