One , background & problem

   The previous framework is based on SOA Distributed framework of thought design . Each application is provided by service , Communication between services is RPC Method call , The implementation is based on .NET Of WCF Communication platform . The framework exists as follows 2 Questions :

  1, Lack of high concurrency processing capacity . High concurrency request , Multiple services may be pending processing , This leads to the bottleneck of the whole system .

  2, With the wide application of mobile terminal , Services cannot be flexibly supported APP application .

  3, System continuous integration deployment is too cumbersome , It's not easy to locate when there is a problem .

   Upgrade the framework based on the above problems , Combined with the current mainstream architecture ideas , Service thinking of the system , namely “ Microservice architecture ”.


Two , Microservice architecture

   Microservice architecture (Microservices
Architecture) Is to split the system into multiple services , Commonly known as application services . Single application service , Specific business application functions , Support independent deployment and maintenance , Multiple application services to build a system . The application services are carried out through lightweight communication framework , And support application services with different technologies or platforms . Microservice architecture is SOA Another way to realize architecture design . Microservice architecture has the following characteristics :

 1, Benefits of microservice architecture

  (1) Extending application service horizontally to improve concurrent processing ability of system

  (2) Independent deployment and maintenance of application services , It is conducive to iterative development, upgrading and continuous deployment

  (3) Flexible architecture supports multiple technologies

  (4) It is conducive to high availability of application services

 2, Insufficient microservice architecture

  (1) There are some requirements for the system design , In particular, split technology application service interface

  (2) It leads to the increase of system implementation complexity

  (3) Need to ensure system data consistency mechanism

  (4) Lead to system maintenance requirements and cost increase

   Whether the system needs to use microservice architecture is determined by the project requirements . Using microservice architecture to design and build the system , The ability of team members is higher than traditional requirements , Especially the design ability .


Three , Frame design principles

  1, Scalable : Support not to modify system functions , Expand server resources on demand .

  2, High availability : Support distributed deployment dual machine hot standby mechanism , Meet the requirements of high availability of the system .

  3, High concurrency : Support rapid expansion of application service processing capacity , Improve system processing capacity , Satisfy concurrent requests .

  4, Security : Access security through unified authentication ; Information security through encryption and decryption , Signature transmission ; Network security through network isolation and firewall ; Data security through regular backup and high error tolerance .

  5, uniformity : Adopt data final consistency strategy .


Four , Overall design of frame


  chart 1- System architecture diagram

   As shown in the figure , System architecture based on SOA Architecture design idea , And micro service architecture is used to design and build . Separation of system presentation and data . System rendering is based on Web page , Support multiple front ends UI Framework integration and custom development ; Data is provided by application services , Unified adoption “ gateway API” Provide for use . Architecture support through network layer , Load balancing middleware of application layer , Achieve high availability and concurrent processing capabilities . Architecture separates some basic public functions into middleware .

  1, gateway API: Application service through gateway API Unified external service provision . gateway API be based on http agreement , with restful Mode provides a unified service interface , Agreement interface communication protocol , Support the functions presented by the system , In a lightweight way of communication , Satisfy different clients . gateway API Realize unified data access control , Routing application service , Current limiting and other functions .

  2, Message platform : Responsible for updating synchronization information between application services , The way to update information by calling distributed transaction of original system architecture , Adjust to publish asynchronously through messages / Subscription processing , Ensure the final consistency of data , Reduce coupling and strong dependence between application services . Under high concurrency capability , Get cache effect .

  3, Service registration monitoring center : Responsible for application service registration, release and registration , At the same time, monitor the operation of application service interface , Support dynamic control of application service receiving request , realization “ Decentralization ” service control . Component implementation service registration , Monitoring and other functions .

  4, authentication center : Responsible for unified authentication of architecture access . Access is controlled by user password and authority . combination “ gateway API” Secure access , Current limiting and other functions , At the same time, the page management function is realized .

  5, Log management system : Responsible for recording system log , Providing service interfaces and components , Business code transfers log information asynchronously to the “ Message platform ”, Log management system subscription “ Message platform ” The log information is processed and stored . It also provides log management function

  6, Cache Center : be based on Redis Distributed memory database , Building a unified cache Center , Provide unified cache service .


Five , Software architecture design


  chart 2- Software architecture diagram

   As shown in the figure , The system architecture is developed by microservice architecture , Observe each application service from the perspective of vertical independent development , Divide levels according to responsibilities , It is divided into four levels from top to bottom , Respectively Web layer , Service interface layer , Business logic layer and data access layer .Web Layer is mainly responsible for the presentation and expression of system functions , Face users directly ; The service interface layer is mainly responsible for providing standardized service interface , Docking with presentation layer ; Business logic layer mainly realizes application business logic , It is the core part of application service ; The data access layer is responsible for data persistence , Support business logic layer . Each layer is isolated by interface , It is conducive to subsequent maintenance and expansion , Reduce dependence and impact .

   After the development of application services, the integration deployment is carried out .Web Layers will be integrated into the Web Application container , The other layers are built for application service deployment , And register and publish the service interface .

Six , epilogue

   This is the general design of the infrastructure , Deployment also needs to be considered , Elastic resources of cloud platform can be considered , Reconstitution docker Container technology .

   The design and implementation principle of related basic components are introduced step by step . Technology framework is more important than problem solving , Design depends on requirements , Demand source actual business scenario .


author : Liu Caitao

official account :【51dotnet】