Compute
Introduction
Each environment deployed to Laravel Cloud runs on at least one App compute instance, which is assigned a specified amount of CPU processing power and available RAM.
Your environment’s App compute instance is responsible for handling incoming HTTP traffic to the environment. In addition, you may add dedicated worker compute instances to your environment to process queued jobs or execute other background processes.
Compute resources assigned to an environment may be managed from the environment’s infrastructure canvas dashboard.
App Compute Cluster
Your environment’s App compute cluster represents the primary compute and infrastructure that will run your Laravel application. This compute cluster can serve web traffic, hibernate, manage long-running processes like queue workers, and even run scheduled tasks.
To scale or customize your environment’s App compute cluster, simply click the cluster in your environment’s infrastructure canvas dashboard.
Laravel Octane
Laravel Cloud makes it easy to run your application using Laravel Octane, which boots your application once and keeps it in memory for each request.
When editing your App compute cluster, simply toggle on the “Use Octane as runtime” option. Then, save and deploy your environment and Laravel Cloud will build, configure, and serve your Laravel application using Laravel Octane and FrankenPHP.
Please review the Laravel Octane documentation to learn about the caveats you should keep in mind when building your application to run on Octane.
Before enabling the Laravel Octane runtime, make sure Laravel Octane has been added to your application via the Composer package manager.
Worker Clusters
Worker clusters are optional compute resources that can be added to your environment. They are a mirror copy of your environment’s App compute in the sense that they use the same repository, branch, PHP version, environment variables, deployment commands, database, and other resources. However, each Worker cluster can be independently sized and can run a custom set of queue workers or custom background processes.
Dedicated worker clusters can be useful for larger applications where you want to use the primary App cluster to serve web traffic, but send background workloads to separate compute resources.
To add a worker cluster to an environment, click “Add worker cluster” on the environment’s infrastructure canvas dashboard.
Workers do not serve web traffic. If your application needs more HTTP throughput capacity, modify your environment’s App compute cluster’s size, replica count, or autoscaling settings and re-deploy your application.
Autoscaling
Laravel Cloud can automatically scale the compute resources attached to your environment based on the CPU and memory being used by the environment. To configure your environment’s autoscaling strategy, click on your environment’s App or Worker compute cluster on the infrastructure canvas dashboard, and select the autoscaling strategy that is appropriate for your environment.
For maximum flexibility, Laravel Cloud currently supports three different autoscaling strategies:
- None: run your App / Worker compute on a single instance without autoscaling.
- Custom: automatically scale your App/ Worker compute clusters up and down horizontally within a specified minimum and maximum replica range.
- Unlimited: automatically scale your App / Worker compute clusters up and down indefinitely based on demand.
After adjusting your environment’s autoscaling strategy, re-deploy the environment in order for the changes to take effect.
Compute Classes
Laravel Cloud applications run on the latest generation of AWS Graviton EC2 servers with an optimized cost to performance ratio, allowing us to pass on best-in-class compute performance and pricing.
Laravel Cloud offers two classes of compute:
Flex
Lightweight and cost efficient. Perfect for dev environments or applications that need the flexibility to support periodic traffic bursts.
Pro
Larger compute sizes designed for sustained, heavy utilization. Best for large scale, mission critical production applications.
Within each class, there are multiple sizes of CPU and RAM available. Prices vary by region.
This region is powered by the latest AWS Graviton4 processors
CPU(s) | RAM | Price / hour | Price / month |
---|---|---|---|
1 flex | 256MB | $0.0067 | $4.89 |
512MB | $0.0088 | $6.42 | |
1GB | $0.0139 | $10.15 | |
2 flex | 512MB | $0.0134 | $9.78 |
1GB | $0.0176 | $12.85 | |
2GB | $0.0278 | $20.29 | |
4 flex | 1GB | $0.0268 | $19.56 |
2GB | $0.0352 | $25.70 | |
4GB | $0.0556 | $40.59 | |
8 flex | 2GB | $0.0536 | $39.13 |
4GB | $0.0704 | $51.39 | |
8GB | $0.1112 | $81.18 | |
1 pro | 1GB | $0.0267 | $19.49 |
2GB | $0.0352 | $25.70 | |
4GB | $0.0556 | $40.59 | |
2 pro | 2GB | $0.0534 | $38.98 |
4GB | $0.0704 | $51.39 | |
8GB | $0.1112 | $81.18 | |
4 pro | 4GB | $0.1068 | $77.96 |
8GB | $0.1408 | $102.78 | |
16GB | $0.2224 | $162.35 | |
8 pro | 8GB | $0.2136 | $155.93 |
16GB | $0.2816 | $205.57 | |
32GB | $0.4448 | $324.70 |
Compute Metrics
Your environment’s compute metrics may be viewed by navigating to the “Metrics” tab of your environment. When graphed, your environment’s App and Worker clusters CPU and memory usage will be averaged across all replicas.
Hibernation
Your environment is able to hibernate if no requests are received within the specified time limit. Environments that enter a “hibernating” state will not be charged for compute until they are “woken up” again.
Hibernating environments will typically take 5-20 seconds to wake up, which will happen automatically when the environment receives a new HTTP request.
You can enable hibernation by clicking on your environment’s App compute cluster on the infrastructure canvas dashboard, enabling the Hibernation toggle, saving the compute cluster settings, and re-deploying the environment.
Hibernation, Scheduling, and Workers
When an environment has hibernation enabled and is hibernating, scheduled tasks will not be executed on the cluster. In addition, queue workers and custom background processes will not execute. These tasks will resume automatically if the environment is woken up.
Limitations
- Only Flex compute sizes are able to hibernate
- Hibernation takes place at the environment level. When an environment goes into hibernation, ALL compute clusters in the environment will hibernate. This includes worker clusters.
Was this page helpful?