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

MultiSite Questions #37

Open
MadtownLems opened this issue Nov 14, 2023 · 5 comments
Open

MultiSite Questions #37

MadtownLems opened this issue Nov 14, 2023 · 5 comments

Comments

@MadtownLems
Copy link

I've been loving the performance improvements that come with Surge, and I've been digging into it more and more. I've got a couple questions, especially as it pertains to MultiSite.

You said that it's supported out of the box (https://wordpress.org/support/topic/multisite-636/). However, the more that I learn about how everything works, I'm wondering if there might be some ways to improve MultiSite performance.

Just for reference, our MultiSites contain several hundred sites - not a small handful.

It seems that if any site on the network does any of the things in $flush_actions, the entire network's cache is immediately invalidated. So, one site changing themes, activating a plugin, etc will expire the cache for several hundred other sites which were not impacted at all by the change. This means our cache is getting expired very frequently, and well in advance of the longer time I'm trying to support.

I was wondering if there's any compelling reason why subsites don't operate more independently. For example, if each subsite maintained its own /wp-content/cache/surge/flags.json.{$blog_id}.php file, and then only flush the cache for the impacted subsite during those actions. Of course, there are still SOME actions that should likely flush the entire network's cache, such as WP itself updating or a plugin being network activated/deactivated.

@ingageco
Copy link

@MadtownLems great question and i'm also looking to hear the answer!

kovshenin added a commit that referenced this issue Feb 3, 2024
@kovshenin
Copy link
Owner

Hey folks, thanks for bringing this up, definitely an oversight which I've addressed in a recent commit.

Not sure I like the idea of separate flag files. Out of curiosity, how large is your current flags file with the several hundred sites in the network?

@ingageco
Copy link

ingageco commented Feb 3, 2024

Thanks @kovshenin!

Recent commit for references
54f57a6

@MadtownLems
Copy link
Author

Out of curiosity, how large is your current flags file with the several hundred sites in the network?

Currently it's only about 200KB, but with you addressing some of my recent issues/requests, I'm expecting that to grow significantly. I've held off on adding my own flags because of how it WAS working in Multisite, where a change on one site would flush the entire network. It didn't seem super necessary to get too aggressive in doing my own flagging, because everything would get invalidated frequently. With the change to Multisite functionality, my plan is to try to keep a relatively long TTL for most pages (as plenty of our sites are actively browsed but basically never updated). The manual flagging should help keep things fresh for the sites that DO have active content changes frequently.

Thank you so much for addressing the Multisite invalidation issue! I'm really excited to take a look at the changes and get these rocking. 🤘

@kovshenin
Copy link
Owner

Sounds good! The recent change shouldn't affect the size too much if it's already 200kb, there should be at most as many new flags as the number of sites in the network, so ~ 16 bytes for flag name and ~ 10 bytes for the timestamp (as a string), round to 32 bytes. For 1000 sites that would be + 32kb. I am a bit worried about how long a lookup would take with such a large object though, should probably run some benchmarks! I'd also be curious to know if it grows larger than that!

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

3 participants