You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The listing below shows a simple program which will spawn a number of threads, each responsible for sending a single email via Amazon SES. After delivering its mail message, each thread will print the number of milliseconds elapsed since application start.
var stopwatch = new Stopwatch();
stopwatch.Start();
var mailer = new AmazonSimpleEmailServiceClient(KEY, SECRET);
for (var i = 0; i < THREAD_COUNT; i++)
{
var thread = new Thread(() =>
{
mailer.SendEmail(new SendEmailRequest()
.WithSource(FROM_ADDRESS)
.WithDestination(
new Destination()
.WithToAddresses(TO_ADDRESS))
.WithMessage(
new Message()
.WithSubject(new Content("Mono test"))
.WithBody(new Body(new Content("Testing 1 2 3")))
));
Console.WriteLine(stopwatch.ElapsedMilliseconds);
});
thread.Start();
}
Console.ReadLine();
Using Microsoft.NET on my Windows machine, it takes around 900 ms to run this program with 1 thread, around 1100 ms with 10 threads, 1400 ms with 50 threads. That's good – it scales great with the number of threads, which is expected due to the amount of waiting involved in calling a web service.
However, when I execute the exact same program on Mono on the same Windows machine, the results a very different. 1 thread: 2 s, 10 threads: 11 s, 50 threads: 62 s. This initially looks like there is a lock() or similar around the HTTP request, effectively forcing sending to be single threaded. Looking closer at the numbers written from the threads, however, all of the threads seems to complete at almost exactly the same time (eg. with 50 threads they all complete between seconds 60 and 62). This seems to suggest some sort of locking behavior, where all of the threads have to wait on the last the finish – weird.
Any idea what this is about? I have a feeling this might be Mono bug, rather than an AWSSDK bug, but I have not been able to reproduce it with "raw" HttpWebRequest instances.
The text was updated successfully, but these errors were encountered:
The listing below shows a simple program which will spawn a number of threads, each responsible for sending a single email via Amazon SES. After delivering its mail message, each thread will print the number of milliseconds elapsed since application start.
Using Microsoft.NET on my Windows machine, it takes around 900 ms to run this program with 1 thread, around 1100 ms with 10 threads, 1400 ms with 50 threads. That's good – it scales great with the number of threads, which is expected due to the amount of waiting involved in calling a web service.
However, when I execute the exact same program on Mono on the same Windows machine, the results a very different. 1 thread: 2 s, 10 threads: 11 s, 50 threads: 62 s. This initially looks like there is a
lock()
or similar around the HTTP request, effectively forcing sending to be single threaded. Looking closer at the numbers written from the threads, however, all of the threads seems to complete at almost exactly the same time (eg. with 50 threads they all complete between seconds 60 and 62). This seems to suggest some sort of locking behavior, where all of the threads have to wait on the last the finish – weird.Any idea what this is about? I have a feeling this might be Mono bug, rather than an AWSSDK bug, but I have not been able to reproduce it with "raw"
HttpWebRequest
instances.The text was updated successfully, but these errors were encountered: