[WIP][Spex TRD][2022-02-01] Simplify traffic config for routing by cid scenarios

Status

Processing

Owner

 

Contributors

Approved

Due date

Decision

 

On this page

 

 Problem statement


As discussed in the biweekly meeting, current the spex CID routing rules config is quite complex, so want to check is it possible to simplify the configuration

 

 Solution hypothesis


After this task is done, we hope to achieve the goal below

  • we hope that users can write same code as little as possible when it comes to service traffic CID config

 Design options

To be clear, all added parameters in solutions are as below

option1

  • enable_cid_routing: cid routing toggle, only working when set to true. If enable_cid_routing is true, all cids in enabled_cids are activated

  • enabled_cids: only those cids in this array will be routed by cid, the rule is CID in context == server-side registered region

  • cid_fallback_regions: the exception traffics will fallback to the regions list here; exception traffics include a. traffics without CID (cid=""), b. traffics CID not included in the list of enabled_cids

Here are three options to choose from

workflow

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 { "rules": [ { "match": { "spex_service_condition": { "condition": "in", "spex_services": [ "deep.platform.product_label.stress_test" ] } }, "subsets": [ { "weight": 100, "name": "stresstest", "enable_cid_routing": true, "enabled_cids": ["sg", "id", "tw", "th", "br", "mx"], "cid_fallback_regions": ["global", "sg"] } ] } ], "subsets": [ { "name": "stresstest", "selector": { "sduid_condition": { "condition": "in", "sduids": [ "stresstest" ] } }, "traffic_policy": null } ] }

option2

  • combine_cid_condition: combine cid routing toggle

  • combine_cids: only those cids in this array will be routed by cid, the rule is CID in context == server-side registered region

  • cid_fallback_regions: the exception traffics will fallback to the regions list here; exception traffics include a. traffics without CID (cid=""), b. traffics CID not included in the list of enabled_cids

  • combine_subsets: if the cid in input applies to combine_cid_condition but not cid_condition, we will get subsets from combine_subsets not subsets

workflow

 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 { "rules": [ { "match": { "spex_service_condition": { "condition": "in", "spex_services": [ "deep.platform.product_label.stress_test" ] }, "cid_condition": { "condition": "in", "cid": ["cn","us","uk"] }, "combine_cid_condition": { "combine_cid": ["sg", "id", "tw", "th", "br", "mx"], "cid_fallback_regions": ["global", "sg"] } }, "subsets": [ { "weight": 100, "name": "deep_example" } ], "combine_subsets": [ { "name": "stresstest" } ] } ], "subsets": [ { "name": "deep_example", "selector": { "region_condition": { "condition": "in", "regions": [ "cn","us","uk" ] } }, "traffic_policy": null } ], "combine_subsets": [ { "name": "stresstest", "selector": { "sduids": { "condition": "in", "sduids": [ "stresstest" ] } } } ] }

option3

  • cid_routing: combine cid routing

  • cid_routing_rule: map source CID to destination regions

  • default_rule: the exception traffics will fallback to the regions list here; exception traffics include a. traffics without CID (cid=""), b. traffics CID not included in the list of enabled_cids

workflow

option3 workflow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 { "rules": [ { "match": { "spex_service_condition": { "condition": "in", "spex_services": [ "deep.platform.product_label.stress_test" ] }, "cid_condition": { "condition": "in", "cid": ["cn","us","uk"] } }, "cid_routing": { "cid_routing_rules": { // cid -> list of server regions "cn": ["cn", "sg"], "sg": ["sg", "global"], // technically, ineffective since it is not in cid_condition above "my": ["global"] // ineffective }, "default_rule": ["global"] }, "subsets": [ { "weight": 100, "name": "stresstest" } ] } ] }

 

Option 1

Option 2

Option 3

 

Option 1

Option 2

Option 3

Benefits

  • This solution is from users' suggestion, maybe users think this could be easy to understand and use

  • Combine_cid_condition is separated from normal cid_condition

  • More room for users to define their own rules

  • Use least code to handle more situations

  • Logic is clear and easy to understand

  • Separate the logic of subset selection and cid_routing definition

Risks

  • In fact, combine the logic of subset selection and subset definition is kinda weird

  • This solution can just apply to “A->A region” situation only

  • Just apply to “A->A region” situation

  • Too much change to the original code

  • Can not handle all situations, for example, when there are different subset definition according to different cid_routing_rule

Suggestions

 

 

 

 

 Follow up

Decision

Status

Next steps

Decision

Status

Next steps

 

in review

 

 

 

 

 Source files

https://jira.shopee.io/browse/SPPE-3452

https://jira.shopee.io/browse/SPPSP-3599

https://space.shopee.io/infra/feedback/feedback/detail/37