-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
perf: accelerate the creation of the consumer cache #11840
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: xuruidong <xuruidong@gmail.com>
To purge local cache need to restart apisix? |
Signed-off-by: xuruidong <xuruidong@gmail.com>
ping @membphis |
conf_version = consumers.conf_version | ||
} | ||
end | ||
|
||
local cached_consumer = consumers_id_cache[val.value.id] |
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.
I do not know why we have to add consumers_id_cache
it seems useless
new_consumer.auth_conf = secret.fetch_secrets(new_consumer.auth_conf, true, | ||
new_consumer.auth_conf, "") | ||
consumer_names[new_consumer.auth_conf[key_attr]] = new_consumer | ||
local new_consumer = lru_cache(consumer.auth_conf[key_attr], |
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.
I think: this should be enough, and it seems easier
local new_consumer = lru_cache(consumer.auth_conf[key_attr], | |
local new_consumer = lru_cache(consumer, nil, create_new_consumer, consumer) |
do | ||
local consumers_plugin_key_lrucache_tab = {} | ||
|
||
local function create_new_consumer(consumer) |
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.
we need a better name, it is not creating a new consumer
it should be transform
or fill secret
, what do you think?
Description
In my case, there are approximately 17,000+ consumers. Any update from a consumer will trigger a long-tail request. I found the methods
consumer.plugin
andconsumer.consumers_kv
cost too much time.Test steps
Update one consumer, send a request. Repeat 5 times.
Test result:
Before optimization:
unit: second
After optimization:
unit: second
Fixes # (issue)
Checklist