Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:32:33+00:00 2026-06-11T02:32:33+00:00

I create WCF service with Spring.NET framework. This service is math service and provide

  • 0

I create WCF service with Spring.NET framework. This service is math service
and provide some computations for client apps.

I have question about WCF service parallelization on multi-core server. For simple
example I have server with 20 cores.

First here is a simplified code.

//WS interface
public interface IMatlabService
{
    List<ResultData> Calculate(byte [] data);
}

//WS class definition
[ServiceBehavior(Namespace = "http://server.com/MatlabService")]
public class MatlabService: IMatlabService
{
    public IMatlabManager MatlabManager{get;set:}

    //web metod for math computations
    public List<ResultData> Calculate(byte [] data)
    {
        var result = new List<ResultData>();

        //do math work in another thread
        Task<List<ResultData>> task = Task.Factory.StartNew<List<ResultData>>(() =>
                                                           {
                                                               return MatlabManager.CalculateWithFiniteElementMethod(data);
                                                           });

        result.AddRange(task.Result)

        return result;

    }
}

public interface IMatlabManager 
{
    List<ResultData> CalculateWithFiniteElementMethod(byte [] data);
}

public class MatlabManager : IMatlabManager 
{
    public List<ResultData> CalculateWithFiniteElementMethod(byte [] data)
    {
        // do some math work
    }
}

With Spring.NET I configure web service and manager class as not singleton.

Spring.NET XML configuration is here.

Matlab manager configuration:

  <object name="matlabManager"
          type="MatlabManager"
          singleton="false"/>

MatlabService configuration:

  <object name="matlabService"
          type="MatlabService"
          singleton="false">
       <property name="MatlabManager" ref="matlabManager"/>
  </object>

WCF service configuration from web.config

 <behavior name="Behavior1">
     <serviceMetadata httpGetEnabled="true"/>
     <serviceDebug includeExceptionDetailInFaults="true"/>
  </behavior>

<services>
  <service name="matlabService" 
            behaviorConfiguration="Behavior1">
    <endpoint address="" 
            binding="basicHttpBinding" 
            contract="IMatlabService" 
            bindingNamespace="http://server.com/MatlabService"/>
    <endpoint contract="IMetadataExchange" 
            binding="mexHttpBinding" 
            address="mex"/>
  </service>
</services>

SVC file.

<%@ ServiceHost Language="C#" Debug="true" Service="MatlabServiceService" Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %>
  1. I believe for each client web metod call is created new instance of
    MatlabService and WCF service work is do on new thread (WCF service
    thread) and OS assign this thread to CPU core.

    Or I am wrong and behavior create new service object per call I must
    define in ServiceBehavior property InstanceContextMode?

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]

  2. In web method Calculate of MatlabService I use
    System.Threading.Tasks for parallelization so math work is do in
    another thread (Math thread).

    For each call is created WCF service thread and in WCF service
    thread is created Math thread.

    I am not sure if this is true.

    Maybe is needed allow multi-threading in WCF service in
    ConcurrencyMode?

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall,ConcurrencyMode
    = ConcurrencyMode.Multiple)]

I would like heard ideas how can parallelize web metod calls for multi core CPU.
I google it but not find any clear and usefull for me because I use Spring.NET framework for creation WCF service.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:32:34+00:00Added an answer on June 11, 2026 at 2:32 am
    1. The default instance context mode is PerCall, so setting that explicitly is redundant.

    2. Yes, you’re creating an additional thread to do the math operations, but you’re not gaining anything because you’re blocking until the task is complete. In fact, it is less efficient because you have the overhead of creating and mangaging an additional thread.

    Each web call is already serviced in its own thread.

    The only place I can see to add additional parallel computing is within the implementation of:

    MatlabManager.CalculateWithFiniteElementMethod(data)
    

    However, that looks like a call to Matlab. If you can reimplement that method using parallel code, you might be able to eek out some performance gains.

    Whatever you do, profiling is the key to understanding if you’re actually making it faster. Remember – parallel doesn’t always mean faster. There is overhead in synchronizing these operations and creating the threads for them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create WCF service and client. I want to add 2 way
I want to create new WCF service and client. The 2 parties will communicate
Hi I want to create a WCF service that have login method, which is
I want to create a new WCF service and client. The 2 parties will
am trying to create WCF client to consume the service, which contains messages. So
I have a WCF service that works ok if I create the service without
I have a WCF Service Using MSMQ hosted on IIS. I want to create
I have WCF service running from within a Windows Service. This is working fine
I have written a .NET Windows service which has a WCF service built into
I have written a windows service in C# .NET. This windows service contains a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.