How to integrate SlmQueueSqs and SlmMail into a ZF2 application?

1

I'm servicing an application developed in Zend Framework 2 and I need, in that order:

  • Send tasks to a queue in AWS SQS.
  • Process queue tasks through an application command that will use AWS SES.

I found two interesting components to do both of these tasks: SlmQueueSqs and SlmMail . However, because I do not have much practice with ZF2, I'm getting a little bit to implement these features.

What's been done so far:

  • The application sends e-mails in sync with the request; to avoid overloading the servers, I need to put the body of the email and the recipient in an SQS queue.
  • I customized the application with the AWS keys in the aws.local.php file.
  • I have loaded the required modules: Aws , SlmQueue and SlmQueueSqs .
  • I created the command that will run every minute to pick up the elements that are in the queue and trigger the emails via SES, but still lack integration with SES itself.

The necessary documentation is in the above links - however, because I do not have much practice to work with the ZF2 service container, I have not been able to follow them strictly so far.

    
asked by anonymous 29.03.2014 / 15:36

1 answer

1

It seems to me that the assumption that this solution will avoid overloading your server, is false. I'll try to explain it simply because this is a common mess.

To send messages to an Amazon email queue, you will overload your server to compose messages, connect to the server, and send the message.

If you use a local mail server (type sendmail / postfix / qmail), the effect is the same, because when you call the mail function, the message is not sent to the destination immediately. Usually the message goes to a local queue, and only later does the mail server try to send it.

In addition, when you connect to the Amazon server, you use a TCP / IP connection that is much slower than connecting to a local mail server, which is just a piped communication, , PHP takes much less time and CPU to put messages on the local server than to send to the Amazon queue server.

Now to send bulk email using PHP, it is possible to perform some optimizations that make the process take much less time and spend much less CPU on newer PHP versions, such as is explained in this article .

    
31.03.2014 / 13:45