[CSHARP-1544] System.TimeoutException: when using more than 10 tasks Created: 22/Jan/16 Updated: 05/Apr/19 Resolved: 26/Jan/16 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Connectivity, Error Handling, Performance |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Critical - P2 |
| Reporter: | Roman | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7, MongoDB v3.0.6 |
||
| Attachments: |
|
| Description |
|
Hello, I am trying to insert the documents into the MongoDB using the Task.Run functionality. When I am creating 10 tasks everything works fine, but if there are for example 50 tasks created then I get the System.TimeoutException. |
| Comments |
| Comment by Roman [ 26/Jan/16 ] |
|
Hi Craig, Thank you for fast response. Thank you very much! |
| Comment by Craig Wilson [ 22/Jan/16 ] |
|
First off, I could not replicate any issues. I even went up to 1000 and had no trouble. So, some statements: I've noticed you increased the defaults this should help when under high loads. However, this is a console application. If you were to profile the speed of your inserts, you'd find that increasing the thread count to 1000 ultimately hurts performance. You are constrained by the number of cores you have on your machine. In addition, this seems to be a semi-concocted perf test with somewhat arbitrary input. It would be helpful to know what your actual workload is rather than inserting a bunch of instantiated error logs as fast as possible. Where are these error logs coming from? Are you likely to be constrained on ingestion speed as well? Anyways... 1. What can help with this is to use asynchronous inserts. This is simple enough with the driver by changing your InsertObject method to return a task and internally calling InsertOneAsync. This will let your local computer utilize resources better while network IO is going on. Note that async tends to be a bit slower individually, but ultimately can yield a higher throughput. 2. Instead of picking something arbitrarily high (like 1000), start low, measure, and increase your thread count until you start to get a decline in throughput. That is your magic number. 3. Consider using Parallel.For instead of a for loop composed of Task.Run. |