I have a group of web services that get hit 2,000,000 times a day; 7 web services.
Each service currently drops the incoming XML message to disk (it's a big disk).
The file drops happen at the start of the request, and I want to spin this off onto a new thread so I don't lose the 20ms it takes to write the file. Yes, those 20ms matter more than you think.
I'm using .NET 2.0, and have thought of 2 ways to do this: Asynchronous method call to the DropMessage() method, or starting a new Thread and calling it.
private void DumpMessage()// this method dumps the incoming message to File.
DumpMessages manages it's own business. If it fails, it knows what to do and how to contact my team.
public delegate void AsyncDumpMessage();
AsyncDumpMessage caller = new AsyncDumpMessage(DumpMessage);
IAsyncResult result = caller.BeginInvoke(null, null);
vs
System.Threading.Thread t = new System.Threading.Thread(DumpMessage);
t.Start();
Are there any caveats to the above two? I'm leaning on the Asynchronous method, as I've gotten better performance out of it through my testing
Any other ideas for a better way to do this? Performance and stability is key for me.