MyBB Central

Full Version: PHP Optimization
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I followed this discussion on the Mod forum and it didn't really answer my situation. I have my forum on shared hosting and when I try to install eAccelerator, I can't get to all the directories that the installation calls for. It's like they are hidden on my server. I do have Shell access and most of the steps works fine, but when I get to the part with "make install" then I don't have permission.

For instance, I can't get to the etc/php or the usr directories. Anyway, they do allow us to get a copy of the Master PHP which can be copied into your www directory. There, you can add your own settings which theoretically would allow me to use an optimizer. On the forum, they seem to have Zend Optimizer 3.3 and it's running. For the forum, I know the choices are DB, Files and Memcache, eOptimizer. If that's running according to my PHP, is that enough or do I need to install my own copy of Zend Optimizer to get the benefit of optimization and would this help the performance of the forum?

Second, are there instructions somewhere or a way to get eAccelerator or Memcache on a shared host for use by my forum, or is this something I shouldn't worry about? I do tend to collect 10 or 12 "slow queries" 2 or 3 seconds per day. I have optimized my tables, made the Sessions table a heap and all other things I could, but I'm wondering if it wouldn't work better with an optimizer. All my queries are typically under 1 second.

Third, I know you have mentioned caching MySQL Queries. I have PHPAdmin and MySQL admin. Where would I enable this feature on my database?

Sorry for the long questions but I'm developing them as I write them out. Any help you can give would be most welcome.

Thanks,

Charles
Quote:I do tend to collect 10 or 12 "slow queries" 2 or 3 seconds per day

I have hundreds...don't worry about them.

For the rest of your comments I wouldn't worry about it. Does the site run? If so then why are you so concerned about optimizing php?
It runs well. I thought perhaps I should not get these "slow queries" if PHP were optimized. If this is normal, then I'll leave it. I had some CPU usage errors last week so I began trying to optimze as best I could. It get my account suspended and locks people out of my forum which causes them withdrawal symptoms like you wouldn't believe. It was probably more related to my WordPress database on my site more than the forum, but I wanted to make sure I was running the forum correctly.

If you could just provide some information that would just let us know what is considered optimal for these foums. For instance, how much CPU should we be using under normal conditions that is considered optimal? How fast should queries be? How much memory should we be using -- I guess I'm just looking to implement "best practices" when running a forum.

Thanks for your help.
If you're on shared hosting it really depends on their TOS. Also what is the size of your databases for both mybb and WP?

Slow queries happen but imho you can't really correct them easily on prewritten scripts. You just have to take it as they come. Do you know what the queries are that are logged as slow. They are probably related to search. I tried tweaking mine with little success because of the limitations of the options mybb gives you for search control.
The forum database is 39.69M with a cache of 74.83K I don't allow any attachments.

The WP database is only 4.4M. I installed a "supercache WP" plug-in that outputs HTML and it really seemed to increase the speed of WP2.7. I had not been optimizing the table in the WP before last week, so that helped some.

I have enabled (fast cgi) PHP5 on my account.

These are my current stats:

Generated in 0.0913310 seconds (94.98% PHP / 5.02% MySQL)
SQL Queries: 8 / Global Parsing Time: 0.0403571 / Memory Usage: 4.5 MB PHP version: 5.2.8 / Server Load: 2.63 / GZip Compression: Enabled (I have this set to "0")

I had this in my CPU exceeded log for yesterday:

Thu Jan 8 03:54:27 2009: used 366.00 seconds of cpu time for [[mysql query]]
Thu Jan 8 03:54:27 2009: used 0.14 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:27 2009: used 0.38 seconds of cpu time for HTTP Request: zerocarbage.com : GET /showthread.php?tid=825&page=5 HTTP/1.1
Thu Jan 8 03:54:25 2009: used 0.08 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:25 2009: used 0.03 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:24 2009: used 0.08 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:21 2009: used 0.28 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:19 2009: used 0.10 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:14 2009: used 0.16 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:13 2009: used 0.04 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:13 2009: used 0.52 seconds of cpu time for HTTP Request: zerocarbage.com : GET /search.php?action=results&sid=2d13aa4f318ab77d2779612487c4b9c1 HTTP/1.1
Thu Jan 8 03:54:12 2009: used 0.03 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:11 2009: used 0.10 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:09 2009: used 0.02 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:08 2009: used 0.09 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:08 2009: used -0.03 seconds of cpu time for PROCESS : /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:54:02 2009: used 0.01 seconds of cpu time for fcgiphp5
Thu Jan 8 03:53:59 2009: used 0.11 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:58 2009: used 0.12 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:52 2009: used 0.14 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:51 2009: used 0.05 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:48 2009: used 0.10 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:44 2009: used 0.10 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:41 2009: used 0.03 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:40 2009: used 0.15 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:36 2009: used 0.27 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:36 2009: used 0.13 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi
Thu Jan 8 03:53:35 2009: used 0.01 seconds of cpu time for HTTP Request: http://www.zerocarbage.com : GET /showthread.php?tid=132&pid=1537 HTTP/1.0
Thu Jan 8 03:53:28 2009: used 0.02 seconds of cpu time for /ramdisk/bin/fcgiphp5 - zeroingi

This is an example of one of the 15 MySQL Slow Queries for today:

# Fri Jan 9 00:22:48 2009
# Query_time: 2 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
use zeroingi_dbzero;
SELECT f.style, f.overridestyle, p.*
FROM mybb_forums f
LEFT JOIN mybb_posts p ON(f.fid=p.fid)
WHERE p.pid='20882'
LIMIT 1

# Fri Jan 9 00:22:55 2009
# Query_time: 7 Lock_time: 0 Rows_sent: 1 Rows_examined: 72
use zeroingi_dbzero;
SELECT COUNT(p.pid) AS count FROM mybb_posts p
WHERE p.tid='635'
AND p.pid <= '20882'
AND p.visible='1'

# Fri Jan 9 00:32:14 2009
# Query_time: 2 Lock_time: 0 Rows_sent: 1 Rows_examined: 349
use zeroingi_dbzero;
SELECT COUNT(p.pid) AS count FROM mybb_posts p
WHERE p.tid='8'
AND p.pid <= '18552'
AND p.visible='1'

# Fri Jan 9 00:41:40 2009
# Query_time: 3 Lock_time: 0 Rows_sent: 10 Rows_examined: 42
use zeroingi_dbzero;
SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
FROM mybb_posts p
LEFT JOIN mybb_users u ON (u.uid=p.uid)
LEFT JOIN mybb_userfields f ON (f.ufid=u.uid)
LEFT JOIN mybb_users eu ON (eu.uid=p.edituid)
WHERE pid IN('24681','24683','24688','24699','24700','24702','24709','24710','24718','24720')
ORDER BY p.dateline
A query time of 2 is too low. See if you can raise that to maybe 5 seconds. In which case you would get only one of those as a long query.

The 7 second query should NOT have taken that long and imho it's your shared hosting environment problem. My long queries are almost always associated with search as I have a 300mb database with 350k posts.

I still don't think you have too much to worry about unless your hosts complains in which case they suck and you should move.
How do I raise the query time to 5 seconds? Is that a setting that I can manipulate? I thought perhaps that was set by the host. I get these reports in my tmp directory.
Contact your host. Really it's going to depend on how they host your sites.