-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[THREESCALE-8410] Add support to set proxy buffer size #1475
Conversation
CHANGELOG.md
Outdated
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
- Support Financial-grade API (FAPI) - Baseline profile [PR #1465](https://github.com/3scale/APIcast/pull/1465) [THREESCALE-10973](https://issues.redhat.com/browse/THREESCALE-10973) | |||
|
|||
- Added `APICAST_PROXY_BUFFER_SIZE` variable to allow configure the size of the buffer used for handling the response received from the proxied server. [PR #1473](https://github.com/3scale/APIcast/pull/1473), [THREESCALE-8410](https://issues.redhat.com/browse/THREESCALE-8410) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Added `APICAST_PROXY_BUFFER_SIZE` variable to allow configure the size of the buffer used for handling the response received from the proxied server. [PR #1473](https://github.com/3scale/APIcast/pull/1473), [THREESCALE-8410](https://issues.redhat.com/browse/THREESCALE-8410) | |
- Added the `APICAST_PROXY_BUFFER_SIZE` variable to allow configuration of the buffer size for handling responses from proxied servers. [PR #1473](https://github.com/3scale/APIcast/pull/1473), [THREESCALE-8410](https://issues.redhat.com/browse/THREESCALE-8410) |
doc/parameters.md
Outdated
**Default:** 4k|8k; | ||
**Value:** string | ||
|
||
Sets the size of the buffer used for handling the response received from the proxied server. This variable will set both [`proxy_buffer` NGINX directive](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers) and [`proxy_buffer_size` NGINX directive](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size). By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets the size of the buffer used for handling the response received from the proxied server. This variable will set both [`proxy_buffer` NGINX directive](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers) and [`proxy_buffer_size` NGINX directive](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size). By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform. | |
Sets the size of the buffer used for handling the response received from the proxied server. This variable sets both [`proxy_buffer` NGINX directive](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers) and [`proxy_buffer_size` NGINX directive](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size). By default, the buffer size is equal to one memory page. This is either 4 K or 8 K, depending on a platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What unit does the K stand for? Do you mean kilobytes or kibibytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for my ignorance, but aren't they the same? ie 1024bytes? Actually the above sentence was copied from Nginx docs
https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I asked for clarification is that the IBM Style Guide "distinguishes between uppercase K
(meaning 1024, or 2 to the power of 10) and lowercase k (meaning 1000, or 10 to the power of 3). Therefore, KB means 1024 bytes, and kB means 1000 bytes" for kilobyte, and therefore we must use either KB (1024 bytes) or kB (1000 bytes) depending on the meaning of 4 K or 8 K in the documentation.
However, we would write kibibytes as KiB.
Sorry for the confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dfennessy updated to use KiB as you suggested. If you are happy with this change, could you please click that ✅ button? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tkan145 It wasn't my intention to muddy the waters. Thank you for your understanding 😄
I'll just to reiterate, KB means 1024 bytes, and kB means 1000 in kilobytes.
If you're sure you want to use kibibytes (KiB), where KiB equals 1024 bytes, then I approve.
Either if the above I approve as long as it works for the reader in their understanding 🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of suggestions and a question 🤓
@dfennessy thanks. I've updated the documentation based on your feedback |
e70fd45
to
9b428f9
Compare
9b428f9
to
5b984c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
What
Fix https://issues.redhat.com/browse/THREESCALE-8410
Notes
What are the differences between buffers?
proxy_buffers
: this is the total size of the buffer that Nginx can use to hold the response from upstream. If the size of the response larger then the total size of the proxy_buffers Nginx will write response to diskproxy_buffer_size
: mainly used to hold the response header.proxy_busy_buffer_size
: size of the buffer can be used for delivering the response to clients while it was not fully read from the upstream server.What are the correct values for the buffers?
proxy_buffers
:proxy_buffer_size
:proxy_busy_buffer_size
:Min: can't be smaller than a single proxy_buffers and must be equal to or greater than the maximum of the value of
proxy_buffer_size
and one of theproxy_buffers
.Max: must be less than the total value of proxy_buffers minus one buffer. (ie 8*4 = 32k - 4k = 28k)
Default: if not explicitly defined, the value for proxy_busy_buffer_size is "the bigger of: twice proxy_buffer_size and the size of two proxy_buffers". This also mean if you set bigger proxy_buffer_size, you are implicitly increasing proxy_busy_buffer_size as well.
Reference: https://github.com/nginx/nginx/blob/master/src/http/modules/ngx_http_proxy_module.c#L3442
Why 4k|8k?
This is equal to one memory page size, ie either 4K or 8K, depending on a platform.
How to check my pagesize
Would increase buffer size also increase the memory consumption?
Yes the buffer is allocated per connection. How much you may ask? I honestly don't know, once I get the profiling tool sorted I'll run a few benchmark tests.
Increase the buffer number vs increase the buffer size
The difference between a bigger number of smaller buffers, or a smaller number of bigger buffers, may depend on each user use case, ie a lot of small size response vs a lot of big response. As well as how much memory they have and how much memory they want to be wasted. So it's hard to provide one solution to fit all.
Due to the above complex rule, I personally think we should just provide one setting and increase the buffer size instead of messing around with the number and size of the buffer. And memory is cheap.
The downside of this approach is if user set a really big buffer size, ie
proxy_buffers: 8 1024k
ie allocating a 1MB buffer for every buffered connection even the response can fit in the default memory page size (4k|8k). However from my initial test, nginx allow allocate needed memory, again I will need to get those profiling tools sorted so I can peek into what is allocated.Does this setting apply per product?
No this setting is global.
Common errors:
proxy_buffer_size is the only directive that needs tuning in order to solve the error. However due to the rule described above, proxy_busy_buffer_size also needs adjustment
Verification steps
docker-compose-devel.yaml
as followapicast-config.json
file with the following contentIt should return 502
and this line from the log
This time it should return HTTP/1.1 200 OK