• Guest, we are pleased to inform you that Forum Promotion has been integrated with Discord. This means no matter where you are you can always stay connected to Forum Promotion. You can connect your Discord account to Forum Promotion by going to you account connected-accounts or by Clicking here. Once your account is connected and if you are part of the FP's Discord, you will automatically be given a role "Approved Users". And when ever a thread/post is created a notication will be posted in #new-threads and #new-posts.

Solved Ajax Threads

Status
Not open for further replies.

Ghost

Seasoned Veteran
Jun 25, 2009
2,995
97
120
Earth
wubur.com
FP$
1,175
To be effective, you're looking at a new SELECT (searching database) query every 5-10 seconds. If you have 200 visitors all in a thread, you're looking at around 200 SELECT queries every 5-10 seconds.
I'm not sure how Xenforo implements this but you should not have to hammer the database...

1. You could hold a cache (think dictionary in Python or Object in JavaScript) of X size (would only need to cover ~10s worth of messages being posted) in memory. Every post goes into that cache in memory in addition to being added to the db, old ones being removed. When a user is on a topic page, it queries the cache to check for new posts.
2. Use websockets to push new messages out to a user when they are received. The user does not have to poll the server for new posts.
Yeah, true - If MySQL caching is set up properly, when you INSERT a new post you are taken to the thread, which then performs a SELECT to get the new post - not in all cases
This would then store the SELECT in cache allowing the auto refresh to access the cache results instead of a brand new select

Could also store the # of replies in a column for thread info instead of the thread replies table being queried. This is an extremely fast query to run, so even if done manually w/ ignoring the cache, the performance hit would not be much
 
  • Like
Reactions: edenwax

Azareal

Paragon
Dec 18, 2010
1,746
353
130
Mars
gosora-project.com
FP$
4,498
I'm not sure how Xenforo implements this but you should not have to hammer the database...

1. You could hold a cache (think dictionary in Python or Object in JavaScript) of X size (would only need to cover ~10s worth of messages being posted) in memory. Every post goes into that cache in memory in addition to being added to the db, old ones being removed. When a user is on a topic page, it queries the cache to check for new posts.
2. Use websockets to push new messages out to a user when they are received. The user does not have to poll the server for new posts.
I don't think you can hold a cache on shared hosting.
Forum Promotion uses a shared host, but it would need a VPS to run APCu.
 
D

Deleted member 44219

Guest
I've heard of Ajax but I'm not sure what it does. Is it like a Live-Chat thing like Discord? I would actually like something like that instead of having to refresh 24/7. But FP does show a pop-up whenever you get a notification while browsing the forum. But again, it'd be a good idea for something like that.
(Please do explain it to me though as I don't have a clue about Ajax. I've only heard of it)
 

Azareal

Paragon
Dec 18, 2010
1,746
353
130
Mars
gosora-project.com
FP$
4,498
I've heard of Ajax but I'm not sure what it does. Is it like a Live-Chat thing like Discord? I would actually like something like that instead of having to refresh 24/7. But FP does show a pop-up whenever you get a notification while browsing the forum. But again, it'd be a good idea for something like that.
(Please do explain it to me though as I don't have a clue about Ajax. I've only heard of it)
Basically, AJAX fires off a request every second (or whatever the interval is) to ask the server for more messages.
Technologies like WebSockets however, like in Discord, hold open a connection and the server pushes through messages whenever something happens.

AJAX is the one which hammers the hell out of a server.
WebSockets is the one which is a lot more efficient, although it does involve holding quite a few connections open and you'll need a far more recent forum software than XenForo, most likely.

Discord would probably go bankrupt, if they used AJAX.
 
Last edited:
  • Like
Reactions: edenwax
Status
Not open for further replies.