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
Align rate limiter & cache memcached configuration #7784
Comments
Ahh I think I know where the problem is.. The cache provider (keyv) relies on memjs, while the rate limiter package relies on memcached. Memcached uses an array, while memjs uses a comma separated string 🙈 |
Yup, that seems to be it. This is positively stupid, but try:
that seems to make it go on my end |
I can confirm it works with this configuration, locally and in our production environment!
I don't know what else I can do to help, An improvement would be for the documentation, mentioning the format for multiple instances of memcached, but I don't know if the team will plan something different in this case to normalize the env vars here. Thank you @rijkvanzanten :) |
Yeah, I think the ideal solution here is to programmatically account for the fact that keyv relies on a string. A simple "if array -> join with ','" would help tremendously in this case, as we could simply say that you'd use an array across the board 🙂 |
Preflight Checklist
Describe the Bug
We are a NGO that has multiple projects, many of them requires a backend, and we don't have devs for backend, so Directus will help us to achieve to develop great projects setting multiple Directus in our infrastructure.
We are deploying the Directus using docker.
For cache and rate limiting, we will be using 3 hosts of memcached. The deal with this is because creating a cluster of Redis HA takes a lot of work and we know that the load balancing for memcached is done in the client. So that simplifies our infrastructure.
We tried to deploy using this envs:
But we had this problem:
So, We investigated..
According to the log, it uses
Client.create()
with memjs but it seems it doesn't support the array sintax.A set of memcached servers should be set as STRING and not array, so no arrays
So we changed to:
And it works! It seems it creates the client!
But when I go to
https://localhost:8055
it keeps loading and then we get this error:We tried to just use one instance of memcached, and it worked:
We believe we should be able to use multiple hosts for memcached, but we don't know why it fails, or if it just the rate-limiter failing to achieve it.
I know that in the documentation it mentions a singular memcached instance, but we believe we should be able to set up multiple hosts for Cache and Rate Limiting specially if we are considering multiple Directus instances and/or high availability.
CACHE_MEMCACHE
RATE_LIMITER_MEMCACHE
Any ideas or explanation would be very appreciated!
To Reproduce
Here is a
docker-compose.yaml
you can run in your local environment.Then go to
http://localhost:8055
You will see that it fails after a little bit
Now stop the services, and change the yaml to
Run the services, boom! It works! But only one instance.
What version of Directus are you using?
v9.0.0-rc.91
What version of Node.js are you using?
Version shipped with directus/directus:9.0.0-rc.91 (npm 7.20.3)
What database are you using?
mysql:5.7
What browser are you using?
Chome and Firefox (latest)
What operating system are you using?
Ubuntu
How are you deploying Directus?
Docker (directus/directus:9.0.0-rc.91)
The text was updated successfully, but these errors were encountered: