brefphp / bref

Serverless PHP on AWS Lambda
https://bref.sh
MIT License
3.06k stars 364 forks source link

Set maximum concurrency for individual parts of the project #1710

Closed Adesin-fr closed 6 months ago

Adesin-fr commented 6 months ago

Following #72 (Set maximum concurrency by default) :

There is already a function that allows to set the max concurrency on the whole project (as far I understood correctly). But imagine if the user sets a limit to 10, and puts a lot of heavy, long during jobs in the queue : 10 "workers" will start and run in parallel, but the limits will be hit and no more lambdas will be allowed to run to serve the web (if none were already started before)...

What would be a really usefull feature is to allow to set a limit for each stack (one limit for web, one limit for job workers), so each one can be scaled independantly.

That also could mitigate some issues where too much jobs are run in parallel against a DB that would not be able to handle hundrers of concurrent connections.

I think that to be able to acheive this, it would require to deploy two distinct projects instead of only one ? Perhaps it is possible to do it manually, but I couldnt figure how to set this up ?

mnapoli commented 6 months ago

It's already possible, set the reservedConcurrency field on each function instead.

Adesin-fr commented 6 months ago

Nice ! Thanks for the trick, I had not understood it before !

Perhaps it should be interresting to put this on the docs or the default serverless.yml ?