<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
    <channel>
        <title>نوشته های محمد روشندل پور Mohammad Roshandelpoor</title>
        <link>https://virgool.io/feed/@roshandelpoor</link>
        <description>مهندس نرم افزار - رزومه linkedin: roshandelpoor</description>
        <language>fa</language>
        <pubDate>2026-04-15 01:22:32</pubDate>
        <image>
            <url>https://files.virgool.io/upload/users/19488/avatar/7Ruc2b.jpg?height=120&amp;width=120</url>
            <title>محمد روشندل پور Mohammad Roshandelpoor</title>
            <link>https://virgool.io/@roshandelpoor</link>
        </image>

                    <item>
                <title>Laravel Pulse: Monitoring in Production</title>
                <link>https://virgool.io/@roshandelpoor/laravel-pulse-monitoring-in-production-txuivto9edqe</link>
                <description>Laravel Pulse boasts an array of features that make it an indispensable tool for Laravel developers:System Statistics Monitoring: Pulse tracks CPU usage, memory consumption, and storage utilization, providing a comprehensive overview of server resources.Application Usage Insights: The tool offers detailed information about user requests, slow routes, and job dispatches, helping developers understand how their application is being utilized.Queue Performance Tracking: Pulse monitors queue throughput, allowing developers to optimize their job processing systems.Slow Query Detection: The tool identifies and logs slow database queries, enabling developers to pinpoint and resolve performance bottlenecks.Exception Tracking: Pulse provides an overview of exceptions occurring within the application, helping developers quickly identify and address issues.Cache Performance Monitoring: The tool tracks cache hits and misses, allowing developers to optimize their caching strategies.Installing and Configuring Laravel PulseSetting up Laravel Pulse in your application is a straightforward process that involves a few simple steps. Let’s walk through the installation and configuration process to get you started with this powerful monitoring tool.PrerequisitesBefore installing Laravel Pulse, ensure that your Laravel application meets the following requirements:Laravel version 8.0 or higherPHP 7.4 or higherComposer package managerStep-by-Step Installation GuideInstall Laravel Pulse via Composer:composer require laravel/pulsePublish the Pulse configuration and migration files:php artisan vendor:publish --provider=&amp;quotLaravel\Pulse\PulseServiceProvider&amp;quotRun the database migrations:php artisan migrate(Optional) Publish the Pulse dashboard view:php artisan vendor:publish --tag=pulse-dashboardEnable it (run) Or add to supervisorphp artisan pulse:check

Or

[program:pulse-worker]
command=php /var/www/html/artisan pulse:check
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_events_enabled=true
stderr_events_enabled=true
user=www-data(Optional) Clear Data after 1 week$schedule-&gt;command(&#039;pulse:clear --type=system --force&#039;)
         -&gt;weeklyOn(5, &#039;4:00&#039;);Configuring Laravel PulseAfter installation, you can customize Laravel Pulse by modifying the config/pulse.php file. This configuration file allows you to:Enable or disable specific monitoring featuresSet thresholds for slow queries and requestsConfigure sampling rates for high-traffic applicationsCustomize the dashboard layoutHere’s an example of how you might configure the slow query threshold:&#039;slow-queries&#039; =&gt; [
    &#039;enabled&#039; =&gt; true,
    &#039;threshold&#039; =&gt; 100, // milliseconds
],Setting Up Authentication for the Pulse DashboardBy default, the Pulse dashboard is only accessible in the local environment. To secure access in production, you can define a gate in your AppServiceProvider:use Illuminate\Support\Facades\Gate;

public function boot()
{
    Gate::define(&#039;viewPulse&#039;, function ($user) {
        return $user-&gt;isAdmin();
    });
}Dashboard Layout and ComponentsThe Pulse dashboard is divided into several sections, each focusing on a specific aspect of your application:Server Statistics: Displays CPU, memory, and disk usage for your application server.Application Usage: Shows the most active users and their interactions with your application.Queue Monitoring: Provides insights into job processing and queue performance.Slow Queries: Lists database queries that exceed the configured threshold.Exceptions: Displays recent exceptions and their frequency.Cache Performance: Shows cache hit rates and most frequently accessed keys.Interpreting Dashboard MetricsUnderstanding the metrics displayed on the Pulse dashboard is crucial for effective monitoring. Here’s a brief overview of how to interpret some key metrics:Server Load: A consistently high CPU or memory usage may indicate the need for server scaling or code optimization.Slow Queries: Frequent slow queries suggest areas where database optimization or indexing might be necessary.Exception Frequency: A sudden spike in exceptions could signal a critical issue that requires immediate attention.Cache Hit Rate: A low cache hit rate might indicate opportunities for improving your caching strategy.Customizing Laravel Pulse for Your ApplicationWhile Laravel Pulse provides a wealth of useful metrics out of the box, you may have specific monitoring needs unique to your application. Fortunately, Pulse is highly customizable, allowing you to tailor it to your exact requirements.Creating Custom RecordersRecorders are the components responsible for collecting and storing metrics in Pulse. You can create custom recorders to track application-specific metrics:Create a new class that extends Laravel\Pulse\Recorders\RecorderImplement the record() method to define how your metric should be recordedRegister your custom recorder in the pulse.php configuration fileHere’s a simple example of a custom recorder that tracks the number of new user registrations:use Laravel\Pulse\Recorders\Recorder;

class UserRegistrationRecorder extends Recorder
{
    public function record(): void
    {
        $this-&gt;record-&gt;count(
          &#039;user_registrations&#039;, 
          User::where(&#039;created_at&#039;, &#039;&gt;=&#039;, now()-&gt;subHour())-&gt;count()
        );
    }
}Implementing Custom Dashboard WidgetsYou can create custom widgets to display your application-specific metrics on the Pulse dashboard:Create a new Livewire component for your widgetDesign the widget’s view to display your custom metricsAdd your widget to the dashboard by including it in the pulse.php configuration fileHere’s an example of a simple custom widget that displays the number of new user registrations:use Livewire\Component;
 use Laravel\Pulse\Facades\Pulse;

class UserRegistrationsWidget extends Component
{
    public function render()
    {
        $count = Pulse::get(&#039;user_registrations&#039;)
                        -&gt;first()-&gt;value ?? 0;

        return view(&#039;pulse.user-registrations&#039;, [&#039;count&#039; =&gt; $count]);
    }
}ConclusionLaravel Pulse is a milestone in application monitoring for Laravel developers. By providing real-time insight into the level of various issues related to application performance, and server statistics down to user behavior can enable developers to drive data-informed decisions when it comes to optimization and resource allocation.It provides seamless integration with the Laravel ecosystem and is very customizable and extensible.By effectively using Laravel Pulse, it ensures applications are performant, stable, and responsive, leading to better user experiences and therefore successful projects. Whether starting a new Laravel application or managing complex ecosystems of applications, Laravel Pulse provides the insight you’ll need to keep your finger on the pulse of your application&#x27;s health and performance.Feel free to Subscribe for more content like this 🔔, clap 👏🏻 , comment 💬, and share the article with anyone you’d likeAnd as it always has been, I appreciate your support, and thanks for reading.Connect with me:LinkedIn: https://www.linkedin.com/in/roshandelpoor/</description>
                <category>محمد روشندل پور Mohammad Roshandelpoor</category>
                <author>محمد روشندل پور Mohammad Roshandelpoor</author>
                <pubDate>Wed, 04 Dec 2024 16:50:23 +0330</pubDate>
            </item>
            </channel>
</rss>