How to terminate a IIS worker process

iLens 6 Reputation points
2021-07-27T09:21:09.523+00:00

My app uses a dedicated app pool with "Max worker processes" set to 1, but occasionally this gets reset to 0 (="infinite") and IIS starts a second process with disastrous consequences for my app.
I plan to check the number of active worker processes in the Application_Start procedure using ServerManager.
If this returns 2, how can I terminate this second process (for instance, can I just use system.diagnostics.process.kill)?
I can reset the app pool max worker process limit by using mypool.ProcessModel.MaxProcesses = 1, but does this take effect immediately or do I need to stop and restart the app pool (and if so, how) ?
How can I force IIS to start a second worker process to test this is all working?

Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,526 Reputation points Microsoft Vendor
    2021-07-28T03:05:44.64+00:00

    Hi @iLens

    If this returns 2, how can I terminate this second process (for instance, can I just use system.diagnostics.process.kill)?

    Open IIS manager and on the left side click on the name of your computer. You will then see a similar list of icons on the right as shown in the screenshot below. Double click on "Worker Processes" and you can get a list of which processes are currently running, here you can find your second process.

    Open the Windows Task Manager, ensure that the PID and Command Line columns are shown on the screen. For the second process, you can end it.

    I can reset the app pool max worker process limit by using mypool.ProcessModel.MaxProcesses = 1, but does this take effect immediately or do I need to stop and restart the app pool (and if so, how) ?

    You need to stop and restart the app pool to make the MaxProcesses setting take effect.

    How can I force IIS to start a second worker process to test this is all working?

    You can terminate other worker processes, leaving only a second worker process.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.