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

Add Redis job #322

Merged
merged 1 commit into from
Jul 10, 2023
Merged

Add Redis job #322

merged 1 commit into from
Jul 10, 2023

Conversation

philippthun
Copy link
Member

@philippthun philippthun commented Jun 27, 2023

  • Redis will be used for rate limiting and (at a later point in time) also for metrics.
  • The monit process will only be started if either the Puma webserver is used or cc.experimental.use_redis is set to true (defaults to false).
  • If Redis is used, the CC config redis.socket is set; this switches the rate limit implementation from using in-memory counters to Redis.

See also cloudfoundry/cloud_controller_ng#3290.

  • I have viewed signed and have submitted the Contributor License Agreement

  • I have made this pull request to the develop branch

  • I have run CF Acceptance Tests on bosh lite

@philippthun
Copy link
Member Author

I've benchmarked the different rate limiting implementations (with the helper script from this PR] and got the following results:

  • The time cost for the in-memory implementation is ~0.004ms per rate limit event1.

  • For the Redis-based implementation, the time cost is ~0.1ms per rate limit event.

When rate limiting 10K users (all kinds of rate limits enabled and applied), there are 30K keys stored in Redis and the process consumes ~10MB. For 100K users (definitely an extreme scenario!), there are 300K keys and ~44MB memory is used.

Footnotes

  1. ExpiringRequestCounter:increment, ConcurrentRequestCounter:try_increment?, ConcurrentRequestCounter:decrement

- Redis will be used for rate limiting and (at a later point in time)
  also for metrics.
- The monit process will only be started if either the Puma webserver is
  used or 'cc.experimental.use_redis' is set to 'true' (defaults to
  'false').
- If Redis is used, the CC config 'redis.socket' is set; this switches
  the rate limit implementation from using in-memory counters to Redis.
@philippthun
Copy link
Member Author

With this change we set vm.overcommit_memory=1 on VM level. As there are memory thresholds (e.g. restart_if_above_mb) for CC that can/should be configured, the risk should be low...

@philippthun philippthun marked this pull request as ready for review July 10, 2023 09:11
@philippthun philippthun merged commit 0f457f0 into cloudfoundry:develop Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants