Patent Publication Number: US-10778751-B2

Title: Method of micro-service transformation for power trading functions

Description:
This application is the U.S. national phase of International Application No. PCT/CN2017/117882 filed on 22 Dec. 2017 which designated the U.S. and claims priority to Chinese Application No. CN201711005376.1 filed on 25 Oct. 2017, the entire contents of each of which are hereby incorporated by reference. 
     FIELD OF TECHNOLOGY 
     The invention involves the field of power trading technology and especially involves a method for microservice transformation of power trading function. 
     BACKGROUND TECHNOLOGY 
     National unified power market trading platform is able to realize market functions including generation rights trade and direct trade among power users and possesses the capacity of multi-species and multi-cycle trading in parallel, which is of great practical significance to the improvement of power trading operation level and promotion of optimal allocation of power resource. 
     At present, national power trading market members are growing continuously and it raises higher and higher requirements on concurrency performance of system and others; however, for national unified power market trading platform in use today, project is huge in size, requirement, design, development, test and deployment procedures are fixed, new function needs to be modified and optimized on basis of original project, resource consumption rate of system is high, requiring level of the entire application is expanding, and development and maintenance are very inconvenient. Thus, it is necessary to conduct microservice transformation of power trading function to adapt to the requirement of business development on system application. 
     CONTENTS OF THE INVENTION 
     Regarding problems in background technology, the invention provides a method for microservice transformation of power trading power function. The invention divides the function to multiple individual services for realizing decoupling of solution or complex system. 
     In order to achieve the above objective, the invention proposes the following technical scheme. 
     The characteristic of microservice transformation of power trading function is that the method described includes the following steps. 
     (1) Divide the function in extranet trading cloud into many multiple individual micro services and divide the function in intranet trading cloud into multiple individual micro services; 
     (2) Register node information for each individual micro service in service registry when service deployment starts; 
     (3) Extranet users enter into extranet trading cloud through PC terminal or mobile terminal, obtain the actual network address that needs to be served from service registry, send a request to the requested service, and perform related business operation. Intranet users enter into intranet trading cloud through PC terminal, obtain the actual network address that needs to be served from service registry, send a request to the requested service, and perform related business operation. 
     Further in step (1), individual services including “bidding declaration” and trading result query” are included in extranet trading cloud; 
     Individual services including “trading sequence creation”, “communique release”, “biding declaration”, “bid opening”, “declared data verification”, “matchmaking trading and cleaning”, “security correction” and “result release” are included in intranet trading cloud. 
     Further in step (3), read/write splitting of database is as follows when each micro service is performing related business operation. 
     Read/write splitting of data adopts ORACLE persistent layer commercial database and REDIS main memory database; 
     When writing data according to business need, user writes data directly to ORACLE database to ensure strong consistency of data; after successfully writing data to ORACLE database, user writes it to REDIS main memory database; when reading data, user reads it from REDIS main memory database. 
     Further, REDIS master-slave replication mechanism is adopted to solve it when downtime is caused due to malfunction of REDIS. Details are as follows. 
     When data is written to MASTER server, data files is sent to SLAVE server of through REDIS SYNC mechanism and SLAVE server will do the same operation as well to ensure data consistency; 
     When a SLAVE process is started, a SYNC COMMAND will be sent to MASTER to request synchronous connection; 
     No matter it is the first connection or re-connection, MASTER will start a background process no matter it is the first connection or re-connection to store data snapshots in data file. At the same time, MASTER will record commands for modifying data and make them cached in data file; 
     After background process completes cache operation, MASTER sends data file to SLAVE and SLAVE port stores data file in hard disk and load it into memory. And then MASTER will modify all data and send them to SLAVE port. 
     Further, in order to avoid downtime fault of MASTER and SLAVE, SENTINEL function of REDIS will be used when REDIS master-slave replication is used. Details are as follows. 
     If downtime is caused due to malfunction of MASTER, REDIS SENTINEL will upgrade a SLAVE to primary server and configure other SLAVE servers to make them user new MASTER; when application program is connected to REDIS server, REDIS SENTINEL will inform new MASTER address and port; 
     If downtime is caused due to malfunction of SLAVE, it will be re-connected after getting right. MASTER will send the complete data file to SLAVE after receiving connection of SLAVE. If MASTER receives synchronous request from many SLAVE servers, MASTER will only start a background process to store the data file and then send it to all SLAVE servers to ensure normal operation of SLAVE. 
     Compared with available technology, the invention has the beneficial effects that service transformation of power trading function divides each function into individual services and each service does a single thing. All services are isolated from each other and do not affect each other. Main benefits are as follows. 
     1 Controllable Complexity 
     Microservice architecture is applied as methods for multiple services through decomposing monocoque to make the complexity controllable. In order to achieve the same function, the application is decomposed into manageable branches or services. Complex function is presented by the way of modularization through microservice architect pattern to make easier development and maintenance of individual services. 
     2 Extensible Flexibility 
     Flexibility is based on microservice architect pattern to make each service expanded independently. Under microservice architecture, technology selection is relatively flexible. In such a pattern, each team can make its own judgment and select suitable technology stack according to own need for service and industry development status. 
     3 Independent Deployment 
     Microservice has independent operation process so each microservice can be deployed independently. In the way, it is not necessary to compile and deploy the entire application to make realize more efficient when a certain microservice changes. UI team can adopt AB test to make rapid deployment of changes. Microservice architect pattern makes continuous deployment possible. 
     4 High Pertinency of Development 
     In a monolithic architecture system, training cycle of new people is very long and it takes a lot of time to understand the local development environment; however, microservice architect pattern makes each service expanded independently and operation and maintenance personnel do not need to spend too much time to get familiar with the local environment but only need to understand the status of their module. 
     5 Reduced TCO 
     In a monolithic architecture system, technology layers such as control layer, logical layer and data layers are used; however, with continuous changes of market requirements, user requirements become personalized gradually, development cycle is shorter and shorter, life cycle of product starts to get shorter, and monolithic architecture system starts to face challenges. Both development cost and maintenance cost are excessively high. 
     By contrast, in microservice architect pattern, when a certain module breaks down, defects including in-process diffusion of monolithic architecture system won&#39;t occur and malfunction will be isolated in a single service to reduce development and maintenance costs and improve development efficiency. 
    
    
     
       DESCRIPTION OF FIGURES 
         FIG. 1  is system microservice transformation flow diagram. 
         FIG. 2  is system data read/write splitting flow diagram. 
     
    
    
     SPECIFIC IMPLEMENTATION MODES 
     Specific implementation scheme of the invention is elaborated below in detail by combination of figures and specific implementation modes. These specific implementation modes are for account only but not for restricting the scope or implementation principle of the invention. Protective scope of the invention is still subject to claims. Obvious change or variation made on the base is included. 
     The invention is aimed at making microservice oriented transformation of national unified power trading platform through understanding the current condition of national unified power trading platform and high development and maintenance costs to reduce maintenance cost, improve development efficiency and reduce management difficulty. 
     In order to achieve the above objective, technical solution of the invention is as follows. 
     1. Microservice Transformation 
     As shown in  FIG. 1 , “bidding declaration” and trading result query” in extranet trading cloud and “trading sequence creation”, “communique release”, “biding declaration”, “bid opening”, “declared data verification”, “matchmaking trading and cleaning”, “security correction” and “result release” in intranet trading cloud are individual microservices. Microservice here is a kind of autonomous service fully responsible for business capacity. Full responsibility here covers view layer, control layer, business logic and data storage. Autonomous service has relatively small influence to other parts in modification and won&#39;t cause any influence to functions of other services. Services are deployed in server cluster in a distributed way and used for solving the influence of high concurrency. 
     As shown in  FIG. 1 , in current national unified power trading platform, take trading module as example (each specific function in the module is separately deployed service. node information for each individual micro service will be registered in service registry when service deployment starts. User obtains the actual network address and sends a request to the service). Extranet users enter into extranet trading cloud through PC terminal or mobile terminal, obtain the actual network address that needs to be served from service registry, send a request to the requested service, and perform related business operation. Intranet users enter into intranet trading cloud and service registry through PC terminal, obtain the actual network address that needs to be served from service registry, send a request to the requested service, and perform related business operation. Please refer to “2. read/write splitting of database” for read/write synchronization in the process of related business operation in each microservice. 
     2. Read/Write Splitting of Database 
     In brief, read/write splitting is to separate database read from database write corresponding to different database servers so as to effectively relieve the pressure of database and the pressure of IO. Primary database is for write operation and slave database operation is for read which is actually most common in many systems. When write operation is done in primary database, the data shall be synchronized to slave database so as to effectively ensure the database integrity. 
     As shown in  FIG. 2 , data read/write splitting in the invention adopts ORACLE persistent layer commercial database and REDIS main memory database. When writing data according to business need, user writes data directly to ORACLE database to ensure strong consistency of data; after successfully writing data to ORACLE database, user writes it to REDIS main memory database; when reading data, user reads it from REDIS main memory database. 
     At the same time, REDIS master-slave replication mechanism is adopted in order to avoid downtime of REDIS. When data is written to MASTER server, data files is sent to SLAVE server of through REDIS SYNC mechanism and SLAVE server will do the same operation as well to ensure data consistency. When a SLAVE process is started, a SYNC COMMAND will be sent to MASTER to request synchronous connection. No matter it is the first connection or re-connection, MASTER will start a background process no matter it is the first connection or re-connection to store data snapshots in data file. At the same time, MASTER will record commands for modifying data and make them cached in data file. After background process completes cache operation, MASTER sends data file to SLAVE and SLAVE port stores data file in hard disk and load it into memory. And then MASTER will modify all data and send them to SLAVE port. In order to avoid downtime fault of MASTER and SLAVE, SENTINEL function of REDIS will be used when REDIS master-slave replication is used. If downtime is caused due to malfunction of MASTER, REDIS SENTINEL will upgrade a SLAVE to primary server and configure other SLAVE servers to make them user new MASTER. When application program is connected to REDIS server, REDIS SENTINEL will inform new MASTER address and port. If downtime is caused due to malfunction of SLAVE, it will be re-connected after getting right. MASTER will send the complete data file to SLAVE after receiving connection of SLAVE. If MASTER receives synchronous request from many SLAVE servers, MASTER will only start a background process to store the data file and then send it to all SLAVE servers to ensure normal operation of SLAVE, guarantee data read/write synchronization, improve database performance, and respond to the requirement of current market in face of high concurrency.