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?

  • 1
    3 services, one to process emails, one to send them, and one to coordinate the work of the other 2.
    – MattDavey
    Feb 14, 2013 at 13:36

2 Answers 2


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
  • +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, 2013 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, 2013 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.

  • 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, 2013 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.
    – MetaGuru
    Feb 17, 2013 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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