TiDB 在 eBay丨亿优百倍:商品数据服务缓存与代码优化
Posted PingCAP
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TiDB 在 eBay丨亿优百倍:商品数据服务缓存与代码优化相关的知识,希望对你有一定的参考价值。
“亿优百倍”是 eBay 智能营销团队推出的系列文章,分享了在营销商品数据服务系统的架构、设计、代码方面的一些理解和研究。在上期的亿优百倍|商品数据服务TiDB性能优化(点击阅读)里,我们分享了对 TiDB 进行调优的方法,以提高了 TiDB 在 eBay 平台上使用的性能和稳定性。本期“亿优百倍”,我们分享了 MIS 中缓存层和代码层面的优化经验,以达到稳定的 QPS/IPS 目标。
相关阅读:
TiDB 在 eBay丨亿优百倍:商品数据服务百倍性能优化之路(背景篇)
TiDB 在 eBay丨亿优百倍 :商品数据服务 TiDB 性能优化(实践篇)
MIS 性能优化之缓存
1.1 横向扩展的极限
1.2 引入缓存层
1.2.1 缓存层设计要点
1.2.2 缓存填充和失效策略
1.2.3 主数据库 TiDB 和缓存层 NuKV 的数据一致性保障
1.2.4 缓存层架构
MQL 和服务层
MIS 性能优化之服务代码优化
3.1 CPU 优化
3.1.1 自动化 SQL 执行计划缓存
3.1.2 UDF 扫描时的反射优化
3.1.3 替换低效依赖库的实现
3.2 IO 优化
3.2.1 使用 Protobuf
3.2.2 NuKV 异步读写
3.2.3 eBay 商品图片 URL 的 IO 优化
总结
ebay商品基本属性组合成数据表格式,可用上传到系统递交数据
该刊登表设计是利用VB写的,当时因为两个系统的数据不能直接对接,又copy并且组合SKU,一个表格一个表格填写,比较麻烦,还好刊登系统可以允许用excel表格上传数据
所以就下好模板,学了VB语言,在业余的时候做了这个数据自动组合功能用刊登数据广告。
另外也使用VB写了一个excel表格几千行数据的处理(这个另做解释)
********************************************************************************************************************
关于SKU刊登功能如下:
(图文与代码)从basic表提取数据 判断数据并组装好,填写在export表上面的格式,就可以上传到系统后台的,这样在产品刊登上可以节省很多时间(总共有106列,但最重要的是SKU和属性的组合);
关键代码:
Sub E_US刊登模板0420() \'basic表单参数 With Sheets("basic") basic_cnt = .Range("a63556").End(xlUp).Row basic_i = 2 \'export-20130124表格的起始点,用j来递增多属性,完成后返还给i; i = 3 Do While basic_i <= basic_cnt basic_sku = .Cells(basic_i, "a") basic_site = .Cells(basic_i, "b") basic_price = .Cells(basic_i, "c") basic_ismult = .Cells(basic_i, "d") basic_mv1_code = .Cells(basic_i, "e") basic_mv1_att = .Cells(basic_i, "f") basic_mv1_val = .Cells(basic_i, "g") basic_mv2_code = .Cells(basic_i, "h") basic_mv2_att = .Cells(basic_i, "i") basic_mv2_val = .Cells(basic_i, "j") basic_mv3_code = .Cells(basic_i, "k") basic_mv3_att = .Cells(basic_i, "l") basic_mv3_val = .Cells(basic_i, "m") basic_title = .Cells(basic_i, "n") basic_description = .Cells(basic_i, "o") basic_ebay_cat1 = .Cells(basic_i, "p") basic_ebay_cat2 = .Cells(basic_i, "q") basic_item_spec4 = .Cells(basic_i, "r") basic_item_spec5 = .Cells(basic_i, "s") basic_item_spec6 = .Cells(basic_i, "t") basic_item_spec7 = .Cells(basic_i, "u") basic_item_spec8 = .Cells(basic_i, "v") basic_item_spec9 = .Cells(basic_i, "w") basic_item_spec10 = .Cells(basic_i, "x") basic_item_spec11 = .Cells(basic_i, "y") basic_item_spec12 = .Cells(basic_i, "z") basic_item_spec13 = .Cells(basic_i, "aa") basic_item_spec14 = .Cells(basic_i, "ab") basic_item_spec15 = .Cells(basic_i, "ac") basic_photo = .Cells(basic_i, "ad") \'j来引导下一个多属性 j = i \'---------------------------- \'数据表列号 dsheet_row_id = "A" dsheet_shop_initial = "B" dsheet_sitecode = "C" dsheet_currency = "D" dsheet_format = "E" dsheet_duration = "F" dsheet_var_parent_sku = "G" dsheet_product_code = "H" dsheet_remark = "I" dsheet_var_photo = "J" dsheet_var_child_var1 = "K" dsheet_var_child_var2 = "L" dsheet_var_child_var3 = "M" dsheet_var_child_var4 = "N" dsheet_var_child_var5 = "O" dsheet_var_ean = "P" dsheet_var_upc = "Q" dsheet_var_isbn = "R" dsheet_lot_size = "S" dsheet_qty = "T" dsheet_price = "U" dsheet_discount_profileid = "V" dsheet_isoffer = "W" dsheet_rejectamt = "X" dsheet_acceptamt = "Y" dsheet_payment_method = "Z" dsheet_paypal_email = "AA" dsheet_autopay = "AB" dsheet_checkout_policy = "AC" dsheet_itemcountry = "AD" dsheet_itemlocation = "AE" dsheet_ship_to_country = "AF" dsheet_exclude_shiptolocation = "AG" dsheet_ship_service = "AH" dsheet_first_post = "AI" dsheet_second_post = "AJ" dsheet_intl_ship_service = "AK" dsheet_intl_ship_location = "AL" dsheet_intl_first_post = "AM" dsheet_intl_second_post = "AN" dsheet_max_dispatch_time = "AO" dsheet_return_accepted = "AP" dsheet_return_refund = "AQ" dsheet_return_within = "AR" dsheet_return_shipby = "AS" dsheet_return_policy = "AT" dsheet_productsize = "AU" dsheet_receivedesc1 = "AV" dsheet_receivedesc2 = "AW" dsheet_receivedesc3 = "AX" dsheet_receivedesc4 = "AY" dsheet_receivedesc5 = "AZ" dsheet_maindesc01 = "BA" dsheet_maindesc02 = "BB" dsheet_maindesc03 = "BC" dsheet_maindesc04 = "BD" dsheet_maindesc05 = "BE" dsheet_maindesc06 = "BF" dsheet_maindesc07 = "BG" dsheet_maindesc08 = "BH" dsheet_maindesc09 = "BI" dsheet_maindesc10 = "BJ" dsheet_pictotal = "BK" dsheet_poster = "BL" dsheet_poster_link = "BM" dsheet_gallery = "BN" dsheet_gallerytype = "BO" dsheet_photofirst = "BP" dsheet_pic_use_actual_path = "BQ" dsheet_desc_use_actual_html = "BR" dsheet_cmptblty_use_profile = "BS" dsheet_pic_actual_paths = "BT" dsheet_condition_id = "BU" dsheet_condition_desc = "BV" dsheet_ebcategory = "BW" dsheet_ebcategory2 = "BX" dsheet_shopcategory1 = "BY" dsheet_shopcategory2 = "BZ" dsheet_sitecategory = "CA" dsheet_titleexternal = "CB" dsheet_subtitleexternal = "CC" dsheet_titleinternal = "CD" dsheet_item_specific_1 = "CE" dsheet_item_specific_2 = "CF" dsheet_item_specific_3 = "CG" dsheet_item_specific_4 = "CH" dsheet_item_specific_5 = "CI" dsheet_item_specific_6 = "CJ" dsheet_item_specific_7 = "CK" dsheet_item_specific_8 = "CL" dsheet_item_specific_9 = "CM" dsheet_item_specific_10 = "CN" dsheet_item_specific_11 = "CO" dsheet_item_specific_12 = "CP" dsheet_item_specific_13 = "CQ" dsheet_item_specific_14 = "CR" dsheet_item_specific_15 = "CS" dsheet_catalog_type = "CT" dsheet_catalog_id = "CU" dsheet_catalog_use_photo = "CV" dsheet_catalog_use_specific = "CW" dsheet_profile_idx = "CX" dsheet_cmptblty_profile_idx = "CY" dsheet_template_idx = "CZ" dsheet_attr_group = "DA" dsheet_privatelisting = "DB" dsheet_listenhancement = "DC" dsheet_keep_enabled = "DD" dsheet_EOF = "DE" \'----------------------------------------------- \'E_US站点参数 Cells(i, dsheet_row_id) = "" Cells(i, dsheet_shop_initial) = "e" Cells(i, dsheet_sitecode) = "US" Cells(i, dsheet_currency) = "USD" Cells(i, dsheet_format) = "BIN" Cells(i, dsheet_duration) = "GTC" If basic_ismult = 1 Then arr_mv1_cod = Split(basic_mv1_code, ",") len_mv1_cod = UBound(arr_mv1_cod) arr_mv1_val = Split(basic_mv1_val, ",") len_mv1_val = UBound(arr_mv1_val) If Trim(basic_mv3_val = "") Then \'判断单SKU和单属性值 If Trim(basic_mv2_val = "") Then If len_mv1_cod = len_mv1_val Then For mv1_i = 0 To len_mv1_cod Cells(j, dsheet_var_parent_sku) = basic_sku & "/120129eusd-P" Cells(j, dsheet_product_code) = basic_sku & "-" & UCase(arr_mv1_cod(mv1_i)) & "/120129eusd" If arr_mv1_val(mv1_i) Like "x*" Then Cells(j, dsheet_var_child_var1) = Application.Proper(basic_mv1_att) & ":" & UCase(arr_mv1_val(mv1_i)) Else Cells(j, dsheet_var_child_var1) = Application.Proper(basic_mv1_att & ":" & arr_mv1_val(mv1_i)) End If Cells(j, dsheet_var_upc) = "Does not apply" Cells(j, dsheet_lot_size) = 1 Cells(j, dsheet_qty) = 15 Cells(j, dsheet_price) = basic_price Cells(j, dsheet_EOF) = "o" j = j + 1 Next Else MsgBox (basic_i & "row:length of mv1_code and mv1_val not same") Exit Sub End If \'判断单SKU双属性值,或者双SKU双属性值 Else arr_mv2_val = Split(basic_mv2_val, ",") len_mv2_val = UBound(arr_mv2_val) \'判断单SKU双属性值 If Trim(basic_mv2_code) = "" Then If (len_mv1_cod + 1) = (len_mv1_val + 1) * (len_mv2_val + 1) Then \'使用mv_k定位循环双属性值 mv_k = j \'*****************************循环SKU编号 For mv1code_i = 0 To len_mv1_cod Cells(j, dsheet_var_parent_sku) = basic_sku & "/120129eusd-P" Cells(j, dsheet_product_code) = basic_sku & "-" & arr_mv1_cod(mv1code_i) & "/120129eusd" Cells(j, dsheet_var_upc) = "Does not apply" Cells(j, dsheet_lot_size) = 1 Cells(j, dsheet_qty) = 15 Cells(j, dsheet_price) = basic_price Cells(j, dsheet_EOF) = "o" j = j + 1 Next For len_mv1val_i = 0 To len_mv1_val For len_mv2val_i = 0 To len_mv2_val \'判断属性值有没有XL,用Application.Proper只能首字母大写,无法让全部字母大写 If arr_mv1_val(len_mv1val_i) Like "x*" Then Cells(mv_k, dsheet_var_child_var1) = Application.Proper(basic_mv1_att) & ":" & UCase(arr_mv1_val(len_mv1val_i)) Else Cells(mv_k, dsheet_var_child_var1) = Application.Proper(basic_mv1_att & ":" & arr_mv1_val(len_mv1val_i)) End If \'判断属性值有没有XL,用Application.Proper只能首字母大写,无法让全部字母大写 If arr_mv2_val(len_mv2val_i) Like "x*" Then Cells(mv_k, dsheet_var_child_var2) = Application.Proper(basic_mv2_att) & ":" & UCase(arr_mv2_val(len_mv2val_i)) Else Cells(mv_k, dsheet_var_child_var2) = Application.Proper(basic_mv2_att & ":" & arr_mv2_val(len_mv2val_i)) End If mv_k = mv_k + 1 Next Next Else MsgBox (basic_i & "row:len_mv1_cod!=len_mv1_val*len_mv2_val") Exit Sub End If \'双SKU双属性值 Else arr_mv2_cod = Split(basic_mv2_code, ",") len_mv2_cod = UBound(arr_mv2_cod) If len_mv1_cod <> len_mv1_val Then MsgBox (basic_i & "row:2/2 mode len_mv1_cod!=len_mv1_val") Exit Sub End If If len_mv2_cod <> len_mv2_val Then MsgBox (basic_i & "row:2/2 mode len_mv2_cod!=len_mv2_val") Exit Sub End If \'循环双SKU和双属性 For mv1val_i = 0 To len_mv1_val For mv2val_i = 0 To len_mv2_val Cells(j, dsheet_var_parent_sku) = basic_sku & "/120129eusd-P" Cells(j, dsheet_product_code) = basic_sku & "-" & UCase(arr_mv1_cod(mv1val_i)) & UCase(arr_mv2_cod(mv2val_i)) & "/120129eusd" \'判断MV1属性值有没有XL,用Application.Proper只能首字母大写,无法让全部字母大写 If arr_mv1_val(mv1val_i) Like "x*" Then Cells(j, dsheet_var_child_var1) = Application.Proper(basic_mv1_att) & ":" & UCase(arr_mv1_val(mv1val_i)) Else Cells(j, dsheet_var_child_var1) = Application.Proper(basic_mv1_att & ":" & arr_mv1_val(mv1val_i)) End If \'判断MV2属性值有没有XL,用Application.Proper只能首字母大写,无法让全部字母大写 If arr_mv2_val(mv2val_i) Like "x*" Then Cells(j, dsheet_var_child_var2) = Application.Proper(basic_mv2_att) & ":" & UCase(arr_mv2_val(mv2val_i)) Else Cells(j, dsheet_var_child_var2) = Application.Proper(basic_mv2_att & ":" & arr_mv2_val(mv2val_i)) End If Cells(j, dsheet_var_upc) = "Does not apply" Cells(j, dsheet_lot_size) = 1 Cells(j, dsheet_qty) = 15 Cells(j, dsheet_price) = basic_price Cells(j, dsheet_EOF) = "o" j = j + 1 Next Next End If End If \'********************************************************** Else \'先获取mv3的值 arr_mv3_val = Split(basic_mv3_val, ",") len_mv3_val = UBound(arr_mv3_val) arr_mv2_val = Split(basic_mv2_val, ",") len_mv2_val = UBound(arr_mv2_val) \'判断双SKU,三属性值 If basic_mv2_code <> "" And basic_mv3_code = "" Then arr_mv2_cod = Split(basic_mv2_code, ",") len_mv2_cod = UBound(arr_mv2_cod) If (len_mv1_cod + 1) * (len_mv2_cod + 1) = (len_mv1_val + 1) * (len_mv2_val + 1) * (len_mv3_val + 1) Then mv_k3 = j For mv1code_i = 0 To len_mv1_cod For mv2code_i = TiDB v6.0.0 (DMR) :缓存表初试丨TiDB Book Rush