From: http://www.cnblogs.com/mikelij/archive/2010/10/26/1856014.html#commentform
Preface
My work experience in. Net in recent years has made me want to write about the large-scale Asp.net application system architecture for a long time (for years ).ArticleThoughts. When chatting with colleagues, I talked about some piece of thinking. The ideas were not perfect. After chatting, I thought about them carefully. Some ideas gradually became clearer. Now I have finally put it into action. I will discuss some ideas with you, which is a summary of ASP. NET over the past few years. This is also a learning process for me.
I have read some of my colleagues on system architecture or enterprise application architecture. As far as I have read these articles, I found that many of them write hierarchical architectures. In my opinion, layering is good. However, if I write it myself, I will start from the architecture selection. Then the applicationProgramYou may choose another architecture instead of a layered architecture. In addition, I will write from the perspective of the entire system, that is, to think about a system from both the hardware and software perspectives.
These are some of my suggestions and hope to help you.
Introduction
Large Asp.net applications must consider how to serve a large number of visitors and ensure that each visitor has a high-quality service. Users in different languages need to be faced; security needs to be ensured; application systems are also highly scalable. When the server cluster is a little insufficient to handle the pressure, you can add more servers to the server cluster to increase the service capability of the entire application system. The availability of the server is also very high, and the downtime for one year is very small. Server Disaster Backup is also good. Even if the current data center suffers a devastating blow, there are also Disaster Backup services that can be restored. The Asp.net application running on the server is scalable and has good scalability and good maintainability. This series of articles will talk about many aspects of the large-scale Asp.net application system architecture. This article describes the architecture selection.
Architecture Selection
The architecture selection depends on the application type. This is the Asp.net application, so the client-server architecture is obviously excluded. Remaining:
Component-based architecture
Applications can be divided by components without implementing different functions and logic. The interface specifications between components are well defined. Some components can be reused.
Layered layered architecture
Applications are divided into several layers that are stacked together. Each layer provides specific services and functions. The call relationship between each layer and its interfaces is called. At the top layer, only the lower layer is called, while the middle layer is both called and called. In the bottom layer, only the above layer is called. Usually divided into the UI Layer, business logic layer, data layer, and so on, and usually multiple layers are deployed on the same server.
Message Bus Architecture
The application sends and receives messages in a predefined format. There is a message queue and a message storage, distribution and processing task. Events of related messages are processed by the program. Supports different system platforms. The message bus contains several defined message streams. The message bus exchanges data with various system platforms and supports different formats. Send messages to different processing programs for processing.
Model, view, controller (MVC) Architecture
Separation of user interaction processing and UI display
User interaction processing, UI display, and data separation
3 tier/N tier architecture
Tier can be translated into rows. It is different from layer. Divides applications into a series of services, including services such as UI, business (business logic), and data. Each tier can be deployed on different servers. Similar to a layered architecture. Generally, layers do not span the boundaries of machines, that is, all layers are deployed on one server. Tier is the boundary between machines. Each tier uses a predefined communication protocol, such as WCF, Web Service, or TCP/IP. The communication between layersProgramming Language. So there is a difference.
Object-oriented Architecture
Applications can be divided into self-contained reusable object sets, which contain data and behavior. Each object has message interaction.
Service-Oriented Architecture
An application uses a function to call a service. There is a communication contract and message between the service provider and the caller. The communication contract defines the Message format and communication mode. A message contains the communication content. The Service-Oriented Architecture is the "request-response" working mode. An application is provided by a service. The caller needs to send a predefined request message to the service before the service responds.
These architecture types can be used to develop Asp.net applications. We can select a combination of architecture types, for example, layered architecture + service-oriented architecture. MVC Architecture + message bus architecture. The specific selection depends on the application requirements. Now let's talk about how to select the architecture:
If
- There are several ready-made components, such as ActiveX components of the previous system or. NET components.
- Applications are simple enough without a layered architecture. Most of the work can be done by calling these components.
- Components developed in different languages need to be combined. For example, Asp.net needs to call COM + components written in VB.
- Applications must support plug-in technology and can dynamically switch components, such as plug-in technology implemented by. Net reflection technology.
We can choose a component-based architecture.
If
- Applications are complex. Different features require different layers to perform their respective duties, such as data access, business logic, and performance.
- There are complex business logic and processes.
Then we can choose a layered architecture.
If
- There are several existing systems and specific interactions between these systems
- A system needs to interact with other external systems
- Systems on different platforms interact with each other
Then we can choose a message bus architecture.
If
- To obtain the separated UI view and processing logic
- Ui view and processing logic separated from Data Storage
Then we can choose the model, view, controller (MVC) architecture.
If
- All applications are on the Intranet.
- Applications on the Internet, and business logic needs to be exposed to the public
- Business logic is complex enough and requires dedicated servers to provide business logic services.
- Applications are complex. Different functions are distributed on different servers. Each function may be provided by a group of servers.
Then we can choose a 3tier/ntier architecture.
If
- There are enough real objects in the relevant business field (these objects are usually nouns in the mouth of the relevant business personnel) and there is interaction between these objects.
- The application is complex and requires more abstraction.
- Data and behavior of objects must be encapsulated for reuse.
- Have sufficient resources for in-depth object-oriented analysis, such as time and manpower.
Then we can choose an object-oriented architecture.
If
- Applications must support platform independence
- The functions of multiple applications are provided on a single interface.
- Run in request-response mode
- Software plus service (software as a service) needs to be developed, or applications based on cloud computing
Then we can choose a service-oriented architecture.
For the current scenario: Large ASP. NET applications, the most basic requirements may be as follows:
At the same time, there will be a considerable number of users, such as thousands and tens of thousands.
Million User Access
In some places, You need to log on to obtain information that requires authorization.
The architecture combination we may choose may be as follows:
3 tier/N tier architecture
Model, view, and controller (MVC) architectures are combined with 3 tier/N tier architectures.
3 tier/N tier architecture combined with service-oriented architecture
3 tier/N tier architecture combined with object-oriented Architecture
Of course, it may also be other combinations.
The layered architecture is not suitable for large ASP. NET applications. The layered architecture usually deploys the UI Layer, business logic, and data access layer on the same server. First, a server cannot afford many users, there is also a complicated business logic that not all one server can afford. Therefore, the layered architecture is not suitable for large ASP. NET applications. Small ASP. NET applications are suitable for layered architecture.
The component-based architecture is not suitable for large ASP. NET applications. Generally, large ASP. NET applications are quite complex. Their UI, business logic, and data are all complex. It is not easy to call a few controls to complete most of the work, large ASP. every tier of the. NET application requires a large number of servers to share the pressure, and the distributed capability of the component-based architecture is limited. Therefore, the component-based architecture is usually not in large-scale ASP. net Applications, unless there are several important controls, and you need to consider integrating controls in multiple programming languages, the component-based architecture will be considered. It is used in a certain part, that is, it must be used together with other architectures.
The message bus architecture can be used in the development of large ASP. NET Applications in some scenarios. Generally, you need to integrate multiple system platforms. The message bus architecture must be combined with other architectures to construct ASP. NET applications.
The MVC Architecture focuses more on the UI, user interaction control, and data access isolation. Generally, a large ASP. NET architecture cannot be constructed separately. It is necessary to combine the 3tier/ntier architecture to construct a large ASP. NET architecture. The MVC Architecture has a fixed pattern in the UI and user interaction. Therefore, you can apply the MVC Architecture in the UI. When the MVC model is involved, it can be extended to a 3 tier/N tier architecture. That is, when accessing the model, you can access the business logic and data storage on another server. This can be used to indicate:
The object-oriented architecture is the result of the process of Object-Oriented Analysis and Design in applications. This result reflects the interaction between objects in the real world. The object-oriented architecture should be combined with other architectures such as the 3tier/ntier architecture to jointly construct the architecture of ASP. NET applications.
Service-Oriented Architecture is required in specific scenarios. As mentioned above, multiple functions serve as a service and provide a unified UI for external users. In large ASP. NET applications, business logic is usually provided for public access. Then we can adopt a service-oriented architecture. The service-oriented architecture also needs to combine other architectures such as the 3tier/ntier architecture to construct the architecture of ASP. NET applications.
The 3 tier/N tier architecture is required for large ASP. NET applications. Each tier is composed of several servers. Only in this way can we serve a large number of users. As shown in the figure above, the UI calls the business logic Service Interface on another server when calling the business logic across the boundary of the machine.
Conclusion
The architecture needs to be selected based on the characteristics of different architectures and application requirements. Sometimes, a combination of multiple architectures is required to meet the needs of a complex application. The designer needs to determine the appropriate architecture selection based on the actual situation.
next we will talk about the 3 tier/N tier architecture ......