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 987805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:32:26+00:00 2026-05-16T05:32:26+00:00

I have a WCF service load balanced across three different machines. Let’s say these

  • 0

I have a WCF service load balanced across three different machines.

Let’s say these services can process requests of types A, B, and C. There are no limits to processing A or B. However, we can only process 5 requests of type C at a time, so if a 6th request of type C comes in, it’ll have to wait until one of the previous requests finish.

How can I make sure that only 5 requests of type C are being processed across all three machines?

  • 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-05-16T05:32:27+00:00Added an answer on May 16, 2026 at 5:32 am

    Sounds like you need a cross-machine semaphore, you can implement one using a distributed caching solution like memcached. Alternatively you could have another WCF service running on a single machine which manages the semaphore for your load balanced services.

    So the new service might look something like this:

    [ServiceContract]
    public interface ISemaphorService
    {
        [OperationContract]
        void Acquire();
    
        [OperationContract]    
        void Release();
    }
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class SemaphoreService
    {
        private readonly static Semaphore Pool = new Semaphore(5, 5);
    
        public void Acquire()
        {
           Pool.WaitOne();
        }
        public void Release()
        {
           Pool.Release();
        }
    }
    

    In a real world app you might want to have the number of semaphores configurable in a config or something and put in some timeouts and putting in mechanism to make sure semaphores are released in a timely fashion and/or when the client crashes:

    // on the client side (service C)
    var client = new SemaphoreServiceClient();
    
    try
    {
       // acquire the semaphore before processing the request
       client.Acquire();
    
       // process request
       ...
    }
    finally
    {
       // always remember the release the semaphore
       client.Release();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a WCF service that a client can use to receive
We have a website load balanced across two servers that calls into a WCF
I have a wcf service that uses the .net System.AddIns framework to load assemblies
I'm new here and I hope anyonte can help me. I have WCF Service
I have built a WCF load balancer/router to conditionally route any one way service
We have a WCF service ( NetTcpBinding ) that sits behind a load balancer.
I have a load test for a WCF service, where we are trying out
I have a WCF service that I have to reference from a .net 2.0
I have a WCF service hosted for internal clients - we have control of
I have a WCF service and I want to expose it as both 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.