Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a bulk emailing service within the system which allows for a template to be used. When the mail is sent the template is parsed or run through a parser to replace tags with actual information. i.e "[Foo] has logged in" is parsed to "Bar has logged in"

Is it better to have 1 service for sending and parsing emails (concurrently), or to have 2 services, one which only checks for pending emails and parses them, and another which only sends emails who have already been parsed?

share|improve this question
1  
3 services, one to process emails, one to send them, and one to coordinate the work of the other 2. –  MattDavey Feb 14 '13 at 13:36

2 Answers 2

up vote 1 down vote accepted

There are two jobs to be done

  1. Preparing personalized mails based on a template and data-set
  2. Sending a mail to a recipient.

This asks for two services.
Because it is very common to do both jobs one immediately after the other, I would further arrange things such that the end-user only has to use one service:

  • either a third (convenience) service that encapsulates the two above
  • or the first service automatically invokes the second service
share|improve this answer
    
+1 for third service, although I would say there are 3 jobs to be done - the third job is coordinating the workflow... –  MattDavey Feb 14 '13 at 13:37
    
That's makes the most sense. Seperating them is good practice, and you can alternatively start using the parser service to parse more than emails (parse a report, or other communication type like sms) –  qminator Feb 15 '13 at 9:29

Unless I am missing some information I see no reason why you would need 2 services to do what you could do with 1. In fact, it may be easier to do it with one in case there are any resources they both share, could mean less code and/or memory used.

You could add more info to the question such as: What do you currently think would be the advantage to having 2 services instead of 1?

Then we can look at that and explain why 1 can handle that better, or we will see your reasoning and agree, yes you can't do that with only 1 service, etc.

share|improve this answer
    
The Parsing might require a lot of read operations, because the email doesn't necessarily send through all of the values from the start. Splitting it in 2, by my reasoning, would allow the service to send any mails which have been parsed or don't require them without having them queue for parsing if they don't need to, or having to wait for an email which might require a lot or read operations. –  qminator Feb 14 '13 at 12:28
    
@qminator In theory you should be able to use the same or less resources by writing one service as compared to two, considering there would be extra overhead for running as a second service, however it would be negligible I am sure. Either way with proper engineering you shouldn't be required to make a 2nd service for maximum performance, a single service should be able to be made to outperform two. –  ioSamurai Feb 17 '13 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.