2

Computer-architecture-wise, I was looking into http://nginx.org/r/proxy_buffers, and the default is set to be eight memory-page-sized buffers.

This makes sense if you try to rationalise it — if the request would fit into a single buffer, why waste any extra memory for it — until you recall a slide of the PHK presentation on varnish-cacheSPECIAL OFFER! — VIRTUALLY FREE MEMORY — OFFER GOOD FROM 1980 ONWARDS.

So, if memory is indeed virtually free, why does nginx have a setting with 8 page-sized buffers by default, instead of simply having a single buffer of 8 times the page size? (Or is that how it's actually handled underneath?)

cnst
  • 25,870
  • 6
  • 90
  • 122
  • The 'all shouting' text is often a sign of problems such as a spam question. I recommend avoiding that by case-converting to title-case or lower-case. – Jonathan Leffler Jun 16 '18 at 22:16
  • 1
    One possible answer is that Nginx uses (fills) one buffer at a time, and goes on to use the next while the first is being written (or is waiting to be written), so it doesn't get hung up by having to wait until all 32 KiB are written (or it doesn't have to use multiple 32 KiB buffers). If it is read-only buffering, it may be that the entries cached are small enough that it can get 8 different entries in the cache with the 8 separate pages, whereas a 32 KiB page would mean only one unit of data could be in cache at a time. It's probably an engineering trade-off. It may even be outdated. – Jonathan Leffler Jun 16 '18 at 22:19
  • @JonathanLeffler, these are buffers used for a single response caching from the upstream server, e.g., it's fundamentally a single-threaded operation that'd be at stake. – cnst Jun 17 '18 at 01:49

0 Answers0