Encountering poor performance in production after a number of troubleshooting steps

Hello all, I nearly have an MVP set up for my application but I think the performance of it is going to be an issue. Each page in the application takes roughly 1.5 seconds to load, with the vast majority of that time being server response time (roundtrips to and from the server and SSL negotiation are around 100ms). I have configured Clockwork on my server and when I have it enabled to see where the bottlenecks lay, it shows roughly 100ms in database queries and the rest as "controller". If I try to enable xdebug to try and get more details it doesn't work so I have skipped that for now. A few notes on my setup: - My app is hosted using php-fpm (version 8.3.9). My web server is Caddy. - My database is on another server in the same region, but database time seems to be relatively low. - I have enabled opcache, and it seems to be working. - When deploying the app, the following commands are run in order:
php artisan optimize
php artisan icons:cache
php artisan filament:cache-components
sudo /usr/bin/systemctl restart horizon
sudo /usr/bin/systemctl restart php8.3-fpm
php artisan optimize
php artisan icons:cache
php artisan filament:cache-components
sudo /usr/bin/systemctl restart horizon
sudo /usr/bin/systemctl restart php8.3-fpm
I saw that a lot of permission checks are performed so I tried to make those faster. I think it's important to note that this is not on pages that have a ton of records on them. Generally, I'm testing on pages with an empty table. I'm relatively new to PHP and since Filament is such a large codebase I'm trying to find my way around to determine how best to improve the performance but I'm a bit stuck. Any pointers would be greatly appreciated!
6 Replies
mylanconnolly
mylanconnollyOP4mo ago
interestingly, I was able to trim another 200ms off the response times by moving from a Google n2d-standard-2 to a t2d-standard-2. I started checking out the different instance types since it seems like the performance issues are only in production (locally I have a 13" M1 Macbook Pro, which is seemingly faster than the VMs). I think performance is starting to become acceptable but I'd still like to get a bit more of a boost if possible
Ron
Ron4mo ago
I deploy to Laravel Vapor and see similar differences between my Mac Studio (Apple M2 Max Chip, 32GB). To be able to analyze this a little better, tonight I deployed the filament demo app to laravel vapor to compare performance to the two production apps (demo.filamentphp.com). The vapor deployment is similar in performance (roughly 350ms - 800ms load times). I was able to correct a couple things with Laravel Vapor to improve the network throughput but not the overall PHP load time. Turns out with Vapor at least that assets loaded from the root domain aren't cached. So I had to publish the livewire assets to get the livewire.min.js to cache. Next, I had to enable content encoding at the AWS API Gateway for compression which resulted in 70-80% compression the response html. I plan to deploy this to forge and compare performance across a couple AWS instance types. I did deploy the demo app to forge with opcache, all performance optimizations, and saw similar results as Laravel Vapor. I ran an AWS t4g-large instance with on-box mySQL. Forge has an opcache button to enable at the server level and default gzip compression. Not seeing a cost-effective deployment solution to get to the 250ms load times seen on my dev system.
zydnrbrn
zydnrbrn4mo ago
have you try using octane?
Lara Zeus
Lara Zeus4mo ago
did you? did you notice any changes? I try to make it work but I am still getting the same response time.
zydnrbrn
zydnrbrn4mo ago
In other projects yes, but im not have been try with filament projects, but it worth to try
mylanconnolly
mylanconnollyOP4mo ago
Hey all, sorry for the lack of replies, I've been busy on other projects. All of my assets are properly caching, which did take some time (I haven't configured a web server in a while and it wasu first time working with Caddy). I haven't tried octane yet because I'm not super experienced with PHP but I'll look into it and see what I can do.
Want results from more Discord servers?
Add your server