Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is sending email really that slow? In my experience, it just writes something to a local mail queue if your front ends can send email.


It can be that slow, yes. There is no assurances that will be fast, you're just hoping it will be.

Now you could argue "that's true of anything!" but in general you are forced to depend on local IO/CPU/RAM otherwise your site is struggling in general, by adding DNS/SMTP/etc you're just adding more "stuff" that your site relies upon.

Plus SMTP servers are "allowed" to go offline for short periods. The client should try to resend the email 2-4 additional times before giving up. Clearly a PHP script cannot do that.


I am totally confused. Who uses an SMTP server written in PHP? mail() just writes a bit of stuff into a mail queue by default.


People set their PHP config to connect to a remote SMTP server rather than a local queue.

It isn't something you can control in the code.


Thanks, I understand. Configuring PHP that way would be an unmitigated disaster. If you want that functionality, it makes the most sense to configure Exim or whatever to do that for you.


Yes it's slow in that it's a blocking call. Since it takes more than a fraction of a second put a message in the mail queue, it'll _feel_ slow.


I am trying to verify your claim:

    php -r '$s = microtime(1);mail("jcampbell1@gmail.com","test","text");printf("%d\n ms",(microtime(1)-$s)*1000);'
    > 20 ms
20 ms doesn't _feel_ slow. You spend far more time fetching the data and rendering the email.


Just realized I edited out (before I posted) my qualifcation for my statement, but it should've been prefaced as "from what I've noticed with no hard numbers."

The reason I assume that it has the feeling of being slow, from the applications I've had to clean up, is because many times there's processing happening right before the mail() function. So while, yes, its relatively fast the the total time is what feels slow.

And for comparison I've ran your commandline test as well with two of my cheap-o VPS instances, one of which is a Linode instance:

Linode: 50ms, 13ms, 14ms

Crappier VPS: 677ms, 149ms, 188ms


Yeah that one caught my eye in an otherwise good list too. Typically sending email via PHP's mail() function is only slow if your server is not configured correctly: http://www.alphadevx.com/a/372-Fixing-slow-performance-of-se...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: