Overview
Monitoring is the heartbeat of any production application. In a serverless environment like Laravel Vapor
, where resources scale dynamically, visibility into performance is critical. This guide explores how to track environment health, database utilization, and queue performance while setting up proactive alerts to catch issues before they impact users.
Prerequisites
To follow this guide, you should have a basic understanding of the Laravel
framework and cloud hosting concepts. An active AWS
account linked to a Laravel Vapor
project is required to access the metrics dashboard and notification settings.
Key Libraries & Tools
Laravel Vapor
: A serverless deployment platform for Laravel
powered by AWS
.
Vapor UI
: A dedicated dashboard package for monitoring queue jobs and failed processes within your application.
AWS Lambda
: The underlying compute service that powers Vapor environments.
Environment Metrics and Alarms
Every environment in Laravel Vapor
provides a Metrics tab that aggregates data from AWS Lambda
. You can monitor HTTP request volume, average request duration, and the estimated cost per function. To prevent surprises, you must configure Notification Methods first. Once a method (like email) is active, you can create alarms. For example, setting an alarm for "more than 10 requests per minute" ensures you are alerted during traffic spikes or potential DDoS attempts.
Monitoring Fixed-Size Resources
Unlike queues, resources like Amazon RDS
databases and Amazon ElastiCache
clusters often have fixed sizes. Monitoring their CPU Utilization is vital. If a database or cache consistently hits near 100% CPU usage, the application will experience significant latency. In these cases, use the Scale button within the Vapor UI to increase server specs or add nodes to your cache cluster.
Syntax Notes and Queue Management
For detailed queue monitoring, you need the Vapor UI
package. Once installed via Composer, it provides a dashboard to track pending and failing jobs. While Laravel Vapor
scales queues automatically, you should focus on the Failed Jobs tab. This interface allows you to inspect the stack trace of a failure and choose to retry or forget the job directly from the browser.
Tips & Gotchas
- Timeframes Matters: Always check if you are viewing the "Last 24 Hours" or a shorter window when debugging a recent incident.
- Alarm Thresholds: Don't set alarms too low for environments with high natural variance, or you'll suffer from "alert fatigue."
- Cost Awareness: Monitoring estimated cost metrics helps you identify inefficient code that may be causing unnecessary
AWS Lambda
execution time.