Advertisement:

Author Topic: Caching  (Read 9695 times)

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Caching
« on: September 20, 2005, 05:27:34 PM »
Optimization is all about trade offs.  If you use more memory, you might end up using enough less CPU for the memory to be worth it.  If you use less memory, you might end up copying stuff around enough for it to be worth the extra CPU.

Things like eAccelerator are examples of this.  In this case, you trade memory (the cached bytecode) for CPU and *more* memory (because it takes both for PHP to compile anyway) which usually results in a net gain everywhere.  Results on your server may vary.  What is eAccelerator?

Caching is another example.  SMF 1.1 Beta 3 and above all have caching features.  These features can use, as of this writing, any of:
  - APC.
  - eAccelerator.
  - memcached (not well tested.)
  - Truck MMCache.
  - Zend Platform/Performance Suite (NOT Zend Optimizer.)

If you use any of the above software, you can enable caching support with this query:

REPLACE INTO smf_settings
   (variable, value)
VALUES ('cache_enable', '1');

What is phpMyAdmin?  Typically, this will reduce query usage per page slightly, but it will vary depending on the page.

For memcached, you also have to run:

REPLACE INTO smf_settings
   (variable, value)
VALUES ('cache_memcached', 'server1,server2,server3:port,server4');

If no port is specified for a server, 11211 is used.  SMF will try to connect to up to 3 (or less, if there are less than 3) servers in that list, using rough/random load balancing.  It will not do any caching if it cannot connect to any of the listed memcached servers.

Furthermore, there are other caching levels.  If you are using a beta version of SMF 1.1, it is strongly recommended that you do not use a level other than 1.  Before RC1, some of the other levels were unstable/broken.

Other available levels are 2, and 3.  3 is usually where the additional memory usage is worse than the saved CPU time, but 2 has been shown to be a benefit.  Any performance benchmarks (over long periods) on which levels (including 0, off) worked best would be most appreciated at this point.

To change your level to 2, use:

REPLACE INTO smf_settings
   (variable, value)
VALUES ('cache_enable', '2');

-[Unknown]