Performance tips

beta990 edited this page Jun 18, 2015 · 2 revisions

Performance tips and tricks

Spotweb is thought to be optimized for most situations you can use Spotweb with. However, there are always some tricks to make Spotweb perform even faster. Depending on your workload (eg: a private system or a public system) and your actual hardware these tips might help to optimize Spotweb.

Use Nginx instead of Apache

As stated in the Nginx Wiki: 'Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.'

In several benchmarks available on the web, Nginx performance and memory consumption was (far more) better than any other webserver (e.g. Apache, Lighttpd, etc.)

Retrieve full spots

By making Spotweb retrieve the spots in full, Spotweb doesn't have to connect to the usenet server to retrieve the spot in full. It also does not need to validate the RSA signature and it allows for some small additional filtering capabilities. If you are running a larger Spotweb install you should really enable these settings.

Please note that this slows down the retrieval of Spots a lot.

Force caching of our static resources.

Our static files are - as the word says - static. These files do not change, but your browser has to make sure for each page visit that the resources actually did not change.

By forcing caching to 'on' you can make sure your browser does not have to check those resources which speeds up Spotweb a lot. An example of how to force caching of these resources (if you are running Apache) is to add the following lines to your .htaccess file:

ExpiresActive On
ExpiresDefault "access plus 4 hours"
ExpiresByType application/javascript A900
ExpiresByType application/x-javascript A900
ExpiresByType text/javascript A900
ExpiresByType text/html A90
ExpiresByType text/xml A90
ExpiresByType text/css A900
ExpiresByType text/plain A62
ExpiresByType image/gif A14400
ExpiresByType image/jpg A14400
ExpiresByType image/jpeg A14400
ExpiresByType image/png A14400
ExpiresByType image/bmp A14400
ExpiresByType application/x-shockwave-flash A3600

Please note that a user probably needs to press Ctrl+F5 to see any layout changes if you would change the templates.

Turn on gzip / compression of pages

This tip is only useful if you are running Spotweb somewhere else than your LAN.

The index page of Spotweb is a rather large HTML page with a lot of repeating content, ideal for compressing these pages by your web server. Apache has the ability to compress your pages before they are sent to your web browser so your network usage decreases and your speed increases. For Apache the following lines added to your .htaccess file will enable compression:

# mod_deflate configuration
<IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript

        DeflateCompressionLevel 9

        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Don't forget to enable the "mod_deflate" module in your Apache configuration.

Note - DeflateCompressionLevel can only be set at the server level level in httpd.conf not in .htaccess

Use a PHP accelerator

Install APC (, eAccelerator ( or XCache ( as a PHP opcode cache.

An average Spotweb page consists of an rather large number of different PHP files, these files are compiled by PHP on each page view. By adding an PHP opcode cache you skip the compilation part which turns into a rather large performance win.

Synology users can enable (the standard installed) eAccelerator module by checking the box at Enable PHP Cache. You can find this option by navigating to DSM -> Control Panel -> Web Services -> PHP Settings.

Tune your MySQL

A complete Spotweb database with 'full spots' retrieval enabled, can use a rather large amount of disk space. The more memory you have, the faster your database will be able to respond to queries.

If you are using MySQL, also please enable the usage of separate innodb files per table.

To enable innodb files per table, add this to your my.cnf file:

innodb_file_per_table = 1

Then restart MySQL. Note: this change would only apply to databases created after the config file change. If you created your Spotweb database before changing the config file, you need to issue some alter table commands. To find out which tables and get the SQL commands you need:

SELECT concat('alter table ', TABLE_SCHEMA, '.', table_name, ' ENGINE=InnoDB;')
FROM   information_schema.tables
WHERE  table_type = 'BASE TABLE'
AND engine = 'InnoDB'

You should get something like:

alter table spotweb.cache ENGINE=InnoDB;
alter table spotweb.commentsfull ENGINE=InnoDB;
alter table spotweb.commentsposted ENGINE=InnoDB;
alter table spotweb.commentsxover ENGINE=InnoDB;
alter table spotweb.filtercounts ENGINE=InnoDB;
alter table spotweb.filters ENGINE=InnoDB;
alter table spotweb.grouppermissions ENGINE=InnoDB;
alter table spotweb.nntp ENGINE=InnoDB;
alter table spotweb.notifications ENGINE=InnoDB;
alter table spotweb.permaudit ENGINE=InnoDB;
alter table spotweb.reportsposted ENGINE=InnoDB;
alter table spotweb.reportsxover ENGINE=InnoDB;
alter table spotweb.securitygroups ENGINE=InnoDB;
alter table spotweb.settings ENGINE=InnoDB;
alter table spotweb.spotsfull ENGINE=InnoDB;
alter table spotweb.spotsposted ENGINE=InnoDB;
alter table spotweb.spotstatelist ENGINE=InnoDB;
alter table spotweb.spotteridblacklist ENGINE=InnoDB;
alter table spotweb.usergroups ENGINE=InnoDB;
alter table spotweb.users ENGINE=InnoDB;
alter table spotweb.usersettings ENGINE=InnoDB;
alter table test.auth_group ENGINE=InnoDB;
alter table test.auth_group_permissions ENGINE=InnoDB;
alter table test.auth_permission ENGINE=InnoDB;
alter table test.auth_user ENGINE=InnoDB;
alter table test.auth_user_groups ENGINE=InnoDB;
alter table test.auth_user_user_permissions ENGINE=InnoDB;
alter table test.django_content_type ENGINE=InnoDB;
alter table test.django_session ENGINE=InnoDB;
alter table test.django_site ENGINE=InnoDB;
alter table test.polls_choice ENGINE=InnoDB;
alter table test.polls_poll ENGINE=InnoDB;

Execute those commands and you'll get one .idb file per table in your $datadir/spotweb folder. It may take a little time to convert.

Running a query like OPTIMIZE TABLE `commentsxover` , `spotstatelist` , `nntp` , `spots` , `spotsfull`; also makes the database a bit faster.