11

I am trying to find difference between inproc and outproc in c#. If I have a dll running on the server and my question is will it run in both inproc and outproc? Performance-wise which process is better?

Rashmi Pandit
  • 23,230
  • 17
  • 71
  • 111
Coder0997
  • 232
  • 2
  • 3
  • 14
  • 6
    Wow, this is a very broad topic, with a lot of "it depends". An important difference is that code that runs in-proc can call each others methods in the same address space. If it is out-proc there needs to be marshalling of parameters and the crossing of process space boundaries, which cost time and cpu. – Richard Jul 23 '13 at 18:02

2 Answers2

20

An inproc server runs in the same process as the calling application. It's close to a normal function call on a dll. Calling an outproc server, data needs to be marshalled across the process boundry which is an expensive operation. An inproc server is fast but it can bring down your application.

tzerb
  • 1,433
  • 1
  • 16
  • 35
  • 1
    What do you mean by "bring down your application" ? Can you be more specific? Are we talking session, or logging? I don't see where the OP specified. If logging, then I'm assuming what you mean is that if the log operation fails, then it can crash the entire app, but how is that any different than out proc? – Sinaesthetic Sep 22 '15 at 19:40
  • I think he means something similar to if the outproc server runs out of memory, it will crash but the program itself will stay alive and can restart it. Eg std::vector is fast but uses the stack/heap of the container process, and if it runs out of memory, the whole program crashes, but if you wrap it in an outproc server, the container program stays alive. – Dmytro Jan 18 '17 at 21:06
14

From MSDN

ASP.NET session state supports several different storage options for session data. Each option is identified by a value in the SessionStateMode enumeration. The following list describes the available session state modes:

InProc mode, which stores session state in memory on the Web server. This is the default.

StateServer mode/OutProc, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

Custom mode, which enables you to specify a custom storage provider. Off mode, which disables session state.

Ehsan
  • 31,833
  • 6
  • 56
  • 65