What is a monolithic architecture
An archive (for example, in WAR format or Jar format) contains the application that applies all the functionality, often referred to as a singleton application. The monolithic application methodology, which we call monolithic application architecture, is a more traditional architectural style.
Example diagram of a single architecture
Defects in a single architecture
1. High complexity
The whole project contains a lot of modules, the boundary of modules is fuzzy, the dependency relationship is not clear, the code quality is uneven, the whole project is very complicated. Every time you make a change to your code, even adding a simple feature or fixing a BUG can lead to hidden bugs.
2. Technology debt is rising
Over time, requirements change, and people change, an application’s technical debt builds up and builds up. The used system design or code is difficult to modify because other modules of the application may use it in unexpected ways.
3. The deployment speed slows down
As the code increases, so does the build and deployment time. In a single application, every functional change or bug fix causes the entire application to be redeployed. Full deployment takes a long time, has a wide range of impacts, and has high risks. As a result, single application projects are rarely deployed online, resulting in a large number of functional changes and defect fixes between releases, and a high probability of errors.
4. The expansion capacity is limited and cannot be scaled on demand
Individual applications can only be expanded as a whole, but cannot be scaled based on the characteristics of service modules.
5. Hindering technological innovation
Individual applications often use a common technology platform or solution to solve all problems. Every member of the team must use the same development language and architecture, and it is very difficult to introduce new frameworks or technology platforms. As the shortcomings of monolithic architectures become more apparent, more and more companies are adopting microservices architectures to address the problems mentioned above. Rather than building a single, massive application, a microservice architecture breaks the application down into a set of small, interconnected services.
SOA architecture
SOA stands for Service-oriented Architecture. The services here can be understood as service layer business services.
Single application Architecture
When site traffic is low, only one application is needed to deploy all functions together to reduce deployment nodes and costs.
Vertical application Architecture
When the volume of traffic gradually increases, the acceleration caused by the increase of a single application machine is getting smaller and smaller. The application is divided into several unrelated applications to improve efficiency.
Distributed Services Architecture (Benefits at the end)
With the increasing number of vertical applications, the interaction between applications is inevitable. Core businesses are extracted as independent services, gradually forming a stable service center, so that front-end applications can respond to changing market demands more quickly.
Mobile Computing Architecture
As the number of services increases, problems such as capacity evaluation and waste of small service resources gradually emerge. In this case, a scheduling center needs to be added to manage cluster capacity in real time based on access pressure to improve cluster utilization. At this point, SOA service governance solutions for improving machine utilization are key. Dubbo is the core framework for SOA service governance solutions. Summary: Dubbo can not only govern services, but also invoke them.
Microservices Architecture
In short, the development approach of the microservices architecture style is to develop a single application system by developing a set of small services. Each of these small services runs in its own process and often uses the lightweight mechanism of the HTTP resource API to communicate with each other.
These services are built around business functions and can be deployed independently through a fully automated deployment mechanism. These microservices can be written in different languages and can use different data storage technologies. We have minimal centralized management of these microservices.
Sample diagram of microservices architecture
Characteristics of microservices architecture
Each microservice can run independently in its own process, and a series of independent microservices together build the whole system. Each service is an independent business development, and a microservice focuses on a specific function, such as order management, user management, etc. Microservices communicate with each other through lightweight communication mechanisms, such as REST API interfaces for invocation, and automatic deployment mechanisms using different languages and storage technologies
Advantages of microservices architecture
1. Easy development and maintenance
A microservice focuses on a specific business function, so it has clear business and less code. It is relatively simple to develop and maintain a single microservice. The entire application is built by several microservices, so the entire application will be maintained in a controllable state.
2. A single microservice starts quickly
A single microservice has a small amount of code, so it will start up quickly.
3. Partial modification is easy to deploy
Microservices solve the problem of redeploying the entire application whenever a single application is modified. Generally speaking, to make changes to a microservice, you just need to redeploy the service;
4. Technology stack is not limited
In microservices, we can combine the characteristics of the project business and the team to choose a reasonable technology stack
5. Scale on demand
Challenges of microservices architecture
1. High requirements on operation and maintenance
More services means more operations. In a single architecture, only one application needs to run properly. However, in microservices, it is necessary to ensure the normal operation and collaboration of dozens or even hundreds of services, which brings great challenges.
2. Inherent complexity of distribution
You build distributed systems with microservices. For a distributed system, system fault tolerance, network delay, distributed transactions and so on all bring great challenges.
3. Interface adjustment costs are high
Microservices communicate with each other through interfaces. If you modify the API of a microservice, you may need to modify all microservices that use the interface.
4. Rework
Many services may use the same functionality. This feature is not decomposed into a microservice, at which point it may be developed by each service, resulting in code duplication.
Principles of microservice design
Single Responsibility principle Service autonomy Principle Lightweight Communication principle Interface clarity principle
Differences between microservices architecture and SOA
The first emphasis of the microservices architecture is that business systems need to be thoroughly componentized and servitized
Microservices no longer emphasize the ESB enterprise service bus, which is more important in the traditional SOA architecture, while the idea of SOA enters into a single business system to achieve true componentization.
The difference between distributed – microservice – cluster
Service A, B, C, and D are service components that access services through API Geteway.
A large system is divided into multiple service modules, which are deployed on different machines and interact with each other through interfaces.
The way to differentiate distributed is by different machines and different services.
Note: Distribution requires good transaction management.
Cluster pattern
In cluster mode, the same set of services are deployed on different servers to implement load balancing.
Cluster differentiation depends on whether services are the same when multiple servers are deployed.
Note: In cluster mode, session sharing is required to ensure that the service will not be stopped and quit when switching between different servers because no session is obtained.
General configuration of Nginx* load container implementation: static resource caching, Session sharing can be implemented, Nginx supports 5000 concurrent volume.
Is distributed a microservice?
(Benefits at the end)
The answer is yes. Microservices means that modules are divided into independent service units to realize data interaction through interfaces.
Microservices Architecture
Microservices are designed so that a module upgrade or BUG will not affect the existing system business.
The subtle difference between microservices and distribution is that the application of a microservice does not have to be distributed on multiple servers; it can also be on the same server.
Distributed and microserver architectures are similar, just deployed differently.