How to choose the right type of web application architecture
Any program, from a web application to a system for a large enterprise, is based on a specific architecture. The selected architectural pattern determines all the further logic of building the application, the interaction of its elements and functionality. Therefore, it is highly desirable to understand the peculiarities of various types of architectures before you start developing the application.
What is a Web Application Architecture?
To begin with, architecture is a crucial part of any software. We won’t go into details here, let’s better look what Martin Fowler says about the importance of software architecture:
A web application architecture is a pre-built interaction between middleware systems, user interfaces, and databases. The general concept of web application architecture is in line with the concept of a browser user who runs an application that can be used on multiple websites.
Each architecture has its own purposes, respectively, the choice of the web app architecture type depends on what problem you need to solve with it.
Below we will tell you about the most popular and multifunctional types of architectures that help qualitatively solve the most common requirements of different types of modern applications.
Web App Architecture Types
Single-page applications - like desktop, but in browser
SPA (Single Page Application) is a one-page web application that loads on a single HTML page and does not require reloading. This is achieved through dynamic updates using the AJAX approach, which allows to increase the convenience of user interaction, save traffic and reduce server load. SPA work is performed inside the browser, and the code is rendered on the user side.
Popular examples of dynamic sites are Gmail, Google Maps, Facebook. When you go to them, the first thing you receive is the main content. To perform various actions (scrolling, moving to other pages), instead of reloading the pages, only certain elements are loaded. Thus, there is no need to reload the same elements. It is very convenient for developers and users.
The advantages of single-page web app architecture include the following aspects:
- high speed comparing to traditional sites;
- good functioning on both desktop and mobile devices;
- flexibility and responsiveness that are achieved thanks to the fact that there is no need for reloading and re-rendering;
- Optimized and simplified development.
- increased browser load;
- the need to provide good data protection - due to cross-site scripting (XSS), hackers can
- get access to the code and add scripts on the client side.
Microservices - lay the foundation for further development
Many applications that we regularly intersect with (Internet banking, entertainment services like YouTube and so on) are often created using a set of different services that somehow coexist and do not look fragmentary.
This effect can be achieved using microservices - an architectural pattern in which all its components (the services themselves) have the following characteristics:
The development of the service shouldn’t require many experts. One team can develop several services.
One service performs only one function. Such services are easier to develop and maintain.
Changes in one service do not affect another. This allows you to achieve the autonomy of different services.
- Distributed according to business needs
A component or class is created taking into account all methods of solving a business problem.
If a classic monolithic application usually has the standard structure, like: Interface → Business Logic → Data, then microservices are based directly on business logic.
One service should solve one problem and such tasks are determined by the parts of the application responsibility. For example, there may be different services for teams working on the same project. This leads to the formation of cross-functional teams having a complete set of necessary skills.
Typically, microservice web app architecture is used as one of the options for scaling an application. In general, there can be three options:
- 1. Sharding — data and access tools are located on different nodes.
- 2. Mirroring — duplication of all data on many identical nodes.
- 3. Microservices — the functionality is divided into business tasks, each service can be created with its own development tools.
Advantages of microservices:
- Clear division by modules. It is always clear how any part of the code works. It is quite easy to add new features.
- High availability. If some part of the monolith breaks, the entire application will break. From this point the use of microservice web app architecture is more beneficial: not all services can work (for example, not critical, like authorization), but the application remains available.
- A variety of used technologies. When developing each service, you are free to select the tools that are the most suitable for the specific business logic in particular service. For example, you can choose different programming languages, the optimal database and convenient tools for working with it. Microservice web application architecture also allows to try a new technology on a separate service without rewriting the entire application.
- Relative ease of deployment. Each service rises independently, which makes the deployment and debugging process cleaner.
Disadvantages of microservices:
- The complexity of the development. If you need a quick solution (prototype, small application, tight deadlines), then microservices web app architecture is not for your project. Development speed - is a high pay for availability and modularity.
- Complexity of support. Each microservice needs separate maintenance, therefore constant automatic monitoring is necessary.
Serverless architectures - forget about infrastructure costs
Software development usually involves managing the physical infrastructure for running of the code and server maintenance. With the advent of serverless computing technology, application owners can minimize administrative costs and focus on the development of the software part of the product.
It is worth to admit, that the term “serverless computing” is not entirely correct as the l servers are still used.
Server management is carried out by cloud service providers using automated systems.
Serverless web app architecture advantages:
- Lower cloud costs. Cloud resources are paid only when they are actually used. In other words, you pay only for the time when your application is runned in response to user requests.
- Cutting of development costs. There is no need to maintain the infrastructure, since you can rent most of the resources required for software development.
- Flexible scalability. Serverless web app architecture has the ability to scale according to the application workload. You don’t need to purchase additional infrastructure in case of unexpected growth.
- Faster releases. To deploy new features, developers only need to compile their code, archive it, and upload it to the Serverless platform. There is no need to write scripts to deploy features.
- Built-in registration and control mechanisms. Serverless vendors have developed own user registration and monitoring solutions, so developers don’t have to purchase third-party tools for similar purposes.
- Serverless platforms can be used for development of applications that can easily integrate with various advanced technologies, such as the Internet of things (IoT) and mobile devices.
The main problems of serverless web app architectures:
- Cost. The fact that serverless computing can significantly reduce development costs is not always true. For example, serverless functions are currently the most attractive for computing related to the CPU (Central Processing Unit). Whereas the functions related to input / output are not as accessible as on dedicated virtual machines or containers.
- Resource limitation. Resource limitations are necessary for the platform to cope with changes and resist attacks. Serverless computing imposes restrictions on memory, runtime, throughput, and CPU usage.
- Security questions. There is a risk of unsafe operation, as many users run their functions on a common platform. Thus, when downloading malicious code, negative consequences for the operation of other applications are possible.
- Monitoring and debugging. Since software developers do not have control over the provider's servers, there are limited options for identifying problems.
Event driven architectures - high speed and instant response
Event-driven web application architecture in general, and Event Sourcing in particular, are on the rise in the last couple of years. This approach to data storage allows, instead of the final result, to store a series of records of events that occurred with some entity. In this case, the developer prescribes behavior (reactions) for the program when any events occur. An event in the system is a change in its state.
Let’s draw an analogy with buying a car in a showroom. When someone buys it, its condition changes from “for sale” to “sold”. This event launches the pre-sale preparation process - installation of additional equipment, verification of technical condition, etc.
Advantages of an event-driven web app architecture:
- Since applications consist of a large number of asynchronous modules (which do not have information about each other's implementation), they are easy to scale. Such systems are assembled as a constructor - you do not need to register dependencies, it is enough to implement a new module.
- Asynchronous model allows you to achieve high performance of the applications.
Disadvantages of event-driven web app architecture:
The asynchronous nature of such applications complicates debugging. One event can trigger several chains of actions at once. If there are a lot of such chains, then it can be difficult to understand what exactly caused the failure. To solve problems, you have to work out the difficult conditions for error solving.
The event-driven architectures are the best solution for:
- organizing messaging between different information systems.
To sum up, the right choice of the web app architecture type is very important, because it will determine the overall functioning of the application: reliability, response speed, usability, etc. Of course, it’s hard to determine a particular type of architecture which is ideal for every product. After all, it all depends on your individual needs, priorities, the specifics of the tasks that the application performs. Moreover, it is often difficult to make a decision because of a lack of technological expertise. In such cases, you need detailed expert advice. You can read how to get it in our article IT Consulting: How it works.