How to integrate Slmqueuesqs and Slmmail into a ZF2 application?

Asked

Viewed 90 times

1

I am maintaining an application developed in Zend Framework 2 and accurate, in that order:

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

I found two interesting components to do these two tasks: the Slmqueuesqs and the Slmmail. However, because I don’t have much practice with ZF2, I’m picking up a bit to implement these features.

What has been done so far:

  • The application sends emails in sync with the request; to avoid overloading the servers, I need to place the body of the email and the recipient in an SQS queue.
  • I customized the application with the AWS keys in the file aws.local.php.
  • I’ve had the necessary modules uploaded: Aws, SlmQueue and SlmQueueSqs.
  • I created the command that will run every minute to take the elements that are in the queue and fire the emails via SES, but still missing integration with the SES itself.

The necessary documentation is in the links above - however, because I haven’t had much practice working with the ZF2 service container, I haven’t been able to follow them to the letter so far.

  • I do not know if your question is valid because it is too vague and does not indicate a specific problem to solve.

1 answer

1

It seems to me that the assumption that this solution will avoid overloading your server is false. I will try to explain simply why this is a common confusion.

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

If you use a local email server (sendmail/postfix/qmail type), 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 the email server tries to send.

In addition, when you connect to the Amazon server, you use a TCP/IP connection that is much slower than the connection to the local email server which is just inter-process communication (Pipes)that is, PHP takes much less time and CPU to place messages on the local server than to send them to the Amazon queue server.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.