Learn about the software architecture

Tram Ho

When designing for a web application, choosing the design structure for the app is extremely important. It will determine whether the application is efficient, easy for maintenance and further development in the future. This article will learn about web architecture and related concepts, to get the best overview and help in choosing system design more accurately.

1. Software architecture

1.1 Concepts

Software architecture (SA) covers the most important components of a system, their relationships and how they interact with each other. It is seen as a blueprint, providing a model for system management and setting up and coordinating communication between components.

  • Architecture defines a solution to meet technical and operational requirements. with the overall goal of performance and security.
  • Architectural design is a combination of the needs of the organization as well as the needs of the development team. Each decision should be considered affecting the quality, maintenance, and performance of the project

1.2 Why they are important

The key to success when building anything is doing the basics right. Whether it’s building a house or even making a cake, if the base doesn’t work, you have to start over.
The same goes for building a web application. Architecture is fundamental and must be carefully thought out to avoid major design changes and refactor code later on. Many engineers will say you don’t want to have to redesign. It will slow down the project realease date, wasting human as well as financial resources.
Depending on what stage in the development process we are faced with due to decisions made in the early design phase. So, before getting into the code, it’s best to get the basics right.

1.2. The difference between software architecture and software design

We will clarify these two concepts to avoid confusion:
Software architecture is used to define the framework and top level components of the system, and how they work together. For example, we need a serverless architecture that breaks the application down into two components: BaaS (backend-as-a-service) and FaaS (functions-as-a-service), or a microservice architecture where the functions are divided into separate modules. Choosing an architecture will determine how we handle performance, fault tolerance, scalability.
Software design is responsible for code design level, how the module is coded, class scope, and function purpose. When used correctly, the programmer will work more efficiently, avoiding rotation. They also provide a common language for conceptualizing repetitive problems and the solutions they encounter.

2. Software architecture design patterns

2.1 Client-Server

The architecture works based on the request-response model. The client sends a request to the server to get information and the server returns the data.
Every website we visit such as blog, Facebook, Twitter is built on client-server architecture.

2.2 Peer to peer

A network where each computer is seen as a node communicating with each other without the need for a centralized server. Absence of centralized server eliminates the single point of failure problem. All computers on the network have equal rights. Each node plays the role of seeder and the leecher at the same time, so even though some of the computers (node) are not working, the system still runs.

2.3 Model-View-Controller (MVC)

MVC architecture is a software architectural pattern in which application logic is divided into three components based on functionality. Components include:

  • Models – represent how data is stored in the database
  • Views – displays information for the user (GUI)
  • Controllers – component acts as an interface between model and view.

2.4 Microservice

In microservices architecture, the different functions are divided into separate modules, linked together to form a large service. Learn more about microservice here

2.5 Event driven

In the Event-Driven architecture, when a service performs some work that other services are involved in, that service generates an event, a record of the task performed. Other services use those events in order to perform any of the tasks needed as a result of the event. Unlike REST, the services that make the request do not need to know the details of the services used. They are capable of handling a large number of concurrent connections with minimal resource consumption. Modern applications need a fully asynchronous model for scaling.

2.6 Layered

This pattern is used to structure the program that can be decomposed into subgroups, each with a different level of abstraction. Each layer provides service to the higher level layer.
Here are some common layers:

  • Presentation layer
  • Application layer
  • Business logic layer
  • Data access layer

3. How do I decide whether the tier number of the application is

Single tier application

Advantages:

  • There is no lag
  • Fast data transmission
  • Data does not need to be transmitted over the network, ensuring safety Disadvantages:
  • Difficult to design new functions
  • Testing must be extremely thorough
  • Easily reverse engineered

Two-tier application

Advantages:

  • The database server and the business logic are close together (physically), so the performance will be high
    Defect:
  • Since the client keeps most of the application’s logic, problems arise when it comes to version control of the application and delivery of a new application.
  • Lack of scalability because it only supports a small number of users, performance decreases when many users request
  • Hard to reuse

Three-tier application

Advantages:

  • Put business logic in a centralized server, so data is guaranteed to be safe

Defect:

  • It takes more effort when applying 3 layers because the number of contact points will increase

N-Tier application

4. Horizontal or Vertical Scaling

If the application is just a utility or tool with a steady expected amount of traffic then this is not a problem, like an internal organization tool. Why must store in a distributed environment? One server is enough to manage the traffic, you should scale vertical when we know the traffic will not spike.

If the application is an application like social networking, fitness, … then the traffic could increase exponentially in the near future. In this case the availability as well as the ability to scale horizontal is important.

5. Monolith or Microservice?

When to use monolithic architecture

Monolithic applications are suitable for simple requirements, applications that only handle a finite amount of traffic. Examples are an organization’s internal tax calculation tool. These are the cases in which business traffic is defined as no exponential growth.

There are also cases in which development teams decide to start with a monolithic architecture and then extend to a distributed microservice architecture.
This helps them handle the complexity of the application step by step.

When to use microservice architecture

The microservice architecture is suitable for complex applications with large traffic volumes.
Social networking-style applications have many different components such as messaging, real-time chat, LIVE video streaming, image upload, like, share …

In this case, each component should be separate, each component being its own codebase.
We have 3 approaches:

  • Choose monolithic architecture
  • Select microservice architecture
  • Start with monolithic and change to microserver later

6. NoSQL or SQL?

When to use SQL database?

If you are building stock trading, banking or financial applications or need to store lots of relationships, such as social networking apps like Facebook, then you should choose a relational database for a number of reasons. The following:

Transactions and Data Consistency

  • If the software needs to work with money and numbers it needs transaction, ACID, data consistency. And the relational database does that well.
  • Storage relationships: If the data has multiple relationships, nothing is better than relationships with relational databases
    Some popular databases include: MySQL, Microsoft SQL Server, PostgreSQL

When to use NoSQL?

Some reasons to choose NoSQL include:

Handling lots of read / write

When you need to scale quickly, you should use NoSQL, for example when there is a large amount of read / write behavior on the website and need to process large data, NoSQL will respond perfectly to such scenarios.

Data analysis

NoSQL databases are also suitable for data analysis. Some popular NoSQL databases: MongoDB, Redis, Cassandra …

Thus, the article has explored some basic concepts in the software architecture with an overview. Hope the article helps everyone. See you!

Reference

https://www.educative.io/blog/how-to-design-a-web-application-software-architecture-101

Share the news now

Source : Viblo