F5负载均衡的rest接口拓展查询

F5负载均衡的rest接口拓展查询

问题描述:

  • 接触过F5的小伙伴大概会发现,F5的rest接口返回中经常会包含isSubcollection这个字段,用来表示存在嵌套的结果,这样的方式在一定程度上缓解了设备一次请求拉取数据的压力,但在我们需要获取所有嵌套结果时,多次的http请求反而会增加性能开销,这时候,我们如何取消isSubcollection带来的弊端呢?
{"profilesReference": 
      {
          "link":"https://localhost/mgmt/tm/ltm/virtual/~Common~Test_77.66_80/profiles?ver=11.6.1",
          "isSubcollection": true
      }
  }

解决方案:

  • 通过在rest 请求的时候添加expandSubcollections=true参数,可以实现拓展查询,无需进行多次请求,极大的缩减了获取数据的请求时间开销。获取到的数据如下:
{
    "profilesReference":
  {
      "link": "https://localhost/mgmt/tm/ltm/virtual/~Common~Test_77.66_80/profiles?ver=11.6.1",
      "isSubcollection": true,
      "items": [
                  {
                  "kind": "tm:ltm:virtual:profiles:profilesstate",
                  "name": "HTTP",
                    "partition": "Common",
                    "fullPath": "/Common/HTTP",
                    "generation": 1,
                    "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~Test_77.66_80/profiles/~Common~HTTP?ver=11.6.1",
                    "context": "all"
                   }
              ]
  }
}

总结:

  • 这其实就是一个简单的应用问题,所有的解决方式在官方的文档中都能够找到很好的解答.解决问题不是目的,学会解决问题才是目的!

猜你喜欢

转载自www.cnblogs.com/willow-blueness/p/11704560.html