2017-08-31 108 views
0

我遇到了與Varnish 4.x文檔不一致的情況。 根據文檔,每次從後端獲取對象時,都會調用vcl_backend_response,並且後端不會返回錯誤(並且存活且健康)。未調用Varnish vcl_backend_response

但是,我注意到許多'fetch'請求(由未命中導致)根本沒有經過這個函數。 下面是一個例子輸出:

- VCL_call  HASH 
- VCL_return  lookup 
- VCL_call  MISS 
- VCL_return  fetch 
- Link   bereq 294915 fetch 
- Timestamp  Fetch: 1504198046.101306 0.003644 0.003644 
- RespProtocol HTTP/1.1 
- RespStatus  200 
- RespReason  OK 
- RespHeader  Server: nginx/1.10.3 (Ubuntu) 
- RespHeader  Date: Thu, 31 Aug 2017 16:47:26 GMT 
- RespHeader  Vary: Accept-Encoding 
- RespHeader  Last-Modified: Thu, 31 Aug 2017 16:42:58 GMT 
- RespHeader  Expires: Thu, 31 Aug 2017 16:47:26 GMT 
- RespHeader  Cache-Control: public, max-age=90, s-maxage=332 
- RespHeader  Pragma: cache 
- RespHeader  X-Lift-Version: 2.6.3 
- RespHeader  X-Frame-Options: SAMEORIGIN 
- RespHeader  Content-Encoding: gzip 
- RespHeader  Content-Type: application/json; charset=utf-8 
- RespHeader  X-Varnish: 294914 
- RespHeader  Age: 0 
- RespHeader  Via: 1.1 varnish-v4 
- VCL_call  DELIVER 
- RespHeader  grace: none 
- VCL_return  deliver 

,而不是附着在文檔的流程:

- VCL_call  BACKEND_FETCH 
- VCL_return  fetch 
- BackendOpen 22 boot.default 127.0.0.1 9919 127.0.0.1 22536 
- Timestamp  Bereq: 1504198040.603601 0.000222 0.000222 
- Timestamp  Beresp: 1504198040.659723 0.056345 0.056123 
- BerespProtocol HTTP/1.1 
- BerespStatus 200 
- BerespReason OK 
- BerespHeader Server: nginx/1.10.3 (Ubuntu) 
- BerespHeader Date: Thu, 31 Aug 2017 16:47:20 GMT 
- BerespHeader Content-Type: text/html;charset=utf-8 
- BerespHeader Transfer-Encoding: chunked 
- BerespHeader Connection: keep-alive 
- BerespHeader Vary: Accept-Encoding 
- BerespHeader Last-Modified: Thu, 31 Aug 2017 16:42:58 GMT 
- BerespHeader Expires: Thu, 31 Aug 2017 16:47:20 GMT 
- BerespHeader Cache-Control: public, max-age=21600, s-maxage=21600 
- BerespHeader Pragma: cache 
- BerespHeader X-Lift-Version: 2.6.3 
- BerespHeader X-Frame-Options: SAMEORIGIN 
- BerespHeader Content-Encoding: gzip 
- TTL   RFC 21600 10 -1 1504198041 1504198041 1504198040 1504198040 21600 
- VCL_call  BACKEND_RESPONSE 

所以 - 根據光油日誌 - 當有未命中並且對象是從取出不支持vcl_backend_response。 除非我錯過了一些東西 - 這與文檔相矛盾。

回答

2

文檔中沒有不一致之處。你看到的是自Varnish 4.0以來的正常行爲。在緩存未命中期間,您會在varnishlog中看到(至少)兩個事務:(1)處理客戶端請求的一個(通常流程爲vcl_recvvcl_hashvcl_missvcl_deliver;即您問題中的第一個日誌摘錄);和(2)處理請求到後端的一個(通常的流程是vcl_backend_fetchvcl_backend_response;即你問題中的第二個日誌摘錄)。這就是爲什麼您在客戶交易中看不到對vcl_backend_response的引用。

顯然這兩個交易都是連接的。客戶端事務創建並等待完成後端事務。這是示出日誌客戶端事務中:

- ... 
- Link   bereq 294915 fetch 
- ... 

這意味着後端交易是爲了從原點取一個對象創建(VXID 294915)。