-
Notifications
You must be signed in to change notification settings - Fork 110
Optimization
This guide will hopefully allow you to optimize the underlying stack in order to improve Uguu's performance and ability to scale. This page in a work in progress and not finished.
For the meantime this only covers the following setup:
- Debian 11 or later.
- PHP 8.3.
- PostgreSQL.
- Nginx (using PHP-FPM).
Running your OS and database on SSD/NVME drives and storing all uploaded files on separate drives will allow for more efficient caching and lookup times.
In order to force Debian to cache as much as possible in RAM rather then swap, add the following to to end of sysctl.conf
.
/etc/sysctl.conf
vm.swappiness = 0
Then run the following command to apply it live, otherwise it will be applied after a reboot.
sudo sysctl -p
If the package php8.3-xdebug
is installed, make sure it's disabled.
/etc/php/8.3/fpm/conf.d/20-xdebug.ini
;zend_extension=xdebug.so
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.profiler_enable=0
xdebug.mode=off
Make sure the package php8.3-opcache
is installed, this will allow PHP to compile and cache Uguu's code much faster.
Depending on the amount of RAM you have available you might need to tweak opcache.jit_buffer_size=512M
and opcache.memory_consumption=256
.
/etc/php/8.3/fpm/conf.d/10-opcache.ini
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=512M
opcache.jit=1235
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=10000
opcache.memory_consumption=256
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=64
opcache.fast_shutdown=1
Work in progress.
Make sure the indexes are created, this greatly improves performance when performing filename generation, antidupe, blacklist or rate-limit checks against the database, especially on big databases.
CREATE INDEX files_hash_idx ON files (hash);
CREATE INDEX files_name_idx ON files (filename);
CREATE INDEX ratelimit_iphash_idx ON ratelimit (iphash);
CREATE INDEX blacklist_hash_idx ON blacklist (hash);
Use PGTune to generate a tuned configuration.
PgHero is a great tool to get a quick overview of your PG's performance.
Work in progress.