The steps of large-scale system refactoring are simple to sort out

https://blog.csdn.net/linsongbin1/article/details/51906661

Overview


With the continuous development of the company's business and the continuous increase in the number of users, the performance requirements of the system will become higher and higher, and the irrationality of the original hastily made projects will continue to be exposed. If you have been exposed to very profitable Internet products, you must know that a small bug in the product may cause the company to lose millions or even hundreds of millions. When the number of users of the product reaches a certain number, the requirements for all aspects of the system are higher, such as qps, cpu, disaster recovery, downgrade, current limiting, scalability, maintainability, and so on. In addition to coping with a large number of concurrent requests, the system must also quickly support various business requirements, and the system must be heavily refactored.

Remark:

Some of the steps and how-tos below are listed based on the actuality of my own project. 


Business carding


To understand the original business process, if there is an unreasonable business process, business process optimization must be carried out. This is generally handled by the company's business architect. 


Database refactoring


In the early stage of the project, due to the rush, there was not enough time to design tables, resulting in various redundant tables, large tables, a large number of redundant fields, and tables with poor scalability. Therefore, when reconstructing the system, you can start with the table, and reorganize the table by sorting out the current business. 
1. Tables with too many fields can be extracted into a new table according to the business attributes of some fields; 
2. Table fields that are no longer used can be deleted; 
3. Fields that can be merged, try to merge as much as possible, for example, want to express If a product is a travel product, there is no need to add a field similar to is_travel. You can directly add an enumeration value to the product type product_type; 
4. According to the current business, sink some table fields to other tables, and from other One dimension output; 
5. If a table has too many extended attributes, another table can be created for storage.

etc. . . .

Database refactoring is generally handled by a dedicated data architect. Data architects must work closely with business architects. 


data migration


Due to the reconstruction of the database, the data of the old database must be completely migrated.

  1. Full migration: You need to do a full migration program that only runs once, and migrate the old database at one time;
  2. Incremental migration: Before the new system goes online, the old system has been working, so the newly added data must also be migrated to the new database through an incremental migration program. This incremental program must run until the old system goes offline and no new data will be generated. 


db data self-check program


In order to verify whether the migration program is working properly, a self-checking program must be written to continuously compare the data in the old and new databases to see if there is any missing data or data with unequal values. 


business interface design


For the newly designed table and newly sorted business, redesign the external business interface. Of course, due to the redesign of the interface, the input parameters and output parameters of the method may be different. In this case, when other systems are connected, they will encounter some resistance. 


Service interface self-check procedure


A business interface self-checking program must be used to constantly compare the output of the old and new business interfaces to see if they are consistent. This is a very critical program to help check for problems with new data and new interfaces. 


Synchronize new requirements


Since the old system still has new requirements to deal with, the new system must also consider whether it needs to be done. Of course, not all the requirements of the old system have to be updated to the new system synchronously, because the new system has done business sorting, and some so-called new functions are actually supported. 

read unity


After the data migration has worked correctly, it is found that the output of the new interface is the same as the output of the old interface through the self-check program. At this time, if the external system, such as system A only needs to read the interface, then system A can be used completely new interface. Gradually let the systems that only need to read the interface go online one after another. 

write unity


In order to facilitate system access, a gateway system can be developed to allow external systems to transparently connect to the gateway first. After the gateway system receives the write request, it first writes the data to the old DB. After success, it writes the data to the new DB to double-write the data  . This has the advantage that after the system goes online, if there is a problem with the new write interface or read interface, you can immediately switch to the old interface.

The difficulty of writing unity is relatively high and requires great care. 

development joint debugging


After the SDK is released for the new interface, other systems can call the new interface through the SDK for simple interface debugging between developers. During this period, if you encounter business problems, you must contact the business architect and data architect in time. Business and table adjustments may be made where appropriate.

As mentioned above, due to the relatively large changes in the business interface, when other systems are connected, they will encounter a lot of resistance. 


Testers step in


In addition to the interface function test, a complete performance test and stability test must be done. At the same time, a test joint debugging environment must be built to conduct joint debugging with testers of other systems, and other systems must be connected to the new interface.

At this stage, it is best to find reliable testers who understand both testing technical skills and business. 


access traffic


You can first cut a few ten thousandths of the flow to the new interface and test the water. If there is a problem, please modify it in time. As long as there is traffic access, various monitoring systems must be used for real-time monitoring, and if there is a problem, an alarm will be given immediately. In addition, developers must frequently check the logging system to detect problems early. Once the new interface is very stable, all traffic can be switched to the new interface. 


observation system

– 
After the new interface is connected to all traffic, in addition to the monitoring system monitoring interface, developers must often check the log system to observe whether the system is working properly. It's a good idea to set a task where developers take turns observing the system.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325845324&siteId=291194637