当前位置:网站首页>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
*/
边栏推荐
- One year experience interview byte Tiktok e-commerce, share the following experience!
- Research Report on inorganic copper fungicide industry - market status analysis and development prospect forecast
- Enterprise level development and use POI stepping on pit inventory
- 学习太极创客 — ESP8226 (九)JSON 数据通讯 三
- 32单片机——pwm波输出
- AutoCAD - drawing units and drawing boundaries
- 如何使用lerna进行多包(package)管理
- 图解 Google V8 # 16:V8是怎么通过内联缓存来提升函数执行效率的?
- Illustration of Google V8 16: how does V8 improve function execution efficiency through inline caching?
- Permission management
猜你喜欢

Le Code est correct, mais les données de la base de données ne sont pas affichées.

mysql中执行存储过程的语句怎么写

学习太极创客 — ESP8226 (九)JSON 数据通讯 三

Practical application cases of digital Twins - coal mine

mysql存储过程中的循环语句怎么写

19 statistics and its sampling distribution -- distribution of sample mean and central limit theorem

部署Zabbix企业级分布式监控

升级Jenkins步骤和遇到的问题

Firefox users are down, Mozilla foundation is at a crossroads

Mathematics is a tool for solving problems
随机推荐
mysql存储过程中的循环语句怎么写
Seat number of Pat grade B 1041 test (15 points)
The concept of tree
Simulate long press event of mobile device
Enterprise level development and use POI stepping on pit inventory
Dynamic addition of prompt information for successful operation
升级Jenkins步骤和遇到的问题
部署Zabbix企业级分布式监控
【蓝桥杯单片机组】串口通信
2021-06-17 STM32F103 USART serial port code using firmware library
Leetcode topic [array] -40- combined sum II
mysql不是内部命令如何解决
Actual use case of strategic routing in a school cloud computer project
2022年的WordPress网站安全问题
Why is there no error in the code, but the data in the database cannot be displayed
QML control type: drawer
2021-06-17 STM32F103 USART串口代码 使用固件库
2021-06-18 STM32F103 DMA 与 DMA串口代码 使用固件库
Privacy sandbox helps enterprises: how privacy technology protects user data and promotes business growth
Rdkit | fragment decomposition of drug molecules