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

Configurable mutex backend. #7

Open
rossigee opened this issue May 19, 2020 · 2 comments
Open

Configurable mutex backend. #7

rossigee opened this issue May 19, 2020 · 2 comments

Comments

@rossigee
Copy link
Contributor

OK, so mutex files in a directory somewhere on the web host are great to keep things simple for an average single-host application or local developer environment.

However, in a larger production/clustered/containerised environments, such as we have deployed, we are running 'i18n-hub' containers in a 3-pod deployment for redundancy and load balancing. This means it would create mutex files in the pod filespace of each of the three pods before each pod starts to back off of those requests. Not a big issue, but also not ideal.

My suggestion (well, requirement really) is to make this component more configurable. I suggest to replace the 'file_put_contents' and 'file_get_contents' lines and the '_getMutexPath' method with more generic '_getMutex' and '_setMutex' calls instead, which can then be used to provide a configurable back-end, such as Redis (ideally), that could be used by all three pods to co-ordinate their mutexes.

@rossigee
Copy link
Contributor Author

Thinking aloud... this would also pave the way for a mySQL-based mutex backend, and we already have a db connection which would be shared between multiple instances. That might be an option for some people who need to co-ordinate the mutex state across machines, but who would prefer not to have to run a shared filesystem or a redis service. IMHO, Redis would still be the best option in our circumstances.

@rossigee
Copy link
Contributor Author

Another thought, now my gaze has moved on to the CacheAdapter parts of the code, and seeing how that uses PSR6 (good stuff!), and the mutexes are essentially just TTLs, I'm wondering if maybe that's an API that the '_getMutex' and '_setMutex' calls could make use of.

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

No branches or pull requests

1 participant