Twenty-four things you can do to make SMF go faster (Updated June 16th, 2010)

Started by Vekseid, February 16, 2009, 06:29:50 AM

Previous topic - Next topic

Something like that

Are you sure you're editing the right configuration file? Or that you're restarting mysql, not reloading it?

Ensiferous

Quote from: «Mark» on June 07, 2011, 02:22:02 PM
Try:

CREATE TABLE smf_sessions ( session_id char(32) NOT NULL, last_update int(10) unsigned NOT NULL, data varchar(16384) NOT NULL, PRIMARY KEY (session_id)) TYPE=MEMORY;


A varchar that long has worked fine for me.

Are you sure this is wise? As far as I know memory tables do not support varchars, instead they act like a normal char, so basically for each session you'll be allocating a metric ****** ton of bytes.

If you want sessions in memory then install memcached (or APC?) and use its memory session handler.

If you're on shared hosting or otherwise cannot install memcached (or APC?) then you don't need sessions in memory.
My Latest Blog Post: Debugging Nginx Errors

Something like that

Quote from: Ensiferous on June 14, 2011, 12:39:01 PM
Quote from: «Mark» on June 07, 2011, 02:22:02 PM
Try:

CREATE TABLE smf_sessions ( session_id char(32) NOT NULL, last_update int(10) unsigned NOT NULL, data varchar(16384) NOT NULL, PRIMARY KEY (session_id)) TYPE=MEMORY;


A varchar that long has worked fine for me.

Are you sure this is wise? As far as I know memory tables do not support varchars, instead they act like a normal char, so basically for each session you'll be allocating a metric ****** ton of bytes.

If you want sessions in memory then install memcached (or APC?) and use its memory session handler.

If you're on shared hosting or otherwise cannot install memcached (or APC?) then you don't need sessions in memory.

Agreed on all points.

The memory usage isn't all that bad though. For a thousand users, it's 16MB. And the data is hot, as the sessions table should only be holding active users (unless Debian has mucked with PHP's session killing).

Warlock666

Quote from: «Mark» on June 13, 2011, 05:53:56 PM
Are you sure you're editing the right configuration file? Or that you're restarting mysql, not reloading it?

Hi Mark,

sorry for my late answer. I just checked this again on 3 machines with Ubuntu 10.04 LTS 64 Bit.
On the productive Server and the development Server mysql ignores several innodb variables which I set in my.cnf.
On my Workstation everything works fine.

So it HAS to be some sort of stupid problem with the guy who is editing the confgiles   8)

The other thing is : My perfornace problems are solved.
Even with your tuning hints I still had slow writing querys.

The solution (in my case) was :

ALTER TABLE smf_settings TYPE=MyISAM;
ALTER TABLE smf_log_mark_readTYPE=MyISAM;
ALTER TABLE smf_log_boards TYPE=MyISAM;
ALTER TABLE smf_attachments TYPE=MyISAM;

Now SMF runs like a sportscar  :)


Thanks again for all your help !

Joshua Dickerson

I would definitely use APC or memcache for sessions. No reason not to IMO.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Something like that

Quote from: Joshua Dickerson on June 15, 2011, 07:42:46 PM
I would definitely use APC or memcache for sessions. No reason not to IMO.

Unless you're using SMF 1.1. I don't recall it having the ability to use APC or memcached for sessions.

Joshua Dickerson

Does that mean that 2.0 can't handle APC/Memcached sessions? Sorry for the ignorance.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Ensiferous

Quote from: «Mark» on June 16, 2011, 02:12:09 AM
Quote from: Joshua Dickerson on June 15, 2011, 07:42:46 PM
I would definitely use APC or memcache for sessions. No reason not to IMO.

Unless you're using SMF 1.1. I don't recall it having the ability to use APC or memcached for sessions.

Memcached, at least, has a transparent handler you can set in php.ini. That way SMF just have to use the normal session functions to store in memcached.
My Latest Blog Post: Debugging Nginx Errors

Something like that

Quote from: Ensiferous on June 17, 2011, 08:49:51 AM
Quote from: «Mark» on June 16, 2011, 02:12:09 AM
Quote from: Joshua Dickerson on June 15, 2011, 07:42:46 PM
I would definitely use APC or memcache for sessions. No reason not to IMO.

Unless you're using SMF 1.1. I don't recall it having the ability to use APC or memcached for sessions.

Memcached, at least, has a transparent handler you can set in php.ini. That way SMF just have to use the normal session functions to store in memcached.

Ahh, yeah, I should do that.

Joshua Dickerson

Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

charles245

thanks for sharing informative article with everyone. really nice thread and share more interesting news with us.

.Vapor


dcmouser

Thank you again for this fantastic thread.
I made a more elaborate backup script based on your suggested backup code, and included a script for backing up attachments.  More info and download here: http://www.donationcoder.com/forum/index.php?topic=27492
proud member of donationcoder.com (forum)

Vekseid

Quote from: Ensiferous on June 14, 2011, 12:39:01 PM
Quote from: «Mark» on June 07, 2011, 02:22:02 PM
Try:

CREATE TABLE smf_sessions ( session_id char(32) NOT NULL, last_update int(10) unsigned NOT NULL, data varchar(16384) NOT NULL, PRIMARY KEY (session_id)) TYPE=MEMORY;


A varchar that long has worked fine for me.

Are you sure this is wise? As far as I know memory tables do not support varchars, instead they act like a normal char, so basically for each session you'll be allocating a metric ****** ton of bytes.

If you want sessions in memory then install memcached (or APC?) and use its memory session handler.

If you're on shared hosting or otherwise cannot install memcached (or APC?) then you don't need sessions in memory.

It 'wastes' about ~8k per session, on average, though I'm not sure how much more efficient memcached's function would be - sessions can and do reach into the 14k range, and memcached gives stuff an arbitrary amount of space rather than storing it efficiently.
Adult Role Playing Forums - - Over five million posts - - Elliquiy's LAMP configuration (maybe NSFW)

Blog about Forums and Servers - - Twenty things to make Simple Machines Forum go faster

Private/Instant Message requests for free support will be ignored.

colby2152

Quote# Turn it on
ExpiresActive On

# Set a default expiry time. One hour is fine, but a day or longer may be appropriate.
ExpiresDefault A3600

# Turn expiry off for dynamic content (or potentially dynamic content).
ExpiresByType application/x-httpd-php A0
ExpiresByType application/x-python-code A0
ExpiresByType text/html A0

<FilesMatch "\.(php|py|pyc|pyo)$">
  ExpiresActive Off
</FilesMatch>

Do I simply add this (as quoted) to my .htacess file in my domain's root file directory?
ProFSL.com - Pro Fantasy Sports Leagues - Advanced fantasy sports leagues, contests, free chances at cash/prizes, and sports discussion.

Need a server? I am happy to advocate this hosting solution - hands on customer service and reliability is relieving!!!

colby2152

A lot of this is above my head.... looking to hire someone to make these changes.
ProFSL.com - Pro Fantasy Sports Leagues - Advanced fantasy sports leagues, contests, free chances at cash/prizes, and sports discussion.

Need a server? I am happy to advocate this hosting solution - hands on customer service and reliability is relieving!!!

h78509

Word of warning. Seems like that for certain forums #8 actually decreases performance, not improves it. So if you run that script, observe what happens to your database size and cancel the script if the database becomes bigger.

青山 素子

Quote from: h78509 on September 07, 2011, 12:48:58 PM
Word of warning. Seems like that for certain forums #8 actually decreases performance, not improves it. So if you run that script, observe what happens to your database size and cancel the script if the database becomes bigger.

Actually, it's a tradeoff. You'll get a larger database, but SMF will have to do less work. You're trading a larger table for a performance increase. If you have a highly-active board, it's a good script. If your board has lots of older unused accounts, you'll get a large jump in size and not much performance increase as all the inactive users will be updated as well.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Edward123

Thanks for posting this list.

#1 is very important, if it's the one where you let browsers cache avatar images.  I recall that SMF out of the box does not let the browser cache the avatars but instead requires php processing... which can be a huge performance hit...

Edward123

By the way, a great tool for testing overall site performance is webpagetest.org [nofollow] (I can't post it as a link).  It shows you how long it takes for the first byte to be sent, and how long it takes for the JS and CSS files to be sent, as well as all the image files, etc.

Advertisement: