@david ah, ok, I’ve got a consistent way to overload the server now. It definitely seems to have something to do with saving the invoice, and specifically, snappdf. I watched htop the whole time as well.
As a test, I went to Clients, and then clicked the Edit circle with pencil icon on a client, and then saved. I did this for the top 10 clients in the list. So, edit, save, edit, save, edit, save, etc. for 10 clients. No problem. I watched htop, and server resources were calm the whole time. All good.
Then, I moved onto Products. I did the same thing, edit, save, edit, save, for 10 products. All good as well.
I moved onto Payments, doing the same thing, and again, no problem.
Finally, I returned to Invoices. I clicked to edit the first invoice, and it saved successfully, but as I watched htop in my SSH session, resources were starting to skyrocket. I clicked edit on another invoice, hit save, and unresponsive. It came back after about 45 seconds or so. I clicked save again, unresponsive.
Here’s htop’s system stats when I simply refresh Invoice Ninja. It’s a bit clunky, but the server handles it easily while loading other websites. Disk usage at 26.8MB/s, not bad. Doing everything above (saving products, clients, payments) was next to zero resources.
But wait for it…now I hit save on an invoice.
Yep, just a casual 18.7GB/s of disk usage for a solid few minutes. Here’s where I think snappdf has something to do with it. Check out that virtual memory.
So, all this to say, is there something I’ve done terribly wrong in my snappdf install, or is this a bug?
PDF generation still works totally fine if I download an invoice, so snappdf seems to be working. But some function of its use seems incredibly unoptimized.
Just to help in the troubleshooting, here’s the exact steps I took in my snappdf install awhile back (from my documentation):
Edit the .env file to change the generator.
$ sudo vi /path/to/invoiceninja/.env
Edited the line:
PDF_GENERATOR=snappdf
then saved and exited.
Invoked the download of snappdf:
$ cd /path/to/invoiceninja
$ sudo -u www-data vendor/bin/snappdf download
Ensured dependencies were installed (for me on Ubuntu 22.04 LTS, I only needed to install fonts-liberation, libappindicator3-1, libasound2, libgbm1, and libxss1).
$ sudo apt-get install fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
Test snappdf:
$ cd /path/to/invoiceninja
$ sudo -u www-data ./vendor/bin/snappdf convert --html "<h1>Hello world</h1>" test.pdf
Finally, re-verified permissions
$ cd /path/to/webroot
$ sudo chown -R www-data:www-data invoiceninja/
$ cd /path/to/invoiceninja
$ sudo -u www-data php artisan optimize