14

What is the advantage of upping the "Maximum Worker Processes" from the default of 1 in IIS?

Given that it seems any worker process can reply to a request from a single client (ie they are not assigned a client) and that session variables are only accessible from the process they were created in, in what situation would it be advantageous to increase this setting?

I ask because one of my web applications was having all sorts of issues with session variables (random logging out etc) - it turns out a server tech had upped this to 4, thinking he was doing good. Returned it to 1 and the application is happy.

2 Answers 2

12

The only real advantage of increasing the number of worker processes is if you've got some long running process that's blocking the other threads from running - in which case you might want to consider adding another Worker Process.

However, as you've found this basically spools up another instance of w3wp.exe with it's own memory space that doesn't share in-process information between them, so you need to ensure you're set up for session sharing (MachineKey has been set, session is stored in a database or Session Service, etc.). A better option would be looking to see if you can offload the long running process to a separate process altogether.

6
  • That makes sense yes - is there any way to force a process to reply only to its own sessions? Luckily the site I'm currently working on only currently gets around 1000 requests a day, so load isn't an issue. Commented Aug 8, 2012 at 14:50
  • No, I don't think there's a way to direct a request to a particular wp - hence the notes about configuring session sharing. Commented Aug 8, 2012 at 15:48
  • You may want to look into IIS web gardens, if you application supports it. Commented Aug 14, 2012 at 1:20
  • 1
    It's important to make the distinction between long running processes that are blocked by I/O operations (or making distributed calls) and those that are simply grinding away CPU time. Adding a worker process in the latter scenario will not help. It will make it worse, because your OS/CPU will now cycle between multiple processes doing work. That's more overhead for the CPU process, reducing capacity.
    – Frederik
    Commented Feb 28, 2013 at 18:07
  • 1
    @Vincent no, I don't think I said that. Not sure what effect it will have on the session object, other than "[spooling] up another instance of w3wp.exe with it's own memory space that doesn't share in-process information between them". So I imagine it will start another instance of the site with its own session object. Commented Sep 16, 2021 at 19:12
3

We use multiple workers on our web services server so that if we reach a peak period, another worker will spawn and handle more requests. This is especially effective with WCF services and is totally automatic. Some of these services are set to spawn up to 8 additional workers with the only limitation being memory. Works great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.