phpmentoring / webapp

PHP Mentoring matching website
http://php-mentoring.org/
MIT License
46 stars 30 forks source link

Sending email may cause issues with SparkPost Slow responding #82

Open svpernova09 opened 8 years ago

svpernova09 commented 8 years ago

Convo from IRC this morning:

09:18 <Lamarus> is there something going on with the site?   I have been getting the same message over and over this morning.   https://cloudup.com/cWz3HtrfQo6
09:18 <Phergie> [http://u.gsc.io/16] Cloudup
09:20 <gchristensen> yikes...
09:20 <gchristensen> mfrost503_: are you doing phpmentoring dev? seems there is some spam or something.
09:21 <mfrost503_> gchristensen: is it coming from me? I haven't worked on phpmentoring stuff in a long time, like 2 years
09:22 <joepferguson> gchristensen: dragonmantank is leading that charge
09:22 <joepferguson> Lamarus: I haven't been getting that, but dragonmantank would be the one to debug
09:22 <joepferguson> afaik
09:23 <Lamarus> no problem.. i didnt know if there was an error coming up when someone sends a message or something like that
09:23 <Lamarus> error but still sending...
09:25 <joepferguson> Hrm checking our mail processor
09:25 <jonny> Assuming somebody isn't just spamming you.
09:25 <Lamarus> I dont think they are.. it was a legit request for help (i think)
09:26 <Lamarus> mail is taking forever to send after I hit "submit"
09:26 <jonny> With a subject of "sick hair cut"? :P
09:26 <Lamarus> ya... I just got a 504 when submitting the message back
09:27 <joepferguson> Hrm, everything looks good on spark post
09:27 <Lamarus> jonny ya.. i thought it was spam at first because of that... but it is my "cousin it" haircut
09:27 <Lamarus> joepferguson odd.... it does go to a 504 page when I submit a message
09:28 <Lamarus> hmm.. i just replied to yours just fine
09:28 <joepferguson> Odd..
09:28 <joepferguson> Maybe just slow response from SparkPost's api
09:29 <joepferguson> I bet we're not queueing the email
09:29 <Lamarus> it seems that way

We couldn't replicate it, but it's possibly caused by slow responses from SparkPost's API. Are we using any queue that we can drop the mail on instead of waiting for success from the API?

dragonmantank commented 8 years ago

The app currently doesn't use a queue to send the e-mail messages, it's doing it through straight SMTP through SwiftMailer.

My guess is that CloudFlare is throwing the 504 as it's sitting in front of the website, and the SMTP connection is taking just long enough sometimes to cause CloudFlare to think we've timed out. Since the process isn't actually dying the message is still sent (I've had this same thing happen on some providers like Rackspace CloudSites).

Short of setting up a queue and workers to process the e-mails, I'll see if there is anything to tweak. I think SparkPost has an API but that will take some work on the app to get it off of straight SMTP.