Closed mdegrees closed 5 years ago
Is now-php production ready? Almost. Are there production apps on now-php? Yes, there are.
PHP development server is not production friedly...
The PHP docs is right, but I think for class webserver combo (apache+php, nginx+php). Because PHP DevSrv is single threaded process, it cannot scale.
Otherwise, serverless is different against classic webserver. It receives 1 request and send 1 response and then die, basically. Learn more in docs (https://zeit.co/docs/v2/advanced/concepts/lambdas#lifecycle-and-scalability).
There are many ways how to run PHP on Lambda.
PHP DevSrv is fast, about 2-4ms per request and takes about 70-90mb of RAM. I don't think we can be faster, well, idk how. And about consumption of RAM, there can be some optimisations. Maybe PHP-FPM would take a less memory, but you need FastCGI client.
There is one client which seems nice (https://www.npmjs.com/package/fastcgi-client), but it's 7y old. It is easily to start PHP DevSrv.
You have to also think about local development, when performing now dev
. I think it takes more work how now dev works. At this time I don't use PHP DevSrv for now dev, but CGI. Because it's also easily to take care about CGI and don't need to kill PHP DevSrv if you have more PHP lambdas in your project.
I hope it brings you better insight. ;-)
@f3l1x Much more clearer. Thank you!
So basically with now
you're using PHP DevSrv mode by default, and there are no concerns given the nature of serverless lambda. While with now dev
you're opting for php CGI.
This explains also why I'm getting a PHP process errored Error: spawn php-cgi ENOENT
with now dev
on MacOs Mojave. Is this because MacOs ships with no php CGI? (php --version
gives PHP 7.1.23 (cli) (built: Feb 22 2019 22:08:13) ( NTS ))
Thanks again for your time.
This explains also why I'm getting a PHP process errored Error: spawn php-cgi ENOENT with now dev on MacOs Mojave. Is this because MacOs ships with no php CGI? (php --version gives PHP 7.1.23 (cli) (built: Feb 22 2019 22:08:13) ( NTS ))
Exactly, you need to install php-cgi as well. I will add it to pre-run check and it show you better error. :-)
Btw, take a look at doc page.
https://github.com/juicyfx/now-php/blob/master/errors/now-dev-no-local-php.md
I'm closing it here. :-) Feel free to ask about anything.
now-php has just renamed to vercel-php and it's more then production ready, it's production ready as 🔥
Forgive my lack of knowledge in php/serverless, you mentioned that the mode is "PHP development server" which gets a flag on php documentation for not being production friendly. Is this normal as it's a now/serverless architecture and all the server load is managed by Now. Can you please shed some light on this?
Thank you!