Closed misog closed 2 years ago
Why do you want sidecar to deploy your application when bref already allows you to run queued jobs etc?
First and foremost it would be useful to deploy and run simple PHP code with sidecar, just like JavaScript, Java, Python, ...
Moreover, CPU-intense PHP jobs could be distributed to multiple Lambda instances very easily, even without queues. Queued jobs are more complex; they usually need packages or classes boilerplate, they require to have a queue and queues could have scalability or other limits.
The idea to deploy/clone entire application by sidecar is an idea how to replace job queue mechanism (with packages or classes boilerplate, queues and queue limits) by any implementation of remote job pattern (ex. simple helper function which calls Sidecar).
@misog this is an interesting question, and one I've thought a lot about. There are a couple of hurdles that I see.
The first is that there is no native PHP runtime! This is fixable, of course, by using a container (which Sidecar supports), but it's not as straightforward and is another thing to maintain. If bref has public images or layers available, that would certainly make it easier. I believe Vapor's layers are semi-public, in that we can figure out what they are and simply use them to add PHP support.
Another issue is the vendor directory + the 250mb limit. If the entirety of the app gets too large, then you're suddenly stuck creating an image out of your app. That's a really big leap. You could be moving along nice and easily and then suddenly you're at 251mb and you have to figure out how to containerize your app. That would be a pretty bad experience. It might not matter though, or rather might not be worth us worrying about at the moment.
If you were able to get a PHP runtime and a Laravel app all zipped up and shipped to Lambda, I'm not even sure if the framework would boot to a "hello world" without some modifications. I don't know what all Vapor does to modify the runtime, but I think it's probably something!
This would be the thing to try:
1) Can you find a layer that provides php8 support? Can you reuse Vapor's? 1) Can you zip up a whole laravel app and call a simple "hello world"?
If you can prove those two things, then we have a path to the other stuff you were mentioning, and we can roll it into Sidecar proper.
@misog ok I got a proof of concept set up last night... and I must admit it seems pretty cool. I'll keep working on it and see if I can get something polished up in the next few weeks.
I also got a full Laravel app working... https://twitter.com/aarondfrancis/status/1478468469154889734.
I'll definitely be working towards releasing this after Laracon on February 9th.
That is wonderful! Looking forward to watch you on Laracon 2022. This shifts power to application framework (Laravel), making it more developer-first & infrastructure-second for individuals and small teams.
See https://github.com/hammerstonedev/sidecar-php for more! 🎉
Hi, is it possible to use custom PHP runtime such as bref.sh?
Then Queueable PHP code or Jobs (with packages) could be run in Lambdas.
Possibly, whole Laravel app could be deployed to Lambda with ex.
sidecar:deploy --clone
and all existing classes could be available including Jobs - Lambda would act like PHP process.Or another interesting usecase; helper
runInLambda(function() { /* any code */ })
will run the function in Lambda in the context of the cloned application.