Back to all articles

Is PHP x Serverless worth it?

James Simm
James Simm
Head of Engineering
4 min read
16 July 2019

Serverless is the new craze in cloud computing, and for good reason. It enables you to release code without needing to worry about servers. Obviously there are still servers involved, however, there is no need to maintain them and reserve the capacity; the servers scale up or down automatically and the developer only pays for what is used.

This topic has always been a bit of a question mark for me and I was able to gain some clarity through attending Laravel Live. The official Laravel PHP Conference for the UK was held over two days in London and brought together hundreds of Laravel and PHP enthusiasts, like me, to share knowledge through a series of inspirational talks and workshops. 

This article is in response to my recent deep dive into Laravel and related technologies and intends to explain what serverless means for web applications and more specifically running PHP on a serverless platform, such as AWS Lambda – which is the platform I’ll have in mind for the rest of this article.

What is serverless (FAAS)?

The traditional way of deploying an application would usually include provisioning a server (or a container), setting up all the required dependencies, and if one server isn’t enough, doing the above multiple times to scale towards your needs – coupled with having to load balance the traffic between those servers/containers.

The aim of serverless is to save programmers from having to do all of the above steps. Additionally, it significantly cuts down server administration expenses and saves money with its pay-as-you-go pricing structure.

This is where things get interesting, as with serverless, you only pay for code execution time. All you have to do is push your code up to the given platform (in our case, Lambda), and ta-da. It just works.

Are there any limitations to consider?

Serverless is a different way of building and operating systems, and just like most alternatives, there are limitations as well as advantages. AWS Lambda is the most mature FaaS platform and its first very limited version was only released 5 years ago and hasn’t been fully perfected. 

Lambda doesn’t allow code and layers (I’ll be covering what these are further down this post) to exceed their maximum allowed size of 250MB’s. On top of the above, the maximum body size of a request is 6MB’s – which is not great, not terrible. 

Lastly, presuming that a user’s application will be using a VPC (Virtual Private Cloud) for example, to connect to Amazon RDS services, Lambda’s cold starts will be extremely slow, making it not-so-ideal for certain use-cases, such as API endpoints. (That said, AWS has promised to fix this issue in 2019)

Read more about the above here and see the maturity matrix of running PHP on AWS here.

So… what are layers?

Simply put, layers allow Lambda functions to pull in additional libraries, custom runtimes, and dependencies.

With some extra work, Lambda allows you to run any programming language on their platform, as, by default, PHP isn’t included in their list of natively supported languages.

Thankfully, an amazing team of developers has already created an easy solution to the above issue. Thus, I present you an amazing tool called Bref

How do I get started?

The goal of this article isn’t to get into the nitty-gritty details of how to deploy PHP on Lambda, but rather to shed light on the possibilities of the platform.

That said, Bref has a really straight-forward documentation available here, if readers decide to give it a shot. All you really need is a bit of spare time and an active AWS account. Plus, Lambda comes with 1 million free requests per month so there really isn’t anything to lose.

Serverless might be all the hype at the moment, but when looking at how the technology has been progressing in the past couple of years, I believe that it’s fair to say that it’s here to stay, especially with the recent shift towards cloud computing in the industry.

More Insights?

View all Insights


Head of Engineering

Sandor Voordes