Fast development iterations: PHP versus Serverless
I sell "serverless" by advertising its fast development iterations. Typically less than five seconds on a primed system.
With a CI/CD system spinning up the environment, downloading source, building, testing, and deploying.... about 3 minutes. A lot faster than any Docker driven system which is pretty much the norm currently.
But PHP is faster
My colleague pointed out that PHP iterations are fast.
- You rsync the *.php to the VPS host
- Boom you're done!
Iterations are indeed less than a couple of seconds (well, as fast as the rsync!), but unlike serverless, this LAMP method is considered antiquated (by myself, warning I'm biased) for several reasons.
Why serverless is better
- PHP requires an always running VPS
- PHP requires a lot of additional complexity, a Web server as modules which can easily be out of sync with your local environment
- The underlying system running PHP probably needs to be maintained, unlike serverless
- PHP can't scale very well compared to the seamless nature of serverless
- if PHP is compromised the underlying VPS is much more of a prize than a short lived serverless process
- PHP's logging is often not properly exported and queriable like serverless good practice
- Rsync isn't (really) an immutable deploy, AWS API gateway for example properly (blue/green) switches from one version to another, and facilitates rolling back
Why PHP (on a VPS) is better
- No cold starts
- It's fairly easy to host yourself, no cloud provider needed
Conclusion
Tbh I am not 100% sure why PHP is not
supported on Lambda. Perhaps it's not
cleanly exposing a request/response interface? Maybe it's runtime is too heavy?
Update: https://bref.sh/ works on Serverless via AWS Serverless Application Model.
Nonetheless things have moved on since PHP. There are better languages. Golang as a language is better in a whole host of ways (greatly reduced surface area) and is well supported as a serverless runtime.