CakePHP

How to scale CakePHP applications faster and more efficiently

We’ve gone over how to deploy a CakePHP application to the Cloud, and shown you how easy it was to do so using the Bunnyshell templates. Now, we’re looking at how the platform can help you scale your CakePHP application in a faster, more efficient, and simple manner that improves your deployment process.

In this article, you’re going to learn how to scale a CakePHP application. 

We’ll explain how scaling works on a variety of Cloud providers like Azure or AWS and how it impacts your deployment process. Then, we’ll show you how to do it faster using Bunnyshell.

Let’s get started. 

Summary

  • Scaling CakePHP apps on other Cloud providers
  • Scaling CakePHP apps on Bunnyshell

Scaling CakePHP apps on other Cloud providers

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 creating, to managing, to scaling, there’s a lot to do. And not paying close enough attention at every step can lead to higher cloud costs and a difficult deployment process. 

The initial setup of the machine implies you doing all the setup steps of your CakePHP framework manually. We covered every step of that process in an article here

Then there’s managing resource groups and selecting (or deselecting) features that you don’t really use. Think of floating IP’s or premium storage solutions that needlessly impact your cloud budget, if you’re not paying close attention.

Once you create your Virtual Machine, you also have to set up your deployment process. This implies a build script for Gitlab/Github/Bitbucket and using a SSH method to get your code to the remote machine that you have setup on it, such as a deployment key.

Let’s say you’ve got everything worked out so far and you’re ready for the next step. To scale that machine you can either go:

  • horizontally – where you create and manage more machines, or
  • vertically – making one machine bigger on the inside. 

Either way, manually scaling on these Cloud providers will impact your deployments. For instance, your deploy script, which is probably written for one server when you push your code. That’s assuming you don’t use their own deployment mechanism, that isn’t automatically included in a standard plan. 

All this brings us back to the beginning – having a good understanding of how a specific Cloud service works is essential, and probably requires dedicated personnel to handle this side of your DevOps needs.

Scaling CakePHP apps on Bunnyshell

On the other hand, scaling your applications using Bunnyshell is an easy process with lots of automation features that make your life easier and helps take your mind off the DevOps side of development. 

Here’s how it works.

Setting up your server

We’ve covered this part in a previous article, but here’s a short summary:

  1. Go to the application section and select the Frameworks tab;
  2. Select CakePHP;
  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.

This way, you can set up a virtual machine to run your CakePHP application without actually having to go through all the steps required to set it up manually on AWS or Microsoft Azure. 

After the virtual machine is created, you’re all set to start deploying your application. Using Bunnyshell is the easiest and fastest way for you to deploy your application’s codebase. And no, you won’t need to use an FTP client to upload your files manually. 

All you have to do is go to Applications and open the app you just created, select Deployments and click Enable Deployment.

enable deployment cakephp

This will allow you to configure a repository to use as a codebase and let you select the branch you want to have deployed. 

Needless to say, this can prove extremely helpful for configuring staging and production environments based on repository branches.

repository branches

deploy cakephp

From here you can also:

  • manage your backups and restores for the application;
  • create a backup or restore your application with a few simple clicks, with no need to log in to the server and run commands.

take backup

Scaling your CakePHP application

Now that your application is created and it’s deployment process is set up, scaling 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

restore virtual machine

If you want to scale horizontally, you can repeat this step and create as many Virtual Machines as you need. 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 inclusive one.

cakephp

Now that your new snapshot-created machine 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 setup your DNS record to point to this IP address as well to easily setup some load balancing. 

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

This means that scaling won’t impact your deployment process because you’re using the applications built in deployment feature.

That’s about all you need to know about scaling a CakePHP application. A cloud infrastructure management solution like Bunnyshell will save you countless hours, increase productivity and improve your deployment process.

We’re always working on improving our product, so reach out if you’ve got any questions or there’s anything you’d like us to walk you through. Make sure you also check out our roadmap and vote on any ideas or features you’d like to see us include in Bunnyshell.