Cache Hit Latency for large responses.

Maxim Dounin mdounin at
Fri May 9 00:59:12 UTC 2014


On Thu, May 01, 2014 at 06:27:19PM -0400, lovekmla wrote:

> Context: 
> I am currently using nginx to serve as a Response Cache Proxy in order to
> shim-out (isolate) network latency while running some performance related
> tests.
> The Perf Tests are comprised of 50 repetitions of the same set of requests.
> => I have been able to successfully set-up the proxy_cache so that it would
> Cache the requests. 
> (I'm using the request_uri and request_body as the cache_key, since I need
> to Cache POST Requests as well)
> (Our POST Requests are not necessarily Write Requests since our API is using
> the POST Params for cases where we need to specify longer Params that exceed
> the limit on GET)
> => I am logging the Cache HIT Status and Request_time in the access_log and
> basically, I am seeing a variance between 500 ms ~ 2 seconds for the Same
> Request being Served from the Cache even when it's both a HIT. The Size of
> the Response is around 170K, and the request_body length is 65k. Most of the
> other HITS are like 0~100ms for request_time and only the ones that are made
> around that huge request seems to have some latency.
> Question:
> #1 I'm using proxy_cache_path. Is it possible that disk I/O is causing this
> latency? I thought the Filesystem Cache was able to handle these Cache HITs
> in memory.

This depends on OS and filesystem you are using, as well as amount 
of memory you have.

> #2 When I set the cache_key to be a combination of the request_body and
> request_uri itself, when it does the lookup, would it automatically pull
> those and to the lookup as expected?

ENOPARSE, but note that $request_body variable only works if a 
request body is small enough and fits in client_body_buffer_size. 

Maxim Dounin

More information about the nginx mailing list