iis - Host a service with 2 endpoints in the same or separate processes? -
i'm building microservice both synchronous rest endpoint (using webapi) , asynchronous publish/subscribe endpoint (using nservicebus on top of msmq) processing data stored in database shared these endpoints.
i'm trying decide if should host both endpoints in same process, or if should host them in separate processes , have them use database common ground pass data between these processes. gut feeling says same process 'better', although more complex:
hosting endpoints in separate processes simple: host webapi endpoint in iis , host nservicebus endpoint windows service.
when hosting them in same process, it's possible self-host nservicebus endpoint in webapi code not recommended iis shut down worker process after period of inactivity, thereby killing nservicebus part of service , leaving unable handle incoming messages.
figured have host both nservicebus , webapi endpoints in windows service, appears possible when using owin self-host webapi endpoint.
does have experience hosting service 2 endpoints in same or different processes, , can tell me problems/benefits associated choice?
(this question seemed ask same, never got satisfactory answer)
edit in response @hadieskandari, i'm not looking webapi facade nservicebus endpoint. i'm planning have webapi endpoint handle simple queries information stores in database shared between these endpoints. thse rest calls invoked ajax-style web application, need execute - forwarding each rest call through msmq queue nservicebus endpoint , waiting response seems slow , wasteful in case.
rather, i'm looking way keep data access code , business logic not in same assembly, in same appdomain both endpoints may share say, same configuration or cached data.
when hosting them in same process, it's possible self-host nservicebus endpoint in webapi code not recommended iis shut down worker process after period of inactivity
iis not shutdown process if set idletimeout 0 in application pool settings.
generally not recommended run background tasks(which in case is) in iis process there application domain recycle,application pool recyle settings things come picture. going windows service(selfhosted owin) right approach in opinion.
i have not worked on nservicebus cannot comment on problems part.but having looked @ nservice bus documentation,i can see recommended them .
Comments
Post a Comment