-3

I want to send Email and SMS in bulk in c# MVC. So, method would be better, cron in a web application or separate scheduler service for it?

I have a web application running already. So, should I integrate the cron in the web app itself or create a new scheduler service for it.

I want to use the best method in terms of reliability, speed and load of data.

Rahul Mahadik
  • 794
  • 11
  • 19
  • 1
    "should I integrate the cron in the web app "...what do you even mean by this? cron is a Linux/Unix program which schedules the execution of jobs on a timed basis. It's a completely separate program. If your server is running windows you won't even _have_ cron available (although you will have Windows Scheduled Tasks, which is pretty much equivalent). – ADyson May 22 '18 at 11:02
  • 1
    Generally speaking you can either make a separate Windows Service application to handle this, or if it's more trivial, make a simple console app which is triggered by a Windows Scheduled Task, or use an extension to MVC such as Hangfire which allows scheduling of jobs (there are others, you can google them easily). What's "best" is almost entirely subjective and is something you, perhaps in conjunction with a software architect, have to determine based on your business and operational requirements (and contraints), and about which we, reading your question, know almost nothing. – ADyson May 22 '18 at 11:03
  • I mean cron by adding 3rd party dlls to the app like hangfire etc. I have seen this in many projects too. – Rahul Mahadik May 22 '18 at 11:08
  • 1
    ok well please use the correct terminology then so that we are all clear what you mean. Cron is a piece of software, not a concept. Anyway yes that's one of your options. You have to assess your requirements and choose what suits your situation. We can't make that decision for you because we don't have enough info, and at some point it may just come down to preference for a particular design pattern or style which you / your organisation mandates or is simple more familiar with. Other factors might be e.g. you want to send mail out of multiple apps, then don't integrate it into one MVC app – ADyson May 22 '18 at 11:13
  • 1
    As for performance / reliability, all the solutions I listed are common and well known, you shouldn't find much issue with reliability. Performance depends on many many different factors, but you can always build two different prototypes and test them against your data to see if it makes any significant difference. Personally I suspect the method by which you choose to trigger these tasks will not be a major factor in the performance of the task itself (which is, after all, the important thing) - in all cases, the actual task itself will remain the same, after all. – ADyson May 22 '18 at 11:14

1 Answers1

1

its better to make separate service for that for the below reasons :

1- Maintainability : If there is a problem in sending mails or SMS you know where you need to check without going to your main solutions.

2- Availability & Scalability : You can scale this Module only or if any thing happens to your main app, your mailing and sms will still be working.

3- Separation of Concerns : SMS and Emailing is considered to be a cross cutting functionality that it will be used in alot of places in system, so it is better to have it in one separate place.

4- I/O latency : like this you will avoid any latency or any performance effects on your main business domain.

Hany Habib
  • 1,377
  • 1
  • 10
  • 19