-
-
Notifications
You must be signed in to change notification settings - Fork 613
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
Introduce redis storage which syncs between multiple instances #4074
base: main
Are you sure you want to change the base?
Conversation
…p.storage.general
I started experimenting and found a simple testing setup:
|
Very interesting feature. We are currently synching manually with redis, using the browser tab uid as part of the key, if this could be automated some point this were great of course. As changes in such "shared" variables are in real application likely not as consequenceless like synching two edit fields but might need to trigger a programmatical reaction if some data is changed, is this integrated already? |
@Alyxion app.storage uses |
Thanks, just found the time to do a full code review, really good job so far. The redis server url can not be configured yet nor can the prefix but I assume thats due to the fact its still work in progress. Conceptual though my 2 cents:
|
Thanks for this excellent observations. You are right. There are still a lot of things to be done. I've started a checklist in the PR description to clarify what is missing to go from draft to review.
Yes. After further investigation, I believe it’s beyond the scope of this pull request to handle it differently. The underlying
Yes, this is by design to keep things simple. See below.
This is also true for the existing local persistence.
You are right. But Pydantic is quite slow compared to json etc. We used to have Pydantic everywhere a few years back and need to throw it out the window because of performance cosiderations in our robotics applications. Pydantic is great when you get external data where you can not be sure about the right structure, types etc. But I don't think this is the case when using As a closing comment, I want to clarify a point which I'll also put in the description of the PR because it is so fundamental: This PR will not solve every remote-syncing-problem out there. It is meant as a transparent (eg. non-api-breaking) drop in replacement for the existing local storage mechanism. Your points are all valid but some are just out of scope of what we want to provide here. In the future we may provide a more flexible storage api. See #1606 (reply in thread) |
Thank you for the through explanation. I personally wasn't aware of the performance implications of Pydantic but I think thats because we are more thinking here in dozens of messages exchanged between our servers per second rather than thousands per second on an edge device which might be sent to your Feldfreund, good to know though, will keep an eye on it. Regarding your closing comment: Totally aware of that. Though I still think not being to somehow sync the storage "smarter" than always dumping and parsing that whole thing and very quickly having 95% garbage and just 5% relevant update data is sub optimal :). |
I think there are quite some use cases which would work fine with a full dictionary update. Our existing local storage is also doing it that way because |
This PR tries to solve #1606 by implementing a redis variant of the persistent dictionaries currently used for
app.storage
. This PR will not solve every remote-syncing-problem out there. It is meant as a transparent (eg. non-api-breaking) drop in replacement for the existing local storage mechanism.NOTE: this is in very early development.
ToDos
ui.run
andui.run_with
, if none is given we use the local storage solutionpyproject.toml
app.storage.user
with redisapp.storage.tab
with redis