funkwhale/docs/administrator_documentation/configuration_docs/optimize.md

63 wiersze
1.8 KiB
Markdown
Czysty Zwykły widok Historia

2022-07-01 09:02:29 +00:00
# Optimize memory usage
Funkwhale has a reasonable memory footprint. If you're running Funkwhale on a limited device, you can use these tweaks to reduce the footprint.
## Reduce workers concurrency
Funkwhale uses Celery to handle asynchronous tasks. By default, Celery spawns a worker per CPU core. This can lead to higher memory usage.
You can set the number of workers using the `CELERYD_CONCURRENCY` variable in your `.env` file. For example, a value of `CELERYD_CONCURRENCY=1` spawns a single worker.
```{note}
Reducing the number of celery workers slows down the handling of asynchronous tasks. On larger instances, this can cause performance problems.
```
## Switch to solo pool execution
Celery uses a `prefork` pool by default. This enables the server to process many tasks at the same time. You can switch to a `solo` pool which handles tasks one at a time. This reduces memory overhead but removes the ability to process tasks concurrently.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
1. Open your `funkwhale-worker` unit file in an editor.
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-23 13:32:35 +00:00
sudo nano /etc/systemd/system/funkwhale-worker.service
```
2022-07-01 09:02:29 +00:00
2. Add the `--pool=solo` flag to the `ExecStart` line of your unit file.
2022-10-26 20:19:16 +00:00
```{code-block} text
2022-07-23 13:32:35 +00:00
ExecStart=/srv/funkwhale/.local/bin/poetry run celery -A --pool=solo funkwhale_api.taskapp worker -l INFO --concurrency=${CELERYD_CONCURRENCY}
```
2022-07-01 09:02:29 +00:00
3. Restart the Celery service.
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-23 13:32:35 +00:00
sudo systemctl restart funkwhale-worker.service
```
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
1. Add the `--pool=solo` flag to the `celerybeat` command in `docker-compose.yml`.
2022-10-26 20:19:16 +00:00
```{code-block} yaml
2022-07-23 13:32:35 +00:00
celerybeat:
command: celery -A --pool=solo funkwhale_api.taskapp beat --pidfile= -l INFO
```
2022-07-01 09:02:29 +00:00
2. Restart Celery.
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-23 13:32:35 +00:00
docker-compose restart celerybeat
```
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::
::::