.NET Windows Service - Architectural Decisions

心不动则不痛 提交于 2019-12-06 11:50:52

问题


I currently have a Windows Service which continually runs throughout the day. It has multiple threads which kick off:

  • tasks daily to update cache
  • tasks weekly to do cleanup
  • 24/7 task to import XML into SQL Server
  • tasks which run for around 12 hours per day kicking off a console application to manage ETL

The tasks are not the important part of this question but it gives you the idea that this Windows service has grown to be a monster. It manages the imports of somewhere in the region of 300 million records per day.

It is hectic, but it works.

This iteration of development is giving me a chance to review the service and possibly break it down so that it is more manageable. It is thought that this could be multiple services with one manager service - ideal if a component needs to be updated then the whole thing does not need to grind to a hault.

Does anyone have any experience with this? I am keen to hear about your approach because it is new territory for me.

I have read this SO post which touches on the topic.

Cheers.


回答1:


Your description sounds a lot like the thing I wrote about 2 years ago. A windows service which hosts addins and runs them in multithreaded environment. The architecture used is the .NET addin pipeline introduced in .NET 3.5 (System.AddIn-namespace). It works like a charm as I also integrated live/hot updates. It's so easy to implement new addins and just plug them in whenever I like. So I really recommend using this addin stuff.

See http://msdn.microsoft.com/en-us/library/cc175292.aspx for a quickstart.




回答2:


I've done something similar for our background services, there's basically a ServiceHost and "Servlets" which are loaded via appdomains so they don't impact each other.




回答3:


Why a service? Pretty much none of the things you do- except the 24/7 task for imports - are something I would do as a service.

I would use:

  • Either command line programs that get regularly scheduled, especially on the daily / weekly tasks
  • Or use SSIS and SQL Scheduler to schedule something.

The only thing that may justify a service is the 24/7 XML import - unless you can get away starting it, for example, every 5 minutes.



来源:https://stackoverflow.com/questions/3510854/net-windows-service-architectural-decisions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!