SimplePortal

Support => English Support => Topic started by: Cermno1981 on February 03, 2011, 06:49:52 PM

Title: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 03, 2011, 06:49:52 PM
Hello,

My web host has requested that I disable my shoutbox (by requested, I mean told!) due to the heavy load this was creating on the server. I had the shoutbox configured as follows;

Shouts to display - 50
Max shouts - 1000
Caching enabled
Autorefresh enabled

My question is, is there a way to reduce the server load? I considered disabling the autorefresh feature, but I am unsure what this will actually achieve. When a user loads the page (and shoutbox) for the first time, what kind of load will this create?

I am running SMF 2.0 RC4 with SP 2.3.3.

I am naturally eager to not have my hosting package disabled completely.

If there are suitable hosts out there who are more supporting, I would be interested in knowing who they are.

Thanks

C
Title: Re: Shoutbox (Heavy Load)
Post by: Nathaniel on February 03, 2011, 07:00:23 PM
Disable the autorefresh, that causes the biggest load. As every user viewing your site will make a request every x seconds, to get an update on the shoutbox.

Also consider disabling some of the bbc tags (if you have any enabled).
Title: Re: Shoutbox (Heavy Load)
Post by: keith021773 on February 05, 2011, 11:49:48 AM
also disable the shoutbox for guests.   Use it just for members and that will reduce your load drastically if you have a lot of guests.
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 07, 2011, 09:07:23 AM
Cermno1981 (http://simpleportal.net/index.php?action=profile;u=17308),
 
Does that help?
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 10, 2011, 02:24:10 PM
We had to remove SP completely. My host took a hard line and said the presence of the script was a risk.

So.... I've arranged to move to a host who says I can use it. I just cannot cope with the TP shoutbox or portal, it's utter crud in comparison.

Thank you for the help though, if we experience issues again I'll be making the suggested changes. :)
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 10, 2011, 07:51:23 PM
OK. The shoutbox can introduce a heavy load, though SimplePortal without shoutbox should not be too bad.  If you have trouble on the new host, we'll be here.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 13, 2011, 06:40:16 PM
I changed host and have reinstated the SP shoutbox. The new host is far more obliging!

Again, thank you very much for your help. This is what will keep people coming back. :)

P.S. Do you take donations towards running costs?
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 14, 2011, 07:17:16 AM
Absolutely!
 
http://simpleportal.net/index.php?action=profile;area=subscriptions (http://simpleportal.net/index.php?action=profile;area=subscriptions)
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 15, 2011, 03:30:27 PM
Will set something up. :nervous-happy:

Onto topic...

The new host is watching resource usage carefully, and we don't want to disable the auto refresh (it's just such a great feature), so.... is there a way to have the shoutbox deactivate itself after 'X' minutes of inactivity? Inactivity could be the last time you navigated the site or typed into the shoutbox.

I know of a VB shoutbox that does this.

Thanks
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 15, 2011, 04:21:04 PM
Google is my friend, it seems this has been asked for before.

http://simpleportal.net/index.php?topic=3681.msg23387#msg23387

If I follow the link within, it seems this has already been done for 2.4. This is great news!

Now this might be a tall order, but is there any chance of a way to do it now before my new host goes grey with stress?  :)
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 15, 2011, 06:41:45 PM
I do not know the code to disable refresh on an inactive shoutbox.
For now, I suggest two things:
1) Make the refresh time-out longer
2) Disable most of the BBC permitted in the shoutbox.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 16, 2011, 11:14:29 AM
I'll need to find a more permanent solution I think, my host sent me usage and resource information and we're literally crippling the server.

SP is not only the best portal, but the best shoutbox too. I'll see what I can cook up.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 16, 2011, 05:29:09 PM
We've now increased the refresh to 20 seconds, and are seeing how that goes. My gut feeling is that 20 seconds is too long.

I may be asking for the impossible here, but would there be any chance of a hotfix? I understand if not, you don't want to be supporting different code bases.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 22, 2011, 05:17:16 PM
I'm not into shameless bumps, but I just wondered if there might be any possibility of getting my current shoutbox to deactivate as per the 2.4 version.

Thanks in advance.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 25, 2011, 07:09:23 PM
I think I solved this...

Code: [Select]
if (!empty($shoutbox['refresh']))
echo '
var counter = 0
interval_id_', $shoutbox['id'], ' = setInterval( "sp_auto_refresh_', $shoutbox['id'], '()", ', $shoutbox['refresh'], ' * 1000);


function sp_auto_refresh_', $shoutbox['id'], '()
{
       
if (window.XMLHttpRequest)
{
sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], ');
}
else
clearInterval(interval_id_', $shoutbox['id'], ');

counter++;

if ( counter > 30 )
{
             
clearInterval(interval_id_', $shoutbox['id'], ');
        }
}';

Before tonight I had no experience in Java whatsoever, so if this is a valid fix then I am well chuffed! :nervous-happy: (is it??)

I declared a variable 'counter' as a default value of 0, and then increment this value on each refresh. I hard coded (as a test) a limit of 30, at which point it clears the refresh interval and ends the heavy load on the server.

Please can somebody validate? I am not a programmer, this is the result of many tutorials read over 2 hours.

Thanks!!
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 25, 2011, 07:24:43 PM
This seems like a step in the right direction.
 
You can try this out on a "test" forum to see if it behaves as required (stops refreshing after the count interval).
I will let the team know you are customizing your own workaround.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 25, 2011, 07:29:13 PM
Thanks Angelina

I've tested it on my home laptop with runs Ubuntu with Apache. I had both me and a friend spam the forum (me locally, him remotely) with 80+ sessions between us. After the counter hit 30, the usage dropped.

I guess as a newbie, I was looking for an assurance that my code was sound.

P.S. Thanks for taking the time to look at it :)
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 25, 2011, 10:12:18 PM
(I didn't really take a look at it.  I didn't test it at all).
I'm glad you figured this out. Please let us know how this works on your production forum!
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 26, 2011, 06:08:31 AM
This is in testing at the moment. I have to say, it feels a lot faster already.

Indications early on are good!
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on February 26, 2011, 06:32:38 AM
And on a side note, fixing that was quite a buzz... so I just ordered these:

Beginning HTML With CSS & XHTML: Modern Guide & Reference: Modern Guide and Reference (Beginning: from Novice to Professional) (http://www.amazon.co.uk/gp/product/1590597478/ref=oss_product)

Beginning PHP and MySQL: From Novice to Professional 4th Edition (Expert's Voice in Web Development) (http://www.amazon.co.uk/gp/product/1430231149/ref=oss_product)

 :D

Maybe I'll practice by tinkering with SMF and SP. :thumbsup:
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 26, 2011, 07:26:22 AM
This is great news.
And understanding php will help you understand and customize your SMF forum.
Title: Re: Shoutbox (Heavy Load)
Post by: Robbo on February 27, 2011, 11:29:13 AM
Just so you know. Java and JavaScript are two very different things. The only reason it was called JavaScript was for easy marketing.

Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on February 28, 2011, 07:27:25 AM
The new host is watching resource usage carefully, and we don't want to disable the auto refresh (it's just such a great feature), so.... is there a way to have the shoutbox deactivate itself after 'X' minutes of inactivity? Inactivity could be the last time you navigated the site or typed into the shoutbox.

I declared a variable 'counter' as a default value of 0, and then increment this value on each refresh. I hard coded (as a test) a limit of 30, at which point it clears the refresh interval and ends the heavy load on the server.
Title: Re: Shoutbox (Heavy Load)
Post by: Cermno1981 on March 13, 2011, 12:42:34 PM
I'm back! With more problems, but I've solved them and thought I would share.

The heavy load was not only down to the Shoutbox but also the Aeva Media gallery modification I was running. I would appear the media (mainly YouTube) embedder that comes with Aeva Media was the culprit. I would therefore advise anybody who runs an even moderately busy site to avoid using the Aeva Media gallery modification.

Upon removal of the mod our usage dropped significantly, and the response times are far better.

We've also maintained our changes to the Shoutbox as it cuts the usage associated with that significantly as well.
Title: Re: Shoutbox (Heavy Load)
Post by: AngelinaBelle on March 14, 2011, 02:27:43 PM
Thanks for that report. You might take the report of AEVA media load to that mod's support thread at SimpleMachines.org (Arantor often reads these), or to aeva.noisen.com, where the mods' author might (or might not) be interested in your report.
SimplePortal 2.3.8 © 2008-2024, SimplePortal