![]() ![]() In most cases overparallelizing is harmful, and might yield worse performance than not parallelizing at all. 18 comments 100 Upvoted This thread is archived New comments cannot be posted and votes cannot be cast Sort by: best level 1 3y Same for me 3 level 2 3y mine just said throttled 7842 seconds - or something close to that 3 Continue this thread level 1 3y I am having the same issue. Don't go crazy with large values like 100 or 1000. Then you'll have to experiment with the MaxDegreeOfParallelism setting, until you find the one that yields the optimal performance. My suggestion is to do the later: ConcurrentQueue listTest = new() Īfter doing these changes, hopefully your code will still work correctly, and it will be running a bit faster. You can either add a lock (listTest) before each listTest.Add, or replace it with a concurrent collection. The List is not thread safe, and so it will get corrupted if you call Add from multiple threads without synchronization. ![]() with this: ParallelOptions options = new() Īwait Parallel.ForEachAsync(rows, options, async (row, _) => I would replace this code: foreach (var row in rows) But since your code is complex, I would go the easy way and do just that. Generally you don't want to put this method inside an outer for/ foreach loop, because then the degree of parallelism will fluctuate during the whole operation. Ideally you would like to call the Parallel.ForEachAsync only once, so that it parallelizes your work with a single configurable degree of parallelism from start to finish. Your code is quite complex though, and deciding where to put this loop is not obvious. When a request is throttled, the API responds with status 429 and the time in seconds till the next request in this scope is allowed. The most handy tool that is currently available for parallelizing asynchronous work is the Parallel.ForEachAsync method. If a rate limit for a scope is set to /![]() ![]() ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |