I've read a ton of articles about this topic but just can't get to an conclusion so i'd like to hear anyone that has a real experience with problems like this.
The problem
I need 'something' that will send request to a certain URL, parse the results and update database based on the results. The task should be ran every few minutes.
There are a few possible solutions but anything with the Timer within asp.net app or the expiring cache option is off the table since it's important for it to be as reliable as possible.
Two solutions left are: do a Windows service (with a timer implementation) or do a console app and put it into Windows Task Scheduler.
I'm opened to anything that's better.
My main concern is reliability of the solution. Nothing else is important.
PS.
DB update job is nothing heavy. It would never last for more than 1-2 seconds. The only thins important is that it's being ran every 2 minutes for example and that I can rely on that as much as possible.
Please share your real-life experience with situations like this.
Thanks in advance.
well, what my experiece says is to go with window service, i agree same thing is possible with scheduled tasks, but when it comes to the reliebility my vote goes to windows service. a real exmaple is: a typical SQL, .NET keep running services are windows
services, you can not find them on scheduled tasks.
windows services can be manual, automatic etc. you can specify them with which user you want them to run, do they need automatic startup when system boots etc.
this is whay my saying, you can find many nice tutorials that says something different, have a look into it:
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
Marked as answer by deezg on Apr 01, 2012 09:35 AM
if it's every minute or so then you can opt for a windows service. If it's only a couple of times per day windows task schedular in combination with a console application would be an alternative.
If you're already going to do something with a database you might also want to consider using SQL Server Agent which is a dedicated windows service on its own shipping with SQL Server which you can have scheduled tasks. Actually if you would host session
state in SQL Server this service runs every minute to make sure that all out of date sessions get removed from the database.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Marked as answer by deezg on Apr 01, 2012 09:35 AM
Interesting, that is one of the articles i've read last days. And, that one says: A Windows Service is the wrong solution to scheduling one-off custom processes. The right solution for scheduling simple processes is the Windows Task Scheduler.
Now, from what I understand, Windows services are 'thingies that help other thingies'. Meaning, it's purpose is to serve other processes.
On the contrary, scheduled tasks are tasks performed when some time conditions are met. Run & Close.
Obviously, what comes out as a criteria where to draw the line between Services and Scheduled tasks is the running frequency. Is it an hour? Half an hour? Minute? Where would you draw the line?
Additionaly, when you say windows service is more reliable, could you please elaborate a bit why do you say so? (I'm not saying it isn't, i just don't know and would like to get all infos possible to help me make the decision which road to take)
PS.
Please note that I'm not biased to any solution.
if it's every minute or so then you can opt for a windows service. If it's only a couple of times per day windows task schedular in combination with a console application would be an alternative.
It will be a few tasks, some of them will be ran more often some of them less, but it's definitively much closer to the order of magnitude of minutes than hours. So, it's 1-5 minutes frequency, never just once a day. So i guess that means windows services
road.
So, you're suggesting windows service with custom timer implementation and ordinary timer_elapsed handling within it?
XIII
If you're already going to do something with a database you might also want to consider using SQL Server Agent which is a dedicated windows service on its own shipping with SQL Server which you can have scheduled tasks. Actually if you would host session state
in SQL Server this service runs every minute to make sure that all out of date sessions get removed from the database.
Never hurd of this solution. I'll have to digg about that one a bit.
I don't host session states on SQL, nevertheless anything that does the job is an option. So, i'll take a look at that one too.
Btw, is that solution good for parsing XML in HTTP response, for example?
Btw, is that solution good for parsing XML in HTTP response, for example?
Never tried that but one can enable the CLR features of SQL Server so you can host your own .NET assemblies in there and call them like functions. That in combination with SQL Server Agent might get you where you want.
deeZG
I don't host session states on SQL
I mentioned it as an example that Microsoft also makes use of this approach.
Another reason that you might want to make use of the Agent is that not all hosters allow you to install a custom windows service on their servers. Agent is a default windows service that can be installed with SQL Server and it's Microsoft supported.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Marked as answer by deezg on Apr 01, 2012 10:03 AM
Never tried that but one can enable the CLR features of SQL Server so you can host your own .NET assemblies in there and call them like functions. That in combination with SQL Server Agent might get you where you want.
Wow, this is a great info! Thanks!
Will definitively look into that one.
XIII
Another reason that you might want to make use of the Agent is that not all hosters allow you to install a custom windows service on their servers. Agent is a default windows service that can be installed with SQL Server and it's Microsoft supported.
I haven't mentioned it, i'm sorry.
I have my own server so i can access&install anything i need.
@deeZG - On that link about Windows Task Scheduler vs Windows Service, make sure to read through some of the user comments as well to get some of the arguments (for/against) the article. It definitely has a valid point, but it was also written 7 years ago
and was probably based on Windows Server 2000 or 2003. I have used both (console apps w/ scheduled tasks and Windows Services) and I prefer the Windows Services on Windows Server 2008. I have had no problems at all (doesn't mean they do not happen, just it's
a stable choice if implemented properly), and the robust hosting model provides a lot of fine grained control. It's not a 'one-size-fits-all', but I wouldn't rule out Windows Services strictly on that 1 post.
You can look at some high level points on using a Windows Service in th article below:
Thank you very much for your response. I definitively agree with you about not taking things for granted, especially not the posts on Internet (made by anyone, including me :) ). There really isn't one-size-fit's-all solutions.
After a research I came to the same conclusion - that Windows services are the solution for my thing. The main reason for choosing Windows service was short timespan (in minutes) and one more thing: services are ideal model for me to implement custom timespans
(put settings in DB by third app and then have auto-adjustable timers [or whatever] in service).
Putting it all together, i did a service today and so far - it works like a charm.
deeZG
Member
4 Points
5 Posts
Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 08:41 AM|LINK
Hello to all!
I've read a ton of articles about this topic but just can't get to an conclusion so i'd like to hear anyone that has a real experience with problems like this.
The problem
I need 'something' that will send request to a certain URL, parse the results and update database based on the results. The task should be ran every few minutes.
There are a few possible solutions but anything with the Timer within asp.net app or the expiring cache option is off the table since it's important for it to be as reliable as possible.
Two solutions left are: do a Windows service (with a timer implementation) or do a console app and put it into Windows Task Scheduler.
I'm opened to anything that's better.
My main concern is reliability of the solution. Nothing else is important.
PS.
DB update job is nothing heavy. It would never last for more than 1-2 seconds. The only thins important is that it's being ran every 2 minutes for example and that I can rely on that as much as possible.
Please share your real-life experience with situations like this.
Thanks in advance.
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 08:54 AM|LINK
well, what my experiece says is to go with window service, i agree same thing is possible with scheduled tasks, but when it comes to the reliebility my vote goes to windows service. a real exmaple is: a typical SQL, .NET keep running services are windows services, you can not find them on scheduled tasks.
windows services can be manual, automatic etc. you can specify them with which user you want them to run, do they need automatic startup when system boots etc.
this is whay my saying, you can find many nice tutorials that says something different, have a look into it:
http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
XIII
All-Star
182707 Points
23464 Posts
ASPInsiders
Moderator
MVP
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 09:00 AM|LINK
Hi,
if it's every minute or so then you can opt for a windows service. If it's only a couple of times per day windows task schedular in combination with a console application would be an alternative.
If you're already going to do something with a database you might also want to consider using SQL Server Agent which is a dedicated windows service on its own shipping with SQL Server which you can have scheduled tasks. Actually if you would host session state in SQL Server this service runs every minute to make sure that all out of date sessions get removed from the database.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
deeZG
Member
4 Points
5 Posts
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 09:05 AM|LINK
Thank you very much for your answer.
Interesting, that is one of the articles i've read last days. And, that one says:
A Windows Service is the wrong solution to scheduling one-off custom processes. The right solution for scheduling simple processes is the Windows Task Scheduler.
Now, from what I understand, Windows services are 'thingies that help other thingies'. Meaning, it's purpose is to serve other processes.
On the contrary, scheduled tasks are tasks performed when some time conditions are met. Run & Close.
Obviously, what comes out as a criteria where to draw the line between Services and Scheduled tasks is the running frequency. Is it an hour? Half an hour? Minute? Where would you draw the line?
Additionaly, when you say windows service is more reliable, could you please elaborate a bit why do you say so? (I'm not saying it isn't, i just don't know and would like to get all infos possible to help me make the decision which road to take)
PS.
Please note that I'm not biased to any solution.
Thank you very much for your response.
deeZG
Member
4 Points
5 Posts
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 09:18 AM|LINK
It will be a few tasks, some of them will be ran more often some of them less, but it's definitively much closer to the order of magnitude of minutes than hours. So, it's 1-5 minutes frequency, never just once a day. So i guess that means windows services road.
So, you're suggesting windows service with custom timer implementation and ordinary timer_elapsed handling within it?
Never hurd of this solution. I'll have to digg about that one a bit.
I don't host session states on SQL, nevertheless anything that does the job is an option. So, i'll take a look at that one too.
Btw, is that solution good for parsing XML in HTTP response, for example?
Thank you for your response!
XIII
All-Star
182707 Points
23464 Posts
ASPInsiders
Moderator
MVP
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 09:45 AM|LINK
Hi,
Never tried that but one can enable the CLR features of SQL Server so you can host your own .NET assemblies in there and call them like functions. That in combination with SQL Server Agent might get you where you want.
I mentioned it as an example that Microsoft also makes use of this approach.
Another reason that you might want to make use of the Agent is that not all hosters allow you to install a custom windows service on their servers. Agent is a default windows service that can be installed with SQL Server and it's Microsoft supported.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
deeZG
Member
4 Points
5 Posts
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 01, 2012 10:04 AM|LINK
Wow, this is a great info! Thanks!
Will definitively look into that one.
I haven't mentioned it, i'm sorry.
I have my own server so i can access&install anything i need.
All i care about is reliability.
atconway
All-Star
16846 Points
2756 Posts
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 02, 2012 08:10 PM|LINK
@deeZG - On that link about Windows Task Scheduler vs Windows Service, make sure to read through some of the user comments as well to get some of the arguments (for/against) the article. It definitely has a valid point, but it was also written 7 years ago and was probably based on Windows Server 2000 or 2003. I have used both (console apps w/ scheduled tasks and Windows Services) and I prefer the Windows Services on Windows Server 2008. I have had no problems at all (doesn't mean they do not happen, just it's a stable choice if implemented properly), and the robust hosting model provides a lot of fine grained control. It's not a 'one-size-fits-all', but I wouldn't rule out Windows Services strictly on that 1 post.
You can look at some high level points on using a Windows Service in th article below:
Running a Periodic Process in .NET using a Windows Service
deeZG
Member
4 Points
5 Posts
Re: Windows service vs Scheduled Tasks (every few minutes)
Apr 02, 2012 11:00 PM|LINK
@atconway
Thank you very much for your response. I definitively agree with you about not taking things for granted, especially not the posts on Internet (made by anyone, including me :) ). There really isn't one-size-fit's-all solutions.
After a research I came to the same conclusion - that Windows services are the solution for my thing. The main reason for choosing Windows service was short timespan (in minutes) and one more thing: services are ideal model for me to implement custom timespans (put settings in DB by third app and then have auto-adjustable timers [or whatever] in service).
Putting it all together, i did a service today and so far - it works like a charm.