Design of microservices architecture

As AN IT practitioner, we often encounter problems like the following:

  • Individual projects are huge, heavy and difficult to maintain.
  • System stability can not be more effectively guaranteed.
  • How to continuously improve the performance of the system.
  • How to respond quickly to changes in requirements without any jitter from system updates.
  • How to better adapt to the expansion of system scale.

In view of these problems, we are constantly trying and exploring to find better solutions or use more advanced technologies.

At present, the micro-service architecture design generated in the Internet environment is an ideal solution.

Overall architecture design of micro services

Figure 2-1 shows the overall architecture design of an e-commerce platform that uses micro-services.

This is a typical microservice overall architecture design diagram. From top to bottom, it can be divided into the foreground application layer, API access layer, business application layer, service center and basic resource layer structure, each layer structure has its own functions and special design.

The foreground application layer can support any application client, such as the Internet of Things, wechat small program, mobile App API open platform, etc.

The API access layer can use the Spring Cloud Zuul Gateway to design a Gateway, which acts as a link between the preceding and the following, and has authentication, routing and flow control functions.

The business application layer is the basic application of microservice, and it is also a microservice. Here is mainly some background management functions of e-commerce platform

Among the services are various AP interface services designed by microservices. These services generally use the design based on ST cutting style and provide lightweight API interface services externally. In addition, the basic service middleware provides service governance, message queue, alarm monitoring, configuration management and other services.

Basic resources are private clouds or public clouds rented by us to build container platforms for microservices and provide data storage, DevOps mirror warehouse and other services.

In this architecture design, in addition to the above, in the horizontal direction, you can also see load balancing, logging, link tracking, and operating platform services based on large e-commerce platforms.

The following describes the advantages of microservices architecture design and the high concurrency and high performance characteristics it presents.

  • Natural stress breakdown.
  • Flexible and scalable cluster environment.
  • Highly independent design.
  • Hierarchical invocation relationships of APIS.
  • Highly available base resource support.
  • Rapid response automation infrastructure.
  • Perfect monitoring system.
  • The security of micro services.

Natural stress breakdown

When a large system is designed with a microservices architecture, the stress on a single application is naturally spread across many microservices. Individual microservices can use different databases and can be deployed separately on different servers, all of which is a way to distribute pressure.

Flexible and scalable cluster environment

The deployment and distribution of microservices will eventually be incorporated into the governance environment of microservices. This governance environment is a distributed cluster management system. For each micro-service, a series of management and control measures such as dynamic routing, load balancing and service degradation can be implemented. At the same time, each microservice is allowed to expand and contract freely according to the pressure it is under, that is, it has the characteristics of elastic expansion and contraction.

Figure 2-2 is a schematic diagram of a microservice operating environment. Whether it is a STAPI microservice providing interface services or a webui. microservice providing operation interfaces, it can be easily added to the cloud server to expand its load capacity as required. Moreover, this scale is not limited to a virtual environment, it can be across machine rooms, across regions, and even across borders. Of course, the basic resources used by microservices also have the ability to expand freely. This ensures that any highly concurrent calls can be handled across the system platform without performance bottlenecks.

Highly independent design

The decentralized design feature of microservices architecture provides a high degree of independence for the design of each microservice. In this way, we can choose the database or communication mode according to the characteristics of each microservice to play its unique performance.

For example, traditional relational databases such as MySQL or Oracle can be used for data with a small amount of data and complex correlation. The MongoDB NoSQL database can be used for large amounts of data that are not updated frequently. For some complicated and associated data, you can use graph database, such as Neo4j. In this way, using the right database for different business characteristics can maximize the performance of the application.

For communication methods, some programs are very sensitive to real-time data and can only be called in real time by using the interface; while some programs do not require much real-time data, but have a lot of traffic, so asynchronous messages can be called.

In this way, you can maximize the effectiveness of your application through targeted, independent design.

Hierarchical invocation relationships of APIS

Microservices use the GateWay interface to provide services for the external environment. In this Way, a hierarchical structure is used. The RESTAPI microservices interface service can be directly called in the Gate Way layer, or another layer can be designed, that is, the Backendfor Frontend layer is used to wrap complex calls. For example, when multiple microservices need to be called, the calls can be assembled into a single interface service to avoid multiple communications between the internal and external environments of the microservice. In addition, some communication can be done asynchronously using MQ (Message Queue).

Figure 2-3 is a diagram of a GateWay multi-layer invocation relationship, in which each layer can be designed for load balancing to greatly improve the concurrency of such invocation relationships. Among them, the load balancing design of micro-service internal environment can be handled by service governance, while the load balancing design of GateWay in external environment can be implemented by Nginx and other tools.

Highly available base resource support

In microservices architecture design, cloud services are often used to build the infrastructure resources. Cloud services can either rent servers from cloud service providers, build their own private clouds, or both.

Cloud-based basic resources, including databases, caches, and file systems, can use high-quality RDBS, distributed database, and object storage services provided by cloud service providers, or build various cluster systems by themselves.

This ensures that the use of each basic resource does not become a bottleneck for another system, which is a strong complement to and support the design of high parallel microservices architecture.

Fast response automation infrastructure

Automation infrastructure construction is a basic requirement in microservices architecture design, involving a series of issues such as code management, code inspection, integration testing, automated testing, continuous delivery, automated deployment and so on.

Whether it’s continuous integration, continuous delivery, agile development, etc., these are all management mechanisms for DevOps. This management mechanism can improve the strain capacity of each micro-service application in the design of micro-service architecture, and can quickly respond to the changes and updates of the whole system, thus fully improving the overall efficiency of the whole micro-service architecture.

Perfect monitoring system

By using the Sp Cloud suite of tools combined with third-party tools, we can build a comprehensive monitoring system for the operation environment of microservices, thus effectively ensuring the stability and robustness of microservices.

The monitoring system includes health check, alarm system, link tracing, log recording, and query. The health check and alarm system help you discover potential problems and hazards in the system in a timely manner, thereby reducing accidents. Link tracing and logging can provide a very detailed service invocation trail, which is ideal for checking and finding complex internal system problems or hidden errors that may exist.

The security of micro services

The larger the system, the higher the concurrency, the greater the risk, and the more important its security. The security design of the system includes firewall design, anti-attack design, access control design, data security design, data backup and disaster recovery and so on. Security protection is the first barrier of system security. We will use firewalls and dynamic sensing devices to provide a secure and reliable distributed environment for the establishment of microservice servers.

Figure 2-4 shows a security management architecture designed by AliYun. Security protection and early warning are used to isolate insecure access or possible attacks, ensuring system security and stability.

If cross-equipment room or cross-region micro-service interconnection is required, ensure security by using dedicated channels on a VPC private network.

summary

The microservices architecture design style is itself a highly concurrent mechanism. Relying on the cloud service environment, we can take the basic resources used by microservices and provide a scalable, highly concurrent and highly available environment through the construction of automated infrastructure. At the same time, the high degree of extensibility of microservices is fully guaranteed through the use of Spring Cloud tool suite and third-party libraries. No matter what kind of architecture design, the stability, robustness and reliability of the system are all indispensable.

Three things to watch ❀️

If you find this article helpful, I’d like to invite you to do three small favors for me:

  1. Like, forward, have your “like and comment”, is the motivation of my creation.

  2. Follow the public account “Java rotten pigskin” and share original knowledge from time to time.

  3. Also look forward to the follow-up article ingπŸš€

  4. [666] Scan the code to obtain the learning materials package

Article is not original, and all of us feel while reading the article good remember thumb up forward + attention oh ~ this article source: www.toutiao.com/i6898321081…