Advice on publications and subscriptions for forum

#1

So I’m programming an Internet forum, right? You can see a live demo here, if you’re curious: https://agora-2866.nodechef.com/forum

My problem comes when I want to manage subscriptions for transferring data from the server to the client. Right now, I just have one big subscription for transferring the listing of all posts in the forum to the client, but once the thing starts seeing heavy use that’s not going to work. So I’m going to need to set up some kind of a dynamic subscription model, I think? I’m not sure what factors I should take into account. The simplest way would be to just subscribe to a selection of posts to start with, say the newest 100, or whatever, and then allow users to load more from there, and just have an extra single subscription for each post after that. I’m not sure if thats a good idea though? Please advise. :confused:

#2

The simplest way is what’s recommended in the guide. Which is to have each ‘page’ or ‘container’ component subscribe to only the subset of data it needs.

For example, in a forum:

  • Thread list -> subscribe to topics and not posts
  • View thread -> subscribe to the posts for this thread

This means there’s a little bit of loading time as the data is piped to the client when the navigate between topics, but should be broadly fine.

You may choose to only grab the last n posts in a topic, similar to how Discourse (this forum) does it. And request more posts if the user tries to look at the older posts.

#3

It’s a bit more complicated than that, because my forum doesn’t use threads or topics - each post can have any number of other posts in response, and they form a sort of tree structure. :confused:

#4

Then it depends on what you want to show on first load, and how deep in each tree you show on first load.

If you can record the depth of a post when it’s created, you can filter by depth and limit total records. Then fetch further data as needed

EDIT: Just took a look at the link and depth filtering is probably the way to go

#5

Hmm, even filtering by depth is going to leave people loading more and more posts as time goes on, due to the expanding breadth of the forum. I was planning to have various modes for initial load, “Most recent”, “Most discussed”, "Posts by ", "Posts mentioning " etc, etc. I think that’s pretty straightforward, I just use an appropriate subscription and limit it to a hundred posts or so. I’m also going to want to allow people to just start loading more posts at any time though - that is to say, they’re browsing, and they see a post and want to read more, they can click on it and load it’s replies and it’s parent, and maybe see other posts using the same hashtags or whatever. The part I’m not sure of is how to manage these subscriptions - do I just have a javascript object somewhere that keeps track of them, and adds or removes them as needed? Or is there a better way…? :confused:

#6

Hmm. So I’m thinking maybe I should use a SubsManager? Is there a more up to date version of MeteorHacks one, or is it fine even if it is a few years old…? :confused: