2017-10-20 60 views
1

我有一個Azure API Management API,僅由模擬操作組成。大多數,像附加圖像的底部,運行在毫秒的十分之一。然而,測試/純粹進入並返回應用程序/ json的通常運行在幾十秒(圖像頂部)。我使用開發人員控制檯或從Logic應用程序調用了此選項。我的情況有1.7K進來,返回的JSON在26K是大型的。Azure API管理中的模擬操作性能

這麼大的響應時間似乎過多。可能會有解釋嗎? }通過模擬

{ 
"FunctionalGroup": { 
    "TransactionSet": { 
     "@controlNumber": "270001", 
     "Area": [ 
      { 
       "Segment": [ 
        { 
         "@id": "BEG", 
         "Element": [ 
          { 
           "@pos": "1", 
           "#text": "00" 
          }, 
          { 
           "@pos": "2", 
           "#text": "SA" 
          }, 
          { 
           "@pos": "3", 
           "#text": "86816853" 
          }, 
          { 
           "@pos": "5", 
           "@date": "2015-04-09", 
           "#text": "20150409" 
          } 
         ] 
        }, 
        { 
         "@id": "REF", 
         "Element": [ 
          { 
           "@pos": "1", 
           "#text": "DP" 
          }, 
          { 
           "@pos": "2", 
           "#text": "16" 
          }, 
          { 
           "@pos": "3", 
           "#text": "DEPARTMENTA" 
          } 
         ] 
        } 
       ], 
       "SegmentLoop": [ 
        { 
         "@id": "N9", 
         "@name": "N9", 
         "Segment": [ 
          { 
           "@id": "N9", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "ST" 
            }, 
            { 
             "@pos": "2", 
             "#text": "001" 
            } 
           ] 
          }, 
          { 
           "@id": "DTM", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "010" 
            }, 
            { 
             "@pos": "2", 
             "@date": "2015-04-12", 
             "#text": "20150412" 
            }, 
            { 
             "@pos": "3", 
             "@time": "00:00:00", 
             "#text": "0000" 
            } 
           ] 
          }, 
          { 
           "@id": "DTM", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "002" 
            }, 
            { 
             "@pos": "2", 
             "@date": "2015-04-12", 
             "#text": "20150412" 
            }, 
            { 
             "@pos": "3", 
             "@time": "12:34:34", 
             "#text": "123456" 
            } 
           ] 
          }, 
          { 
           "@id": "DTM", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "001" 
            }, 
            { 
             "@pos": "2", 
             "@date": "2015-04-30", 
             "#text": "20150430" 
            }, 
            { 
             "@pos": "3", 
             "@time": "12:34:34.789", 
             "#text": "123456789" 
            } 
           ] 
          } 
         ] 
        }, 
        { 
         "@id": "N1", 
         "@name": "N1", 
         "Segment": [ 
          { 
           "@id": "N1", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "ST" 
            }, 
            { 
             "@pos": "2", 
             "#text": "COMPANY INC." 
            }, 
            { 
             "@pos": "3", 
             "#text": "92" 
            }, 
            { 
             "@pos": "4", 
             "#text": "001" 
            } 
           ] 
          }, 
          { 
           "@id": "N3", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "123 main street" 
            }, 
            { 
             "@pos": "2", 
             "#text": "PH:(644)123-4567" 
            } 
           ] 
          }, 
          { 
           "@id": "N4", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "Elk Grove Village" 
            }, 
            { 
             "@pos": "2", 
             "#text": "IL" 
            }, 
            { 
             "@pos": "3", 
             "#text": "6007" 
            }, 
            { 
             "@pos": "4", 
             "#text": "US" 
            } 
           ] 
          } 
         ] 
        }, 
        { 
         "@id": "N1", 
         "@name": "N1", 
         "Segment": [ 
          { 
           "@id": "N1", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "SF" 
            }, 
            { 
             "@pos": "2", 
             "#text": "EDGE ENTERPRISES" 
            }, 
            { 
             "@pos": "3", 
             "#text": "92" 
            }, 
            { 
             "@pos": "4", 
             "#text": "99999" 
            } 
           ] 
          }, 
          { 
           "@id": "N3", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "2645 W. Coast Highway" 
            } 
           ] 
          }, 
          { 
           "@id": "N4", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "Silicon Valley" 
            }, 
            { 
             "@pos": "2", 
             "#text": "CA" 
            }, 
            { 
             "@pos": "3", 
             "#text": "56874" 
            }, 
            { 
             "@pos": "4", 
             "#text": "US" 
            } 
           ] 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       "SegmentLoop": [ 
        { 
         "@id": "PO1", 
         "@name": "PO1", 
         "Segment": [ 
          { 
           "@id": "PO1", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "1" 
            }, 
            { 
             "@pos": "2", 
             "#text": "96" 
            }, 
            { 
             "@pos": "3", 
             "#text": "EA" 
            }, 
            { 
             "@pos": "4", 
             "#text": "2.05" 
            }, 
            { 
             "@pos": "6", 
             "#text": "BP" 
            }, 
            { 
             "@pos": "7", 
             "#text": "HB-Natural Adult Bat" 
            } 
           ] 
          } 
         ], 
         "SegmentLoop": [ 
          { 
           "@id": "PID", 
           "@name": "PID", 
           "Segment": [ 
            { 
             "@id": "PID", 
             "Element": [ 
              { 
               "@pos": "1", 
               "#text": "F" 
              }, 
              { 
               "@pos": "5", 
               "#text": "DESCRIPTION" 
              } 
             ] 
            } 
           ] 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       "SegmentLoop": [ 
        { 
         "@id": "CTT", 
         "@name": "CTT", 
         "Segment": [ 
          { 
           "@id": "CTT", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "6" 
            } 
           ] 
          }, 
          { 
           "@id": "AMT", 
           "Element": [ 
            { 
             "@pos": "1", 
             "#text": "TT" 
            }, 
            { 
             "@pos": "2", 
             "@number": "1000.00", 
             "#text": "100000" 
            } 
           ] 
          } 
         ] 
        } 
       ] 
      } 
     ] 
    } 
} 

返回

我的表述例

我實際上政策的相關API運算

<policies> 
<inbound> 
    <!--base: Begin Global scope--> 
    <!-- PC-1404 --> 
    <set-query-parameter name="subscription-key" exists-action="delete" /> 
    <!--base: End Global scope--> 
</inbound> 
<backend> 
    <!--base: Begin Global scope--> 
    <forward-request /> 
    <!--base: End Global scope--> 
</backend> 
<outbound> 
    <mock-response status-code="200" content-type="application/json" /> 
</outbound> 
<on-error> 
    <!--base: Begin Global scope--> 
    <!-- By placing policy statements in the on-error section you can review the error by 
    using the context.LastError property, inspect and customize the error response using the 
    set-body policy, and configure what happens if an error occurs. 
    There are error codes for built-in steps and for errors that may occur during the processing of 
    policy statements. 
    For more information, see https://msdn.microsoft.com/en-us/library/azure/mt629506.aspx 
    statements to be applied if there is an error condition go here --> 
    <!-- for CORS support to Office Add-In to detect subscription key errors, etc. PLEX-JIRA: PC-725 TSCH 8/16/16 --> 
    <set-header name="Access-Control-Allow-Origin" exists-action="override"> 
     <value>*</value> 
    </set-header> 
    <!--base: End Global scope--> 
</on-error> 

+0

還嘲笑的運算需要幾秒鐘無論是第一次,我還第一次嘗試了多種不同的嘲笑OPS,互相嘲笑op是一個毫秒的十分之一無論是第一或不。我確信它是特定於這個嘲弄的操作 –

+0

如果您從門戶網站運行此請求,您是否看到相同的低速?跟蹤是否暗示延遲來自何處? –

+0

此外,如果您將模擬響應策略移至入站部分,性能是否會提高? –

回答

2

我發現我需要動模擬調用入站部分。這是前進到後端(我實際上沒有一個花時間的後端)。新OP政策

<policies> 
<inbound> 
    <mock-response status-code="200" content-type="application/json" /> 
    <base /> 
</inbound> 
<backend> 
    <base /> 
</backend> 
<outbound> 
    <base /> 
</outbound> 
<on-error> 
    <base /> 
</on-error> 

+0

我會要求團隊爲什麼你可能想要把它除入站以外的任何地方。如果沒有任何理由,我們應該更新文檔。 –

+0

謝謝,@DarrelMiller - 如果不僅僅是文檔,UI也是如此。不適當地放置時,UI也抱怨其他的策略元素。 –

+1

我們明確地允許其他地方。我只是不確定我們爲什麼這樣做。 –