Serverless case study: PrettyCI and Laravel Queues

This article is part of a series of case studies of serverless PHP applications built with Bref on AWS Lambda. If you are not familiar with serverless and Bref, I invite you to read Serverless and PHP: introducing Bref.

This case study is about, a SaaS that provides continuous integration for PHP coding standards for GitHub repositories.

The idea is that anytime you push a commit to your GitHub repository, PrettyCI will analyze that commit using PHP CodeSniffer or PHP-CS-Fixer. Since PrettyCI integrates in GitHub's checks tab you can see the build result directly in your repository without having to leave your work.


I originally created the project using Laravel Spark. This is a Laravel project pre-built for creating SaaS applications (and it is pretty awesome by the way).

While Spark takes care of the website, I had to create:

Fortunately Laravel has a queue system that is very easy to setup.

After deploying the whole thing to a small DigitalOcean server (❤️) using Laravel Forge (❤️) it was running just fine.

Serverless workers

Since I was running 4 workers on my server that meant that the system could process at most 4 commits at a time. When the 4 workers were busy, new commits to GitHub would be pending and waiting for a worker to free up.

This is not great for user experience, and while scaling up is doable (see this great article by Oh Dear for example) it is a bit more work.

Indeed, that meant adding more servers, which meant more costs and a much higher maintenance effort. This is were my lazy side kicked in.

As I was working with Lambda for at the time, I decided to migrate the workers to AWS Lambda using Bref.

I did the migration in July 2018 and it has been a complete success in my eyes, running great since then.


The migration itself presented some challenges:


Now that the system is running, I don't see many downsides:



As explained in the Bref Maturity Matrix, running workers and jobs is an excellent use case for AWS Lambda, and this works perfectly for PrettyCI.

The migration is a bit more effort than "simply" using Laravel Queues or other similar libraries, but this is something we are trying to simplify at Bref.

If you are interested to learn more about AWS Lambda, you can check out other articles and subscribe to the serverless PHP newsletter.

Interested to learn more about serverless?
Check out my interactive course: Serverless Visually Explained.