当前位置:网站首页>General business plan

General business plan

2022-06-21 07:49:00 Don't null a

Update the cache after the database is loaded
Using English for log printing can avoid garbled code
If there's a lot of business , Need to increase redis The number of connections , take redis Pay attention to catching exceptions , There may be insufficient connections to throw exceptions , It is necessary to ensure that data can be obtained from other channels , To ensure the normal operation of the business
Scenario of using distributed locks : For example, the cluster environment machine starts from redis The queue fetches the request consumption and counts , If the lock is not used, it may cause inconsistent reading of count values
Memory update can be done by defining static lastUpdatedTime To implement incremental updates ,Date The type can be through compareTo Compare , Remember to add... When synchronizing the time synchronized
After the code is on the test line, it is better to turn on shell Observe the log for a period of time
Solutions to prevent business problems during deployment in the cluster mode ( The intermediate process of a business is killed ): The blue-green cluster takes the blue environment first Apollo The logo is changed to unavailable , At this time, the blue environment will no longer consume tasks , Open the logo after the blue environment is successfully published , Green environment operation is similar

You can add a switch where you log frequently , Turn off the switch after production to avoid too large log , Turn on the switch when troubleshooting

It is better to define interfaces for all implementation classes , This is easier to expand , Use polymorphism, etc

If the interface level is deep , Consider encapsulating a uniform return object , In this way, only one class can be read when judging the superior processing results

The cluster environment can be realized by incr,finally in decr Whether the latter is equal to 0 To determine whether all machine execution is completed , However, it is necessary to consider the abnormal condition of a certain machine , It can be judged by adding a mark bit

Prevent too much data in the database JVM The total number can be checked first , Then do a paging , But the paging cache may have concurrency problems , How many times can I publish ,redis Add several times to the number of middle marks , Run the task several times to solve it , But it will also cause program interruption, resulting in the initial value not being 0 The situation of , It will never be reduced to 0 了
How to ensure that all machines execute in a distributed environment ? If some machines are abnormal , What should I do if I need to repeat this task ?

You can define a in an object Object Attribute implements the permission granularity of a piece of data

The test must be OK , Be sure to consider alternatives
Like cached 、 You'd better print out the loaded quantity , Easy to verify

The production environment table should be used with caution like, It is easy to create a long transaction alarm , need DA kill, Or determine which paragraph to check , With date

Tool classes can use static injection , Because static bean Can be used directly in static methods
private static UcpDocSysConfigCacheService ucpDocSysConfigCacheService;

@Autowired
public void setDatastore(UcpDocSysConfigCacheService ucpDocSysConfigCacheService) {
    // Static injection
    setStaticUcpDocSysConfigCacheService(ucpDocSysConfigCacheService);
}

public synchronized static void setStaticUcpDocSysConfigCacheService(UcpDocSysConfigCacheService ucpDocSysConfigCacheService) {
    IMClientUtil.ucpDocSysConfigCacheService = ucpDocSysConfigCacheService;
}

When returning an error message, remember to intercept the length to avoid being too long
controller Layer exceptions are best handled , Otherwise, the front end will receive an exception, which is very unfriendly to the user , And it will expose the back-end information

It is better to provide a query interface rather than a distribution interface , In this way, once the data is wrong, it is easy to repair , It's not easy to carry the pot

The memory is in JVM Than redis It's going to be a lot faster

Always leave a way for the program
Generally, it is better to print the quantity for loading , Easy to troubleshoot , Some prints are only used for marking during the test phase , A switch can be added for those not used in production

have access to mycat Realize database fragmentation ( colony ), Generally, the unique identification will be stored in modules and pieces , Fragmentation is imperceptible to development

For important functions that do not leave a trace after modification, you can add a log table , Write after successful execution

To avoid data problems caused by concurrency , It can be done by redis Lock control , For example, you can't upgrade documents after locking them when importing them 、 Released

It is best to classify the logs according to errors info warn error

It's better to add memory limit to large file batch export

Want to use labels to distinguish data in a text , have access to jdk Primitive class JAXBContext

The amount of backup data per unit time should be greater than the amount of new data

Users' privacy issues should be desensitized

Open the wall according to the network segment to facilitate the expansion of the machine

Production monitoring finds that there are periodic FULL GC, Probably 1 Once an hour , It is speculated that it is caused by batch caching of documents , The most direct way is to increase JVM Memory , Batch can also be stopped , Post release caching or incremental caching , You can judge key(doc_code+version) Whether there is , If it exists, it will not be updated , Production batch 20 minute
CPU commonly 40~50% More appropriate 、 Memory 60% More appropriate

To get through a route is to get through IP To IP, To get through the firewall is to get through IP To port
If FULL GC You may not provide external services , Depends on what garbage collector is used , If it is single threaded, it will not provide external services , therefore FULL GC Too often is not good , In the case of high concurrency, if the cluster has machines FULL GC, It will cause the load of other machines to be too high , May collapse and return 503

Involving various service invocations, switches can be designed to be defined in Apolo, Control external access

Text editing skills : Document and version copy To another sheet, Enter the English mode double quotation marks in the first line on the left , double-click + Then all the corresponding columns are enclosed in quotation marks , The same goes for the right side , Choose all again copy To notepad, Using mouse copy A space , Then replace all

Access class problems , If someone takes it , It is more efficient to directly ask the people who receive questions

Asynchronous processing design : When the container is initialized, create a thread pool according to the configuration parameters , Pass in a specific instance , Use in instance while Dead cycle , Keep checking redis Is there any object that needs to be consumed , Thread instances are equal to the maximum number of threads , And remain unchanged

Multi query data from the database at one time , It is better to reduce the frequency of scheduled tasks , Better fault tolerance

Consider L2 cache when designing cache ( Class A redis, Secondary database , Because level one redis There must be a threshold ), When the first level reaches the threshold, the request is placed in the second level , Supplement data when fetching tasks

Idempotency : It means that the result of one or more requests for the same operation is consistent , It won't have side effects due to multiple clicks , For example, idempotent avoids repeated deduction of orders

Call other systems , Connection timeout is normal 2 second , Read timeout is normal 10 second , It is better to be configurable

Call the external system to set the compensation , If the first call fails, call again , You need to take out the timeout exception alone , If there is a return code or timeout break, No more compensation

There should be a limit on the number of processing times , Avoid program errors that can't be handled all the time , More and more data

Enumeration class comes with name Method can be used directly
It is best to design the backup log table when designing the backup , Record every backup , Log write back logic , Generally, the records of the most recent period will be kept , Sub database and sub table is the final solution , To query the backed up data, it is better to limit the time period, sort and add the maximum number of pieces , When there is a large amount of table data , Sorting without adding a time period may block the database , These values can be based on the number of table fields 、 Whether to query all tables ,JVM Memory 、 Try not to affect the application performance , Like the biggest 2W, Time period fetching 2 Hours , Handle in sections , Every time 100 strip , Backup speed > Generation speed

Line annotations are always used // get data , Method annotations are always used
/**
 * initialization
 */
 

原网站

版权声明
本文为[Don't null a]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221507217422.html