Closed tkan145 closed 6 months ago
Also fix the test steps.
Question: The shared dict is shared for all the 3scale products? So if I have 20m, those are shared for me and other 3scale users?
Yes the shared dict is shared between workers and all 3scal products and perhaps user also.
Maybe I would add some documentation with your tests, saying what you can get for the default values of the policy and the new env var for several key sizes. Then the same for half/double of the default value of
batch_report_seconds
. Same thing for haf/double for the default value of the new env var.
Where do you think that doc would live? inside the top level doc or inside the policy?
he top level doc or inside the policy
I would say in the specific readme for the batcher policy: https://github.com/3scale/APIcast/blob/master/gateway/src/apicast/policy/3scale_batcher/README.md
Thanks @dfennessy. I will need your approval also
What
Fixes: https://issues.redhat.com/browse/THREESCALE-9537
Dev notes
1. What shared dict value should we increase?
3scale batcher policy use a few different shared dict caches
and
api_keys
if Caching policy included in the chainFirst let's run some test to see how much
1m
of shared cache can hold.The reason to use
safe_set()
here is to prevent automatic evicting least recently used items upon memory shortage in set().Querying /t gives the response body on my Linux x86_64 system. NOTE: you may get different value as this actually depends on the underlying architecture.
So a
1m
store can hold 4033 key/value pairs with 57-byte keys and 15-byte values. In reality, the actual available space will depend on the memory fragment but since these key/value pairs are consistent in size, we should have no problem. More details hereChanging the "dict" store to 10m gives
So a 10m store can hold 40673 pairs. It's a linear growth as expected.
So we can see that all will grow the equally, but due to the use of safe_add and cache reports for 10 seconds, only
batched_reports
will returnno memory
error.A possible workaround is to set
batch_report_seconds
to lower value.2. Do I need to increase the batcher policy storage.
Let do a small test and increase the key size:
with a key that ~400bytes, with the default report time of 10s for the
batched_reports
to be fully filled, it would require20400/10 = 2040 req/sec
. It's very unlikely that a single gateway will be hit with this much traffic.@eguzki do you know what is the highest load a single gateway can handle?
Verification Steps
Filling the storage is a bit tricky so I just check to see if the configuration file is filled with the correct value.
Create a apicast-config.json file with the following content
Checkout this branch and start dev environment
Run apicast locally with
APICAST_POLICY_BATCHER_SHARED_MEMORY_SIZE
set to 40mStop the gateway
Check that
lua_shared_dict batched_reports
is set to 40m