当前位置:网站首页>This summer, the configuration items should be clear and refreshing

This summer, the configuration items should be clear and refreshing

2021-07-06 10:12:33 InfoQ

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Any business system needs fast iterative delivery in the process of rapid growth , Inspection treasure business is no exception . In this process, it is inevitable that we will continue to introduce 「 Bad taste 」. Now let's take a look at a small optimization and some thoughts recently made by jianhuobao ."}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" What is? 「 Inspection treasure 」"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" First of all (ān) Shao (lì) Let's have a look at the inspection service of Xianyu . Buy digital products at leisure 、 Tide shoes 、 Luxury bags and other valuables , Buyers may worry about buying fake goods or babies that don't match the seller's description , Sellers also hope that their high-quality baby can be sold at a good price . In order to solve the problem of trust between the buyer and the seller , LEIYU cooperates with professional institutions , Provide authoritative inspection report for all inspection products . When the buyer place an order to buy inspection treasure goods , The seller delivers the baby to the inspection center , After the inspection center issues the inspection report , The buyer can decide to buy or not to buy according to the report . As soon as the inspection service was launched, it was deeply loved by users , In a short time ."}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" The girl ( shipment ) Child ( The camp ) Said to me, , Another new category "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Inspection treasure has been online for more than half a year , The speed of demand iteration also tends to be stable , Thanks to the excellent overall architecture design , At present, the back-end development can be done by myself Cover live . But there are still some in the requirements iteration process 「 Pain points 」, such as : I hope that when the operation students keep coming to me for new categories , I can do it faster and easier . At present, the first batch of online support categories of inspection treasure are : mobile phone 、 Flat 、 The notebook 、 Tide shoes 、 Luxury bag 、 Luxury watches 、 Luxury accessories 、 Luxury clothing . The follow-up inspection service will cover more categories , Let's sell comfortably and buy at ease ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/db\/db2ad923aa84a4d98a00ab3c87a51f07.png","alt":" picture ","title":"null","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Different categories have different inspection fee calculation strategies 、 Different introduction pages URL、 Different service providers 、 Different upgradeable price ranges ( Only commodities in the specified price range can upgrade the inspection service )、 Different interiors Code wait . Of course, most of this is managed through configuration , But configurations are scattered across multiple systems 、 Multiple key in , Another part is hard coded in the code ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Configuration is distributed in multiple systems mainly because different configuration systems have different emphasis , For example, some configuration systems are for development students 、 Some of them are for operation students ; Hard code in the code is mainly such as some global constants Code Need to hit the dependent JAR In bag . The problem brought by the configuration of hard coding is that new categories need to be released on the server side , Will be affected by holidays 、 The influence of blocking the net, etc , Long release cycle 、 inflexible ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In fact, this is a common and easily overlooked scene , The associated configuration in a link needs to be closed to a 「 Atomic configuration 」( It refers to the smallest distribution unit ) in , Too many and scattered configuration items may bring many negative effects :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Increased maintenance costs : The change process is cumbersome , Multiple configurations need to be modified ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Error prone : Prone to mismatches 、 Missing match without knowing it ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Change time extended : Every configuration needs to be modified 、 Go through the process of examination and approval ;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Consistency issues : If multiple configurations of a link are time-dependent , Then the delay of the configuration system may cause consistency problems , Additional means are needed to ensure final consistency , But atomic configuration doesn't have this problem ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" To optimize this problem , At the same time, in order to support the new categories to go online quickly , Inspection treasure just made a special optimization : Normalization transformation of configuration . The goal is to launch new categories without publishing them , At the same time, the configuration is unified to close one by category ."}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Simple point , The way to add a new class is simpler "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" First of all, we will sort out the two main links :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Product upgrade link "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Order fulfillment link "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The whole link involves multiple applications , There are also many types of configurations :String、Boolean、Map、Integer wait . existing 「Mach Cloud delivery platform 」 It just meets the requirements of this configuration center .Mach Provide independent configuration definition and configuration instance capability . The configuration definition uses JSON Schema Type constraints on configuration content , Configuration instances can create different delivery time periods 、 Different priorities 、 Multiple instances of different environments ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Here I'll illustrate this link with a simplified example , For example, I sort out that each category should have this 3 Configurations :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• Inspection service description page URL: String type "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• The amount of inspection fee to be charged : value type "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• This category can upgrade the classification of inspection service : String list type ( Let me explain this , It is used to configure multiple categories, such as basketball shoes 、 Skate shoes 、 Canvas shoes, etc. can open the inspection service of Baochao shoes category )"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" So I am Mach Create a new configuration on :「 Inspection treasure configuration set 」, First define JSON Schema:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/69\/690d9263bb592c221fd7375339ba05d6.png","alt":" picture ","title":"null","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Then create a new configuration instance , Set the effective time interval 、 Priority information . Finally, fill in this 3 The specific content of the configuration ,Mach According to the data type of the configuration item, the corresponding GUI Fill out the page , such as string A type is a text input box ;array It's a belt + Button text box list ;number Type is a text input box with numeric validation . This example does not post a screenshot of the page , Use the text to indicate :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• introductionPageUrl: www.taobao.com\/yanhuobao\/introduction-page.html[1]"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• platformServiceFee: 39"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"• cateIdUnderScene: [123, 234, 345]"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"OK, Now we can go through Mach The configuration information is pulled from the service interface of , We can get the configuration instance from the interface JSON character string , adopt fastjson You can parse to the corresponding configuration content . Of course, the structure of our definition of configuration is not necessarily the same as the data structure actually used , We will parse the above configuration into a file containing the following 3 Configuration of two variables DO object :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/40\/409bd05f0cda8f6668de6be74d49cf8e.png","alt":" picture ","title":"null","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Online business QPS Very high , At the same time, these configurations do not require real-time access to the latest values , So we do a local cache , Of course, it will be resolved ConfigDO Saving objects is the best choice ."}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Fireworks are cold , Less wheels "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" There are many references in an application Mach To configure , Each configuration resolves DO The data structure is different , But if we use our own cache everywhere, it will inevitably lead to repeated development and waste of resources . So here we introduce a general configuration cache pool ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/61\/61f54e43bb3b4730294605a070bbd995.png","alt":" picture ","title":"null","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The cache pool uses Guava Of LoadingCache, By abstracting out a ConfigValueParser, Each configuration user can implement its corresponding parsing logic ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/34\/34b76ec2d8986e445865b08035fa2e78.png","alt":" picture ","title":"null","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" stay parseConfig Implement analytic logic , Return to the above-mentioned configuration after parsing YhbConfigDO Object can . You can get it directly when you use it :YhbConfigDO yhbConfigDO = configMachReader.get(CONFIG_MACH_ID);"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" summary "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In this paper, through a recent configuration normalization optimization of an inspection treasure, we introduce the possible problems caused by the related configuration dispersion in the product link , And the optimization plan . I hope it can help you ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Reprinted from : Free fish technology (ID:XYtech_Alibaba)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Link to the original text :"},{"type":"link","attrs":{"href":"https:\/\/mp.weixin.qq.com\/s\/NVlH_Y2SAodPEyyhgqPCwg","title":"xxx","type":null},"content":[{"type":"text","text":" This summer , Configuration items should also be clear and refreshing "}]}]}]}

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/07/20210706101013636n.html

随机推荐