Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hlipnick's avatar

Painfully Slow Interface with Filament/Livewire in Production

I've been building out v1 of my web app over the last six or seven weeks, hoping to do a small private test launch at the end of the month. The MVP isn't quite finished, but I wanted to start testing on a live server to work out any kinks. The site is build with Filament v3 and I've tried to be diligent about sticking to conventions and writing tests. All my tests pass both in local dev as well as GitHub Actions.

Unfortunately, on the production server I'm seeing simple Livewire requests take 800-1000ms to return (the longest I've seen it take locally with the same data is 150-200ms, usually faster)

It's the first time I've used Forge and Digital Ocean, so it's certainly possible I'm doing something wrong. I'm trying to keep thing cheap at the outset, so I provisioned the $6/mo DO droplet (1 vCPU / 1GB RAM / 25GB Disk). Maybe that's the bottle neck? Is there a specific metric I should look at in order to speed up Livewire? Maybe some config that I'm missing that wouldn't be obvious in local testing?

Thanks for any help!

0 likes
2 replies
LaryAI's avatar
Level 58

It sounds like you're experiencing performance issues with Livewire on your production server. Here are several steps you can take to diagnose and potentially improve the performance:

  1. Server Resources: The $6/mo Digital Ocean droplet is quite small and might not be sufficient for a production environment, especially if you're expecting multiple users. Livewire can be resource-intensive since it makes frequent requests to the server. You might want to consider upgrading to a larger droplet with more CPU and RAM.

  2. Caching: Ensure that you're using Laravel's caching features effectively. This can include route caching, configuration caching, and view caching. For Livewire, you can also look into caching expensive queries or computations.

  3. Optimize Livewire: Livewire offers several features to reduce payload sizes and speed up requests:

    • Use wire:model.defer to batch updates and reduce the number of requests.
    • Use Lazy loading for properties that don't need to be loaded immediately.
    • Use Eager loading for your models to prevent N+1 query issues.
  4. Assets Optimization: Minify your CSS and JavaScript assets. If you're not already using Laravel Mix, it can help you compile and minify your assets.

  5. Network Latency: Check the network latency between your users and the server. If your users are far from your server's location, consider using a CDN or choosing a server location closer to your user base.

  6. Profiling: Use tools like Laravel Debugbar or Telescope to profile your application and find bottlenecks.

  7. Database Optimization: Make sure your database is optimized. This includes using indexes appropriately and optimizing queries.

  8. PHP Version: Ensure you're using the latest stable version of PHP, as each new version typically offers performance improvements.

  9. OPcache: Make sure OPcache is enabled and properly configured on your production server.

  10. Background Processing: If there are any non-critical actions that can be deferred, use Laravel's queue system to handle them in the background.

Here's an example of how you might implement caching for a Livewire component:

use Livewire\Component;
use Illuminate\Support\Facades\Cache;

class SomeComponent extends Component
{
    public $data;

    public function mount()
    {
        $this->data = Cache::remember('some-expensive-call', 3600, function () {
            // Replace this with the actual expensive call
            return SomeModel::expensiveCall();
        });
    }

    public function render()
    {
        return view('livewire.some-component');
    }
}

Remember to clear your caches (php artisan cache:clear) after making changes that could affect cached data.

If after trying these optimizations you're still experiencing slow performance, it might be time to consider a more powerful server or additional optimization strategies specific to your application's needs.

1 like
hlipnick's avatar

Coming back to close the loop on this: I had forgotten to add Filament caching and Laravel optimization to my deploy script (whoops). Now they're in there and the production app is running very responsively.

The specific steps I added to the forge deploy script, for anyone looking in the future:

echo 'Caching icons...';
$FORGE_PHP artisan icons:cache
    
echo 'Caching Filament components...';
$FORGE_PHP artisan filament:cache-components
    
echo 'Running artisan optimize...';
$FORGE_PHP artisan optimize
6 likes

Please or to participate in this conversation.