-1

I have problem with concurrent requests to an API. If too many requests are executed in one time (it can be 200+), they start to fail with an error.

There is list of students and I need to create test assignments for them, 1 student 1 API call. I used forkJoint to group observables with API calls and wait until all requests completed, after that the user gets a notification that students were assigned tests.

It's working fine, because browser limited amount of request, 10 for Chrome if I'm not mistaken. However with HTTP/2 this limit does not work, I used this example and its helped to solve problem with amount of requests, but I still have to wait before all (200+) requests completed to show notification. I don't understandt how to make it with RxJs.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • Do you have control over the API? It's a ***far*** better idea to send one larger request instead of hundreds of smaller ones. – Rory McCrossan Feb 07 '23 at 09:36
  • @RoryMcCrossan Thank for your help and response. No I dont have control over API, I agree that this is better solution, but for now we focused on how to change code on client side. – Vadim Khismatov Feb 07 '23 at 09:51

1 Answers1

1

Final solution looks like this:

from(observables)
  .pipe(mergeAll(10), toArray())
  .subscribe();