serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
111 stars 15 forks source link

Compose is waiting for all services at a given "wave" to deploy before moving on #95

Open ROSeaboyer opened 2 years ago

ROSeaboyer commented 2 years ago

I've got a monorepo with 6 stacks; for ease of labelling let's call them A-F. In this scenario, consider the following dependency layout:

In this scenario, my services are being deployed in three "waves", which are starting in the proper order:

  1. A is deployed
  2. Upon completion of A, the deployments for B, C, and F begin
  3. Upon completion of B, C, and F, the deployments for D and E begin

In my scenario, F takes longer to deploy than B and C, but D and E are both waiting for F to complete before starting.

I'm not sure how much of a pain this would be on the implementation side, but would it be possible for a dependent service to start deploying immediately once the last dependency has completed instead of waiting for the entire wave to finish first?

mnapoli commented 2 years ago

Thanks for opening this issue, this is indeed something I noticed before, and we could improve it as it could accelerate some deployments.

@pgrzesik AFAICT this will not be a quick fix as it involves refactoring the building of the graph (inherited from Components).

pgrzesik commented 2 years ago

Hey @ROSeaboyer - thanks a lot for reporting 👍 That's correct, at the moment the execution of dependency graph is done in such "waves" and it definitely can be improved, but as @mnapoli mention it might not end up being a quick fix but it's definitely something that we want to do 👍

ROSeaboyer commented 2 years ago

That's fair; I tried taking a look over the weekend to see if I could figure it out quickly and try to give back, but in the limited time I had, I couldn't easily figure out a way to do it that wouldn't result in a gross mess of spaghetti code

pgrzesik commented 2 years ago

Hey @ROSeaboyer - thanks for trying to improve it 🙇 I was thinking about this as well and I believe I have a reasonable approach that shouldn't be too hard to implement - I'm hoping to find some time this week to tackle it