Skip to content
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

cache-locks #1402

Merged
merged 6 commits into from
Jul 23, 2016
Merged

cache-locks #1402

merged 6 commits into from
Jul 23, 2016

Conversation

subnetmarco
Copy link
Member

@subnetmarco subnetmarco commented Jul 15, 2016

When requesting a specific entity from the database, only one request to the database per node is allowed. This dramatically improves reliability during heavy load.

For example: let's say that 1000 req/s are being processed by a Kong node, and suddenly an in-memory entity is being invalidated and Kong needs to read it again from the database. Before this PR Kong would open 1000req/s to the database until that entity is stored into memory again. With this PR, only one read request will be opened to the database (per node), and the other requests (on the same node) will just wait until it's finally in memory again.

This also helps the performance of new nodes that are being added to the cluster (whose load goes from 0 to 100 real quick).

Closes #264.

@Tieske
Copy link
Member

Tieske commented Jul 20, 2016

lgtm

@Tieske Tieske added this to the 0.9 milestone Jul 20, 2016
@@ -34,6 +34,7 @@ lua_shared_dict cache ${{MEM_CACHE_SIZE}};
lua_shared_dict reports_locks 100k;
lua_shared_dict cluster_locks 100k;
lua_shared_dict cluster_autojoin_locks 100k;
lua_shared_dict cache_locks 100k;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not need so many different *_locks shared dicts. A single one is able to hold multiple locks with different options (expiration, timeout, etc...). It will be worth cleaning this up some time soon.

@thibaultcha thibaultcha added pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. and removed pr/status/needs review labels Jul 22, 2016
@subnetmarco
Copy link
Member Author

@thibaultcha addressed last comments.

exptime = ASYNC_AUTOJOIN_INTERVAL - 0.001
})
if not lock then
ngx_log(ngx.ERR, "failed to init lock dictionary", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The err variable will tell what the error is. Should be "could not create lock: "

@subnetmarco subnetmarco added pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release) and removed pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. labels Jul 23, 2016
@subnetmarco
Copy link
Member Author

All comments addressed.

@subnetmarco subnetmarco merged commit 794f480 into next Jul 23, 2016
@subnetmarco subnetmarco deleted the feature/cache-semaphore branch July 23, 2016 00:54
thibaultcha added a commit that referenced this pull request Jul 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants