News for hackers. Stuff that matters.
Re:PHP 8.4 by JodieBenitez on Thursday November 21, 2024 @06:08AM (#42203096)
> - Easy to deploy: Upload files, done.

Sure, it works for simple/less important cases. But it also means that your application code is inconsistent while the files are uploading.

Stop your service, upload the files, start the service: safer.

For a Django app you would upload files and ask Gunicorn to graceful reload... similar, just cleaner.

Re:PHP 8.4 by lenlorijn on Thursday November 21, 2024 @07:43AM (#42203783)
Most PHP apps use a deployment method where a symlink gets set to a directory with a new version of the code. Because of how opcache works this has no impact on running requests, while new requests get handled with the new code.
Re:PHP 8.4 by JodieBenitez on Thursday November 21, 2024 @11:37AM (#42206031)
Yes, my point really... it's really not "just upload files" like it's 1997.
Re:PHP 8.4 by dizhn on Friday November 22, 2024 @10:14AM (#42214452)
That sounds pretty neat.
Re:PHP 8.4 by kijin on Thursday November 21, 2024 @06:23AM (#42203173)
You can use the same strategy with PHP. Preload all your scripts in opcache. Once you're done making changes, reset your opcache.

In practice, any serious project is likely to be version-controlled. Git pull is generally fast enough that it behaves like an atomic change. (By default, opcache will not reload a file that's less than 2 seconds old.)

Re:PHP 8.4 by JodieBenitez on Thursday November 21, 2024 @06:38AM (#42203301)
I'm pretty sure many PHP dev don't know about OPCache. Many of my colleagues don't know for sure. My point is "be aware of the state of your app code and what you execute", and so be aware of the shortcomings of this deployment "strategy". It's sure perfectly fine and easy for small apps / low traffic / not critical apps. I just want to point that it's not inherently good enough and definitely not the universal way to deploy a PHP app.

Git pull to deploy is something I avoid.

Re:PHP 8.4 by kijin on Thursday November 21, 2024 @10:24PM (#42210860)
Yeah, I've seen cases where even git is not fast enough. That's when opcache preload comes into play. It's still better than manually uploading files over FTP.

Having said that, the "most modern" deployment strategy is to spin up a new container with your new code already loaded, point your LB at the new container, and scrap the old container. No opcache issues. No race condition.