Start free trial
Start free trial Log in

14-day free trial. No credit card.

Monitoring Laravel Livewire

How to find the slow component behind a chatty Livewire page, and the latency targets that keep interactions feeling instant.

  • Guide
  • 3 min read

How do I monitor Laravel Livewire components?

Every Livewire interaction is a POST to /livewire/update (/livewire-{hash}/update in Livewire 4), and a Livewire-heavy page fires 10-50 of these per user-minute. Standard APMs treat each as a separate request, flooding dashboards. Group by component class (extracted from the payload), target under 100ms p95 for simple actions and 300ms for complex ones, and watch for N+1 queries inside render() since it fires on every interaction. NightOwl records every Livewire update under that one route, and each request's timeline shows the component and the queries it ran.

Updated

Livewire is deceptively chatty. The same page that feels like one screen to a user is, on the backend, a stream of POST requests: one per keystroke, click, and validation. That changes what monitoring has to do: the question stops being "is this route slow" (every interaction hits the same route) and becomes "which component is slow, and how often is the user actually waiting on it." A standard request dashboard answers the first question and buries the second.

Why Livewire needs its own monitoring lens

Every user interaction (typing in a search box, clicking a checkbox, validating a field) is a POST to /livewire/update (/livewire-{hash}/update in Livewire 4). A moderately interactive Livewire page can generate 10-50 backend requests per user-minute. That makes two things matter more than usual:

  • Per-component aggregation: per-route grouping is useless because every request hits the same route. You care which component is slow.
  • Latency targets: users expect UI to feel reactive. A checkbox toggle that takes 300ms feels laggy; a full page load at 300ms feels fine.

Finding slow components

Your APM sees every Livewire interaction as a POST to the same update endpoint. To find the slow ones, parse the request payload, which includes the component name:

Livewire 3 request shape (simplified)

json
{
  "components": [
    {
      "snapshot": "{\"data\":{...},\"memo\":{\"id\":\"abc123\",\"name\":\"products.filter-panel\",...},\"checksum\":\"...\"}",
      "updates": { ... },
      "calls": [{ "method": "updateFilter", "params": [...] }]
    }
  ]
}

Decode components[].snapshot (it's a JSON string) and read memo.name. That's the component's alias (products.filter-panel for App\Livewire\Products\FilterPanel), the value you want to group on.

Common Livewire performance bugs

N+1 inside render()

php
// Bad: render() fires on every interaction, each one refetches posts
public function render()
{
    return view('component', [
        'users' => User::all(),  // 1 query
        // Users->posts in template fires N queries per render
    ]);
}

// Good: eager-load
public function render()
{
    return view('component', [
        'users' => User::with('posts')->get(),
    ]);
}

Unbounded real-time search

php
// Bad: wire:model.live sends a request as the user types,
// with only a 150ms default debounce between them.
public $search = '';
// <input wire:model.live="search">

// Good: debounce, wait for pause
// In Blade:
// <input wire:model.live.debounce.300ms="search">

// Better: only update on blur for expensive filters
// <input wire:model.blur="search">

Computed properties without caching

php
// Bad: recomputes on every update request
public function getCartTotalProperty()
{
    return $this->cart->items->sum('price'); // hits DB each time
}

// Good: memoize per component instance across requests.
// (cache: true would share one value across every user.)
// Call unset($this->cartTotal) after the cart changes.
use Livewire\Attributes\Computed;

#[Computed(persist: true, seconds: 5)]
public function cartTotal()
{
    return $this->cart->items->sum('price');
}

Latency targets

Interaction p95 target Feels laggy above
Toggle / checkbox< 100ms200ms
Form validation< 150ms300ms
Filter / search< 300ms500ms
Submit / save< 500ms1000ms

For interactions you can't get below 200ms, use wire:loading indicators. A visible spinner or disabled state masks the latency.

Instrumenting lifecycle events

app/Providers/AppServiceProvider.php

php
use Livewire\Livewire;

public function boot(): void
{
    // Livewire 3 lifecycle events
    Livewire::listen('mount', function ($component, $params) {
        logger()->info('Livewire mount', [
            'component' => $component::class,
            'params' => array_keys($params),
        ]);
    });

    Livewire::listen('hydrate', function ($component) {
        // Runs on every update request: attach timing info, user context, etc.
    });
}

Find your slowest Livewire interactions

NightOwl records every Livewire update under its one update route. Filter that route to requests at or above P95 and open one: its timeline names the component and groups repeated queries on its Duplicates tab.

No credit card needed.

Terminal
composer require nightowl/agent
php artisan nightowl:install
php artisan nightowl:agent

Frequently asked questions

Anything else, write to support@usenightowl.com

Why is Livewire monitoring different from regular Laravel requests?

Livewire components communicate via AJAX POSTs to /livewire/update (Livewire 3) or /livewire-{hash}/update (Livewire 4). Every user interaction (a button click, input change, validation) is a round-trip to your server. A Livewire-heavy page can fire 10-50 requests per user-minute. Standard APMs treat each as a separate request, which floods dashboards with low-signal data. You want per-component aggregation, not per-request.

Can NightOwl group Livewire requests by component?

Not as a separate view. NightOwl groups every Livewire update under the one update route, so that route's charts and percentiles cover all your components together. Each request records the component classes it hydrated, so when you open a slow request, its timeline shows which component it was for and the queries it ran.

How do I find slow Livewire components?

Filter your APM to POST requests against the Livewire update endpoint, then group by the component name in the payload. Look at p95 per component. Common slow components: real-time search (firing on every keystroke), filter panels (re-querying the full table), dashboards (multiple DB-heavy computed properties). Switch to on-blur or debounced updates where appropriate.

Does Livewire fire N+1 queries more than regular controllers?

Not inherently, but its reactive model hides them. A component's render() method fires on every interaction. If it lazy-loads a relationship inside the template, you're firing N+1 queries on every button click. Use computed properties with caching or pre-load relationships in mount() / boot().

How do I monitor Livewire lifecycle events?

Components have lifecycle hooks (mount(), hydrate(), updated(), render()), and Livewire 3 fires matching global events you can listen to from a service provider: Livewire::listen('mount', fn ($component, $params) => ...) or Livewire::listen('hydrate', fn ($component) => ...). Log the component class with context so your log aggregator can group on it.

What's the p95 target for a Livewire action?

Tighter than traditional requests because users expect immediate feedback. Under 100ms p95 for simple actions (toggle a checkbox); under 300ms for complex ones (filter update that re-queries). Above 500ms feels laggy. Use wire:loading indicators to mask any action you can't get below 200ms.

Does Livewire 3 change monitoring compared to Livewire 2?

Yes. Livewire 2 posted each component to /livewire/message/{name}, so the URL named the component. Livewire 3 moved every component to a single /livewire/update endpoint, and Livewire 4 adds a hash prefix (/livewire-{hash}/update). Grouping by URL no longer tells components apart; you need the payload or a lifecycle hook to get component context.

Related

Flat pricing, whatever your traffic does

Every plan starts with a 14-day free trial. No credit card needed.

Hobby
$5 a month

One app for a side project. Issues and alerts, with a 14-day dashboard window.

Start my 14-day trial
TeamRecommended
$15 a month

Up to 3 apps and 5 people per team. Full history, the MCP server, data clearing and agent health.

Start my 14-day trial
Agency
$69 a month

Unlimited client apps and people, one overview of every app, and apps you can hand over.

Start my 14-day trial