how to scale Laravel

How to scale Laravel Applications

In our previous article, we detailed how to deploy a Laravel application to the cloud on Ubuntu, and showed you how easy it was to do so using the Bunnyshell Framework templates.

Summary

In this article, we’re going to show you how to scale a Laravel application using the Bunnyshell platform. We will explain how the platform can help you scale in a simple manner and how it can help your deployment process.

Scaling on other cloud providers

First of all, managing Virtual Machines on a Cloud provider like Microsoft Azure or Amazon Web Services should be a simple matter, if you are already familiar with these platforms – and by familiar we mean you know them well.

From managing resource groups to selecting or deselecting features that you do not really use, such as floating IP’s or premium storage solutions that they offer and impact your cloud budget needlessly if you don’t pay attention to what you create.

However after you navigate the interfaces and tweak your Virtual Machine setup until it’s just the way you wanted, but probably not and you just don’t know it yet, you still have to go through the entire process of setting the said Virtual Machine up after it was created to be able to run your Laravel application as detailed in the previous article.

And only after all these steps and manual configurations are you now able to scale your Virtual Machines vertically and horizontally. Provided that you also know how to setup and use their load balancer services, block storage, and so on.

How to scale Laravel using Bunnyshell 

Getting Started

Using the Bunnyshell platform creating your Virtual Machine only takes a couple of clicks, and by using our Frameworks feature you can have your Virtual Machine set up for running Laravel with just a couple more clicks.

We covered these simple steps in our previous article but here they are again:

  1. Go to the application section and select the Frameworks tab;
  2. Select Laravel;
  3. Select an existing virtual machine or leave it blank to create a new one;
  4. Select your desired cloud provider and your machine location and size;
  5. Give your application a name and create it.

how to scale laravel

And after just a couple of minutes, your Virtual Machine is up and already configured to run the Laravel Framework. All you had to do is click a couple of things instead of having to configure the machine manually as detailed in the previous article about setting it up on a bare Virtual Machine.

Laravel deployment

This will allow you to configure a repository to use as a codebase and allow you to select the branch you want to have deployed. Needless to say, this can be helpful for configuring staging and production environments based on repository branches.

repository git Laravel

deploy Laravel

From here you can also manage your backups and restores for the application, you can simply create a backup or restore your application with a few simple clicks, no more logging in to the server and running commands.

Back up Laravel

Let’s talk scaling

So all that is fine and simplifies the way you deploy your application’s codebase, but we haven’t really talked about scaling, aside from scaling your deployment process.

Now that your application is created and its deployment process is set up, all you have to do to scale into more machines is simple.

First, you need to create a snapshot of your current Virtual Machine that was created for your application or that you selected during the setup process.

After that, you need to go to the OPS section under Snapshots, select the newly created snapshot and create a new Virtual Machine by selecting the Restore option from that snapshot.

snapshot laravel

restore backup

You can repeat this step and create as many Virtual Machines as you need. Assuming that you want to scale horizontally. Obviously this is a good idea if you don’t have a Database on the same machine as your API or UI.

If you just want to scale vertically then all you have to do is select your Virtual Machine and change it’s plan to a more expensive one.

scale laravel

Now that your new machine created via snapshot has come online you can see that a cloned application was also created in the Applications section, you can use this to either create a staging environment by setting up the new application to deploy a different branch or set up your DNS record to point to this IP address as well to easily set up some load balancing. This means scaling won’t impact your deployment process because you also use the applications built-in deployment feature.

DNS load balancing is the practice of configuring a domain in the Domain Name System (DNS) such that client requests to the domain are distributed across a group of server machines.

Conclusions

This is about all you need to know about scaling a Laravel application with Bunnyshell, it’s an easy process with lots of automation that makes your life easier and helps take your mind off the DevOps side of development.