How to limit concurrency with async? #520
-
I have a task to do which requires to loop thousands of time to launch thousands of async subtasks. I'd like these subtasks to be launched with a limitation of 10 at the time. What is the best way to achieve that using the async library? Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
SimonFrings
Jul 10, 2023
Replies: 1 comment 2 replies
-
Have a look at https://github.com/clue/reactphp-mq that should be able to help you. Otherwise you, if you need something more persistent than in process memory, you could check out https://github.com/jakubkulhan/bunny/ |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@maximejobin good question 👍
I agree with what @WyriHaximus said, just note that when using clue/reactphp-mq you'll queue your (thousands) operations in-memory and I'm not sure if this is something you want to do (the more operations, the more memory you're using).
You might also want to take a look at clue/reactphp-flux as this works similar to clue/reactphp-mq without keeping you operations inside your memory, so this might be a good fit for the amount of operations you have. Taken from the flux documentation: