Mind Mapping:
Nanyi (below)
Date: September 3, 2016
Software Architecture (software architecture) is the basic structure of software.
The right architecture is one of the most important factors in software success. Large software companies typically have a dedicated architect position (architect), which only senior programmers can hold.
O ' Reilly published a free booklet, software Architecture Patterns (PDF), which introduces five of the most common software architectures and is a very good primer. I benefited from reading, and here is my note.
First, layered architecture
The layered architecture (layered architecture) is the most common software architecture and the de facto standard architecture. If you don't know what architecture to use, then use it.
This architecture divides the software into several horizontal layers, each with a clear role and division of work, without needing to know the details of the other layers. The layer communicates with the layer through the interface.
Although there is no definite agreement, the software must be divided into many layers, but the structure of the four layer is the most common.
- Presentation Layer (presentation): User interface, responsible for visual and user interaction
- Business layer: Implementing Business logic
- Persistence layer (Persistence): Provides data, and SQL statements are placed on this layer
- Database: Saving Data
Some software adds a service layer between the logic layer and the persistence layer, providing some common interfaces required by different business logic.
The user's request will go through the four-tier process sequentially, and cannot skip any of these layers
Advantages
- Simple structure, easy to understand and develop
- Programmers of different skills can work on different layers, and naturally fit the organization of most software companies
- Each layer can be tested independently, and the interfaces of the other layers are simulated to solve
Disadvantages
- Once the environment changes, it is often cumbersome and time consuming to code adjustments or add functionality
- Deployment is cumbersome, even if only to modify a small place, often requires the entire software redeployment, not easy to do continuous publishing
- Software upgrades may require a full service pause
- Poor extensibility. When a large number of user requests increase, each layer must be expanded sequentially, because the internal coupling of each layer, the expansion will be difficult
Second, event-driven architecture
Event is a notification that the software sends when a state changes.
The event-driven architecture (Event-driven architecture) is the software architecture that communicates through events. It is divided into four parts.
- Event queue: The entry that receives the event
- Dispatcher (event mediator): Distributing different events to different business logic units
- Event Channel: The channel of communication between the distributor and the processor
- Event Processor: Implement business logic, issue events when processing is complete, trigger next action
For simple projects, event queues, distributors, and event channels can be integrated, and the entire software is divided into event agents and event handlers.
Advantages
- Distributed asynchronous architecture, high degree of decoupling between event handlers, and good scalability of software
- Wide applicability, all types of projects can be used
- Good performance due to the asynchronous nature of the event, the software is not easy to produce clogging
- Event handlers can be loaded and unloaded independently, easy to deploy
Disadvantages
- involves asynchronous programming (considering remote communication, loss of response, etc.), developing a relatively complex
- It is difficult to support atomic operations because events involve multiple processors and it is difficult to roll back
- Distributed and asynchronous features cause this architecture to be more difficult to test
Third, micro-core architecture
The microkernel Architecture (microkernel architecture), also known as the "plug-in Architecture" (plug-in architecture), refers to a relatively small kernel of software, with key functions and business logic implemented through plug-ins.
The core (core) typically contains only the minimum functionality that the system is running. Plug-ins are independent of each other, the communication between the plug-ins should be minimized to avoid the problem of interdependence.
Advantages
- Good function Extensibility (extensibility), what function is needed, develop a plug-in can
- Features are isolated, plug-ins can be loaded and unloaded independently, making it easier to deploy,
- High customization, adaptable to different development needs
- Can be incrementally developed, gradually increase the function
Disadvantages
- Extensibility (scalability), the kernel is usually a standalone unit that is not easily distributed
- It is relatively difficult to develop because it involves the communication between the plug-in and the kernel, and the internal plugin registration mechanism
Iv. Micro-Service architecture
The MicroServices Architecture (microservices architecture) is an upgrade of the service-oriented architecture (service-oriented architecture, abbreviated SOA).
Each of these services is a standalone deployment unit (separately deployed unit). These units are distributed, decoupled from one another, and are connected by remote communication protocols such as rest, SOAP.
The microservices architecture is divided into three implementation modes.
- RESTful API mode: Services are provided through APIs, and cloud services fall into this category
- RESTful Application Mode: Services are provided through traditional network protocols or application protocols, often in a multi-functional application, common in the enterprise
- Centralized message mode: With message broker, you can implement Message Queuing, load balancing, unified logging, and exception handling, with the disadvantage of a single point of failure and the possibility of a message broker being clustered
Advantages
- Good extensibility, low coupling between services
- Easy to deploy, software is split into multiple services from a single deployable unit, each of which is a deployable unit
- Easy to develop, each component can be continuously integrated development, can be deployed in real-time, uninterrupted upgrade
- Easy to test, each service can be tested individually
Disadvantages
- Due to the emphasis on mutual independence and low coupling, services may be split very finely. This results in a system that relies heavily on microservices, becomes messy and cumbersome, and has poor performance.
- Once communication between services is required (i.e. one service needs to use another service), the entire architecture becomes complex. A typical example is a generic Utility class, where a solution is to copy them to each service, with redundancy in exchange for the simplicity of the architecture.
- The nature of the distribution makes this architecture difficult to achieve atomic operations, and transaction rollback can be difficult.
Five, cloud architecture
Cloud Architecture (architecture) is the most extensible architecture, primarily addressing scalability and concurrency issues.
The main reason for its high scalability is that it does not use a central database, but instead copies the data into memory and becomes a replicable memory data unit. The business processing capability is then encapsulated into a processing unit (prcessing unit). When the traffic is increased, the processing unit is closed by the new processing unit and the traffic is reduced. Because there is no central database, the biggest bottleneck of extensibility disappears. Since the data for each processing unit is in memory, it is best to persist the data.
This pattern is divided into two main parts: the Processing Unit (processing unit) and the virtual middleware (virtualized middleware).
- Processing units: Implementing Business logic
- Virtual Middleware: Responsible for communication, maintain sessions, data replication, distributed processing, processing Unit deployment.
The virtual middleware also contains four components.
- Message middleware (Messaging Grid): Manage user requests and sessions, and decide which processing unit to assign to when a request comes in.
- Data Grid: Data is copied to each processing unit, i.e. data synchronization. Ensure that the same data is obtained for a processing unit.
- Processing middleware (processing Grid): optional, if a request involves a different type of processing unit, the middleware is responsible for coordinating the processing Unit
- Deployment Middleware (Deployment Manager): Responsible for processing unit startup and shutdown, monitoring load and response time, when the load increases, the new start processing unit, the load is reduced, the processing unit is closed.
Advantages
- High load, high scalability
- Dynamic deployment
Disadvantages
- Complex and cost-efficient
- Mainly suitable for the application of Web-site, large-scale database application not suitable for large data throughput
- More difficult to test
Software Architecture Classification (reprint)