Small records of some daily problems

1. Split the trading line and display line

Background : System a needs to provide an interface query for system b, which is used to calculate the price of active commodities after discounts
:
1. System a is positioned as a transaction link execution system, and the main body provides services for the transaction line
2. It is used by system b The provided interface service belongs to the service of the display line.
3. The new interface belongs to the display line with a large amount of calls. It is necessary to prevent the interface from affecting the interface of the existing transaction line.
Solution: The
new interface is divided into an independent package to be independent from the interface of the original transaction line. , To prevent the display line from being too large and affecting the trading line. Therefore, the existing system a needs to be hierarchically divided. Is independently a war package, as is the presentation layer code package, the package independent deployment, a dedicated data source cluster (Redis)
discounted price as merchandise four page display elements, corresponding to higher tps claim estimated 7w + / tps
so Apply for the redis10 group of 2c4G. Each group of 2W/tps
harvest:
principle transaction line priority> display line
transaction line availability> display line,
display line allows a small amount of wrong and dirty data

2. The order occupied information is entered into the db scheme:

1. Decoupling into db through windQ
2. Setting up a separate redis storage needs to enter the db occupancy information, and a job in the background will periodically take out the data in the redis and enter the db in batches

3. Activity platform-based routing

Background : There are multiple types of sales activities. Activities are distinguished by activity type type and platform type. The processing flow of multiple types of activities is the same, but the details of the processing methods are different.
Solution :
1. Define public interfaces and write implementation classes for each type of activity
2. Define custom annotations and fill in the annotations on each implementation class.
3. Define the factory class. After the bean is instantiated, each implementation class is initialized and incorporated into the factory. When
invoking, it is called according to the annotations

4. Consider cold and hot diversion for systems with excessive tps pressure

waf -> lua -> ngix -> jboss
lua layer performs real-time calculation of hot products. For products or requests that exceed the threshold, hot labels are applied, heat treatment is performed, and traffic is intercepted.

5. Production accident: the web caches empty data

Lua calls the web front-end sub-interface to obtain the a data set under the corresponding parameter A.
The internal logic of the sub-interface
1. Enter Redis to get the cached data a1 corresponding to parameter A
2. When 1 is empty, return to the source solr to query the corresponding data a2, and cache it in redis, redis ttl: invalid on the whole point
3. There will be backstage Job will initialize a1 in Redis regularly.
Problem: In step 2, different parameters are entered into different solr cores to return to the source. This operation is judged by a series of if...else, but parameter A is not in the if condition, so it cannot Back to the source.
As a result, empty data is returned, and the cache time is set for the request result set. As a result, the empty data result set is cached. Before the Redis cache reaches invalidation, the user cannot access the category collection.
Summary: During
development, for calling ready-made sub-interfaces, try to understand the implementation logic of the sub-interfaces, and track the next execution process at the lowest level to prevent unexpected problems.
When caching the result set of important data, it is necessary to evaluate whether it is abnormal data. For abnormal data under abnormal conditions, it is best to dynamically configure the cache time.

Guess you like

Origin blog.csdn.net/weixin_43828467/article/details/114667938