Click here to Skip to main content
15,908,274 members
Home / Discussions / C#
   

C#

 
AnswerRe: Pass Info from Desktop App to Webpage Pin
David C# Hobbyist.28-Mar-13 8:42
professionalDavid C# Hobbyist.28-Mar-13 8:42 
Questionprogramming ideas Pin
MegaBaitas28-Mar-13 3:45
MegaBaitas28-Mar-13 3:45 
AnswerRe: programming ideas Pin
Richard MacCutchan28-Mar-13 3:58
mveRichard MacCutchan28-Mar-13 3:58 
AnswerRe: programming ideas Pin
PIEBALDconsult28-Mar-13 4:01
mvePIEBALDconsult28-Mar-13 4:01 
Generalprogramming ideas Pin
MegaBaitas28-Mar-13 5:11
MegaBaitas28-Mar-13 5:11 
GeneralRe: programming ideas Pin
PIEBALDconsult28-Mar-13 10:14
mvePIEBALDconsult28-Mar-13 10:14 
AnswerRe: programming ideas Pin
Alan Balkany1-Apr-13 5:08
Alan Balkany1-Apr-13 5:08 
QuestionBoost parralel messaging performance (TPL / Async) Pin
KillerX12328-Mar-13 2:29
KillerX12328-Mar-13 2:29 
Hi Braniacs Smile | :)

I have a performance optimization problem that has been bothering me for some time. I have tried to squeeze more performance from it without much success.

The system (simplified) is as follows:

1) Requests come in over an HTTP Post (I need to respond syncronously / inline)
2) I process the request, and return a response (all xml)
3) If I do not have a result ready within 15 seconds, I respond with a 'server busy, try later' type message.

As the central message processing mechanism I have used a Task based approach to queue, start and wait for messages (max of 15 seconds)

When a message is processed almost instantanesouly, the throughput (requests per second) is quite good (1000/s). However, when message processing is delayed by 200ms, this

degrades rather badly to 40/s

A few snippets:

C#
public void AddMessage()
{
     Task.Factory.StartNew<MessageResponse >(() =>
                {
                    return worker.ProcessMessage(),
                  , 
                TaskCreationOptions.None);
}

public MessageResponse GetMessage()
        {
            task.Task.Wait(15 * 1000);

            switch (task.Status)
            {
                case TaskStatus.Running:
                        message = "Your request is taking longer than usual"

                case TaskStatus.RanToCompletion:
                        message = (MessageResponse)task.Result;
                    
            }
   return message;
}



Note:

Task creation options None / Longrunning / PreferFairness has no impact. When running the visual studio performance analyser, I can visually see Longrunning creating a new thread for each request (expected), and None using a limited number (underlying threadpool) to service the requests.

Looking at both ANTS performance profiler and Visual studio Performance analyzer, there are no concurrency issues around contention and no other obvious areas where time is being wasted (either cpu time or wall clock time)

What is clear from the visualized results is that in a situation where say 1000 requests are queued, 90% of the program time is spent on thread servicing and context switching (obviously very expensive). My conclusion is that waiting on the result (over multiple requests) is very costly.

If i doing this on a web page or WPF form I could make it completely asyncronous, however I dont have this option.

Is there any where I can alter the message processing mechanism to optimize concurrency better? I am open to anything really , would even explore async / await if it would benefit.

Thanks in advance Smile | :)
QuestionMy issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Tridip Bhattacharjee28-Mar-13 0:31
professionalTridip Bhattacharjee28-Mar-13 0:31 
AnswerRe: My issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Thomas Duwe28-Mar-13 5:26
Thomas Duwe28-Mar-13 5:26 
GeneralRe: My issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Tridip Bhattacharjee30-Mar-13 5:35
professionalTridip Bhattacharjee30-Mar-13 5:35 
GeneralRe: My issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Thomas Duwe1-Apr-13 5:37
Thomas Duwe1-Apr-13 5:37 
QuestionHttpWebRequest and strange networking errors Pin
cjb11028-Mar-13 0:10
cjb11028-Mar-13 0:10 
QuestionHow to enlarge the recording voice Pin
Star.jon27-Mar-13 22:46
Star.jon27-Mar-13 22:46 
AnswerRe: How to enlarge the recording voice Pin
Bernhard Hiller27-Mar-13 23:01
Bernhard Hiller27-Mar-13 23:01 
GeneralRe: How to enlarge the recording voice Pin
Star.jon27-Mar-13 23:05
Star.jon27-Mar-13 23:05 
GeneralRe: How to enlarge the recording voice Pin
Dave Kreskowiak28-Mar-13 2:00
mveDave Kreskowiak28-Mar-13 2:00 
Questionerror in crystal reports Pin
User349027-Mar-13 13:36
User349027-Mar-13 13:36 
AnswerRe: error in crystal reports Pin
Abhinav S27-Mar-13 17:58
Abhinav S27-Mar-13 17:58 
AnswerRe: error in crystal reports Pin
V.27-Mar-13 22:21
professionalV.27-Mar-13 22:21 
GeneralRe: error in crystal reports Pin
User349028-Mar-13 7:49
User349028-Mar-13 7:49 
GeneralRe: error in crystal reports Pin
V.28-Mar-13 8:19
professionalV.28-Mar-13 8:19 
QuestionHow to Async download multiple files using webclient simultaneously? Pin
Tridip Bhattacharjee27-Mar-13 8:01
professionalTridip Bhattacharjee27-Mar-13 8:01 
QuestionScreenshots -> Video file Pin
ADASD33333227-Mar-13 4:06
ADASD33333227-Mar-13 4:06 
AnswerRe: Screenshots -> Video file Pin
Abhinav S29-Mar-13 4:00
Abhinav S29-Mar-13 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.