locked
Multiple worker processes question RRS feed

  • Question

  • User350923160 posted

    Hello friends,

    I have an asp.net web application with several pages. In the load event for each page I check for a specific session ID in all of the pages and if it is null the redirect to the login page. 

    The problem started when I increased the worker process from 1 to 2 or 3 hoping to increase performance.  I get this random behavior. I run 3 or 4 different browsers and login to the web application using different IDs and every now and then I get redirected to the login page because the session is null. This happens only when I increased worker processes to above 1. Any ideas why it is doing that?

    The problem with leaving worker process to 1 is that it takes a while if I run multiple browsers at once for testing purposes. I noticed that one has to finish before the next one will finish. I thought that is because I have one worker process. 

    Any ideas thoughts or suggestions is greatly appreciated.

    Thank you. 

    Monday, February 19, 2018 9:33 PM

All replies

  • User475983607 posted

    aazizasp

    have an asp.net web application with several pages. In the load event for each page I check for a specific session ID in all of the pages and if it is null the redirect to the login page. 

    This is a bad design.  Session lives in server memory and should not be used to persist user credentials as it limits expandability - adding servers to manage load.

    aazizasp

    The problem started when I increased the worker process from 1 to 2 or 3 hoping to increase performance.  I get this random behavior. I run 3 or 4 different browsers and login to the web application using different IDs and every now and then I get redirected to the login page because the session is null. This happens only when I increased worker processes to above 1. Any ideas why it is doing that?

    You created what's called a web garden.  Basically, isolation between worker processes.  If you are using In-Proc Session then Worker process 1 cannot see Worker process 2's memory.  Again, don't store user credentials in Session.  Session has other performance issues as well.

    aazizasp

    The problem with leaving worker process to 1 is that it takes a while if I run multiple browsers at once for testing purposes. I noticed that one has to finish before the next one will finish. I thought that is because I have one worker process. 

    Yeah, that's does not sound right.  However, if you opened the same browser with the same Session cookie then yes that is the expected behavior.  The server must queue the requests due to Session.  This stops request 2 from changing Session while request 1 is running.

    aazizasp

    Any ideas thoughts or suggestions is greatly appreciated.

    Read the docs before arbitrary making configuration changes.  Use best practices for persisting user authentication like the built in membership API(s) provided by ASP.

    Monday, February 19, 2018 10:01 PM
  • User350923160 posted
    Hi mgebhard,
    Thanks for responding. I am using the session to store an id that i use to run queries with throught the application. It is not used for credentials. In fact my application is behind an access manager system that utilizes saml authentication. Basically once they authticate, i use for fill to populate the session variable and use it throughout the application. I hope this makes sense to you.
    Tuesday, February 20, 2018 12:58 AM
  • User475983607 posted

    Hi mgebhard,
    Thanks for responding. I am using the session to store an id that i use to run queries with throught the application. It is not used for credentials. In fact my application is behind an access manager system that utilizes saml authentication. Basically once they authticate, i use for fill to populate the session variable and use it throughout the application. I hope this makes sense to you.

    You are explaining the purpose for using Session which is irrelevant.  The fact that you are using session is what's causing the problems you are experiencing.   I would change the design and find a solution other than Session especially if you are using SAML. 

    Tuesday, February 20, 2018 11:28 AM