Introduction

Laravel Cloud allows you to create MySQL and Serverless Postgres databases and attach them to your application’s environments directly from the Laravel Cloud dashboard.

Laravel Serverless Postgres

Powered by Neon

Laravel Serverless Postgres provides a full-managed, autoscaling and serverless Postgres database for your application. Serverless Postgres databases autoscale their compute resources and storage to automatically accommodate the demand from your application.

To attach a Serverless Postgres database to an environment, click “Add database” on your environment’s infrastructure canvas dashboard. When adding a database to an environment, Laravel Cloud will prompt you to select the database you would like to attach to the environment or to create a new database cluster. When creating a new cluster, select “Laravel Serverless Postgres” as your database cluster type.

To attach a Serverless Postgres database to an environment, click “Add database” on your environment’s infrastructure canvas dashboard. When adding a database to an environment, Laravel Cloud will prompt you to select the database you would like to attach to the environment or to create a new database cluster. When creating a new cluster, select “Laravel Serverless Postgres” as your database cluster type.

Once the database has been attached to an environment, you will need to re-deploy the environment in order for the changes to take effect.

Compute Units

When creating a Laravel Serverless Postgres database cluster, you may configure the range of “compute units” your cluster should scale between based on demand. Compute units correspond to the following vCPU / RAM configurations:

Compute UnitsvCPUsRAM
.25.251 GB
.5.52 GB
114 GB
228 GB
228 GB
3312 GB
4416 GB

Connection Pooler

Laravel Serverless Postgres offers connection pooling via pgbouncer, enabling up to 10,000 concurrent connections to your cluster.

To connect to the pgbouncer endpoint of your database cluster, append -pooler to the first segment of the cluster’s host name. For example, if your database cluster’s host name is ep-frosty-shadow-a57j6ubb.us-east-2.pg.laravel.cloud, the corresponding pgbouncer endpoint is ep-frosty-shadow-a57j6ubb-pooler.us-east-2.pg.laravel.cloud.

Then, add the new host name as the DB_HOST environment variable in your environment’s General Settings:

DB_HOST="frosty-shadow-a57j6ubb-pooler.us-east-2.pg.laravel.cloud"

Hibernation

Laravel Serverless Postgres databases may be configured to automatically hibernate after not receiving any incoming database queries for a given number of seconds. When a Serverless Postgres database is hibernating, you will not be billed for its compute resources.

If the database receives an incoming query while it is hibernating, the database will automatically wake up within a few hundred milliseconds.

Autoscaling Compute

Serverless compute can autoscale up and down based on your database cluster’s utilization. Set a minimum and maximum range and only pay for the compute resources you actually need.

Laravel MySQL

Laravel MySQL is currently in developer preview. It is currently only recommended for use in non-production environments. Learn more below.

Laravel MySQL provides a fully-managed MySQL database for your application. Laravel MySQL databases are assigned a fixed compute and storage size, but can be scaled at any time. Laravel MySQL databases do not currently support hibernation.

To attach a Laravel MySQL database to an environment, click “Add database” on your environment’s infrastructure canvas dashboard. When adding a database to an environment, Laravel Cloud will prompt you to select the database you would like to attach to the environment or to create a new database cluster. When creating a new cluster, select “Laravel MySQL” as your database cluster type.

Once the database has been attached to an environment, you will need to re-deploy the environment in order for the changes to take effect.

Visit the pricing docs for information on compute and storage prices by region.

MySQL databases can only be attached to compute clusters in the same region.

Developer Preview

Laravel MySQL databases are currently available as a developer preview and will be tagged as generally available in the coming weeks. Below is an up-to-date list of Laravel MySQL’s current capabilities and what is coming soon. You can also check our Changelog for updates.

What’s currently available

Provisioning MySQL databases in all regions

Edit cluster to increase storage capacity

Edit cluster to increase or decrease instance size

Connect to your database externally

Backup snapshots taken every 24 hours and stored for 7 days

Point-in-time recovery logs are being continuously backed up and stored for 7 days

What’s in development for GA

Download a snapshot

Take a manual snapshot

Create a new cluster from a point-in-time or snapshot

Database Clusters vs. Databases

When creating a new database cluster, you will be asked to provide the desired name of the cluster and the desired name of the initial “database” that will be created within the cluster. Each database cluster can have as many databases as needed within the cluster. In web development, these databases are sometimes referred to as “schemas”.

When attaching a database cluster to an environment, you will actually be selecting a particular database within the cluster that you would like to make available to the environment via the DB_DATABASE environment variable used by Laravel.

Connecting to Database Clusters

From Your Application

When a database is attached to an environment, Laravel Cloud will automatically inject the environment variables needed by the Laravel application to connect to the database, including the DB_HOST, DB_USERNAME, DB_PASSWORD, and DB_DATABASE variables. You may view these environment variables in your environment’s General Settings.

From Your Local Machine

To connect to your database from your local machine using a database management client like TablePlus, navigate to your organization’s “Resources” page and click the ”…” icon next to an available database. Then, click “View credentials”.

The database credentials modal window will provide you with the credentials needed to connect to your database, in addition to a “DeepLink” which will open your database in your local machine’s default database management client if you have one installed.

MySQL Public Endpoints

Before connecting to a MySQL database cluster, you must enable its public endpoint. From your organization’s “Resources” page, navigate to the “Databases” tab and click the ”…” icon for the MySQL database cluster you would like to connect to. Then, click “Edit settings” and enable the “Enable public endpoint” toggle.

Once the public endpoint has been enabled, you may click the ”…” icon next to the MySQL database cluster and click “View credentials”. When you are finished interacting with your database from your local machine, you are free to disable the public endpoint.

Editing and Resizing Database Clusters

You may edit database clusters and adjust their compute / storage settings via your organization’s “Resources” page. From the “Resources” page, navigate to the “Databases” tab and click the ”…” icon for the database cluster you would like to edit or resize. Then, click “Edit settings”.

Laravel MySQL storage can only be increased once every 6 hours and cannot be decreased.

Database Cluster Metrics

You may view metrics such as CPU, write throughput, and storage for database clusters via your organization’s “Resources” page. From the “Resources” page, navigate to the “Databases” tab and click the ”…” icon for an available database. Then, click “View metrics”.

Deleting Database Clusters

You may delete a database cluster via your organization’s “Resources” page. From the “Resources” page, navigate to the “Databases” tab and click the ”…” icon for the database cluster you would like to delete. Then, click “Delete database cluster”.

Was this page helpful?