79587614

Date: 2025-04-22 23:55:13
Score: 1
Natty:
Report link

I believe networking (mainly client/server limits) is an important factor in this problem. Looks like something wrong with numbers. There shouldn't be that much difference (24 mins to 1 mins) between single/multi thread downloading files, unless there is specific limits on per socket/thread. Most likely you are getting lots of errors and unfinished downloads in second example? In that case, comparison and numbers will be meaningless.

In networking there are boundaries both for client and server like bandwidth, process time per request etc. Lets imagine a simple scenario; there are no limits on server side, you are limited only by your bandwidth, lets say you are limited by 10mb per second and a single file is 1mb; in this case, it wont matter how many threads you are using as bandwidth will be shared among threads. 1 thread will download 10 files in a second or 10 threads will download 10 files in a second, no difference. Multi threading will help if a request/download are limited per request basis. For instance if it takes 1sec to send/get a single response no matter what then you will better off sending 10 request simultaneously than 1.

As for "task.whenall" vs "parallel.foreachasync", I think its been already answered discussed well. I also made a few benchmark tests compared both for api requests and downloading files, both performs similar.

Side note; i recommend cpu bound tasks first for experimenting "Threading and Task Parallel Library" etc. stuff. It would be easier without extra factors.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: devmet34