Swift Mailer Support Thread (Split from Source)
Moderator: General Moderators
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Swift has a timeout on the SMTP connection in fsockopen(). It's 30 seconds, but there's a setter for it in versions 1.2+.akreider wrote:I don't have a good example. If I remember correctly, it's when I run the thing through a web-service (using nusoap). If I don't use the close command then I get a nusoap timeout error, even when i'd just try to send one email. But it worked fine when I'd use the close() command.
I should mention that I'm using version 1.0.0
Timeouts are driving me crazy. Apparently I've got seperate timeouts for
1) php
2) nusoap
3) apache (or so i've heard, I don't know if this is true)
(Does Swift Mailer have any timeouts of its own?)
PHP I've got figured out.
NuSOAP - I've got a pending question to the NuSOAP email list. I've been waiting two weeks for a response.
Apache - I guess I'll look into this.
I want to have my script run for two hours, so I can email people every five seconds (and I want to do it using a web-service - aka via nusoap). The every five seconds is so that my host doesn't kill me. Maybe I should just send a web-service every ten emails, instead of the One Big Web Service.
Or if someone does some benchmarking (and/or optimizing) and its possible to send several emails per second without killing my host, i'd love to do that! I've done some experimenting, and so far it doesn't look like a safe idea. Server load increases too quickly.
I suggest you upgrade from 1.0 by the way. There have been some significant changes that make it worth switching.
I'm not familiar with NuSOAP I'm afraid.
Benchmarking
I'm trying to benchmark this on my shared host using the sendmail connector. The biggest problem is that I have a hard time telling what impact I'm having on the server, compared to that of everyone else.
I've got access to uptime(), for server load, and ps - to get an idea of which processes are running. For instance, I'll compare uptime from before I ran the script, to during, and then after.
I'm trying to benchmark sending a batch of 10 emails. I'm wondering whether I need a 1, 2, 5 or 0 second delay between the emails -- because I plan to send multiple batches of 10 emails (around 80 batches). Alternatively I might have the delay between the batches, and zero delay between emails.
I'm wondering if benchmarking will be accurate if I send all the emails to the same address and they have the same text? Otherwise I could setup 10 random email addresses and use random text - but that's more work. I don't want to bother my legitimate users with floods of test emails =)
I'm trying to benchmark this on my shared host using the sendmail connector. The biggest problem is that I have a hard time telling what impact I'm having on the server, compared to that of everyone else.
I've got access to uptime(), for server load, and ps - to get an idea of which processes are running. For instance, I'll compare uptime from before I ran the script, to during, and then after.
I'm trying to benchmark sending a batch of 10 emails. I'm wondering whether I need a 1, 2, 5 or 0 second delay between the emails -- because I plan to send multiple batches of 10 emails (around 80 batches). Alternatively I might have the delay between the batches, and zero delay between emails.
I'm wondering if benchmarking will be accurate if I send all the emails to the same address and they have the same text? Otherwise I could setup 10 random email addresses and use random text - but that's more work. I don't want to bother my legitimate users with floods of test emails =)
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It shouldn't make any difference if you send 10 to the same address rather than to 10 addresses. The SMTP server will still process each request in turnakreider wrote:Benchmarking
...
I'm wondering if benchmarking will be accurate if I send all the emails to the same address and they have the same text? Otherwise I could setup 10 random email addresses and use random text - but that's more work. I don't want to bother my legitimate users with floods of test emails =)
What are you benchmarking it against? Just make sure you keep the same timings on both tools you try against each other. Oh, and maybe use the latest version for the most optimizations. A 1 second delay between emails is plenty slow enough, even mail() can manage that
EDIT | How do you plan on sending your batch? I'm curious what your plans are the get the delay since I only see that possible bu using a foreach loop one email at a time (or by making a "sleep" plugin..). It's faster and less memory intensive to let swift do the batch sending by passing it an array (swift caches data locally after the first mail is sent).
For benchmarking, I'm comparing Switch to itself, and comparing Switch to running nothing (to see the impact on CPU).
I'm having a hard time making sense of my results. It seems like I might need a 20 second delay between sending batches of 10, otherwise my server load goes from 8 to 12. The server is supposed to be fast too (one of those dual processors with several GB of RAM).
I'm sending the emails one at a time because they are customized to the user's location. I could try to group a quarter or half of my users into regions (it'd make sense to do so only for large cities) and then I could give everyone in that area the same email, but creating the regions would be messy and make the messages less personalized so I'd rather not do it.
I think my server is using sendmail to call exim - does this make sense? Because when I run it, I get a couple calls to sendmail that seem to spawn several exim processes with my username.
When looking at the ps() results, I never see sendmail using any significant resources (mostly 0.0% on memory and cpu), whereas exim uses more resources (up to 30% cpu -- though this probably isn't for my processes - I cannot really tell what it's for because it is running as "mailnull" or "root").
I'll do some more benchmarking. Might try comparing to mail() too.
Aaron
I'm having a hard time making sense of my results. It seems like I might need a 20 second delay between sending batches of 10, otherwise my server load goes from 8 to 12. The server is supposed to be fast too (one of those dual processors with several GB of RAM).
I'm sending the emails one at a time because they are customized to the user's location. I could try to group a quarter or half of my users into regions (it'd make sense to do so only for large cities) and then I could give everyone in that area the same email, but creating the regions would be messy and make the messages less personalized so I'd rather not do it.
I think my server is using sendmail to call exim - does this make sense? Because when I run it, I get a couple calls to sendmail that seem to spawn several exim processes with my username.
When looking at the ps() results, I never see sendmail using any significant resources (mostly 0.0% on memory and cpu), whereas exim uses more resources (up to 30% cpu -- though this probably isn't for my processes - I cannot really tell what it's for because it is running as "mailnull" or "root").
I'll do some more benchmarking. Might try comparing to mail() too.
Aaron
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It sounds like sendmail is merely a symlink to exim. That's what exim recommend in their manual pages.
I think it's time I wrote a template callback plugin to do things like you're doing during batch sending since a couple of replaces will likely be faster than rebuilding entire mails. The MTA will show usages on your process list yes if you're sending a batch through it. This is perfectly normal. I'll be interested to see how you work out what is Swift memory usage and what is from other processes since I need to do some of these tests myself also
I think it's time I wrote a template callback plugin to do things like you're doing during batch sending since a couple of replaces will likely be faster than rebuilding entire mails. The MTA will show usages on your process list yes if you're sending a batch through it. This is perfectly normal. I'll be interested to see how you work out what is Swift memory usage and what is from other processes since I need to do some of these tests myself also
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
FYI: Finally on SF.net after their long delay with all the backlogs.
Theres a mailing list and bug tracking set up via SF.
http://sourceforge.net/projects/swiftmailer/
Theres a mailing list and bug tracking set up via SF.
http://sourceforge.net/projects/swiftmailer/
Tentatively I'm not noticing a significant improvement using Swift Mailer compared to using mail.
I haven't been able to get Swift Mailer to work reliably without causing server load spikes, unless I put a big delay between batches of ten emails. Currently I'm using a 30 second delay. 20 seconds is ok if the server load is low, but the server load is generally around 9 (whereas tech support claims 10 is too high).
Swift Mailer does produce less processes than using mail. However all of the processes appear, in the ps() list, to not be using serious computer resources. It's just a lot of 0.0/0.0 percent of CPU/Mem (which could be because 1/1000 of say 3GB of memory is a lot of memory, so these scripts could use up to 1.4 mb of memory and be listed as 0.0%).
I don't think generating each email is causing me trouble - at least on my end. I run a couple mysql queries which probably take 0.1 seconds or less per email.
I haven't been able to get Swift Mailer to work reliably without causing server load spikes, unless I put a big delay between batches of ten emails. Currently I'm using a 30 second delay. 20 seconds is ok if the server load is low, but the server load is generally around 9 (whereas tech support claims 10 is too high).
Swift Mailer does produce less processes than using mail. However all of the processes appear, in the ps() list, to not be using serious computer resources. It's just a lot of 0.0/0.0 percent of CPU/Mem (which could be because 1/1000 of say 3GB of memory is a lot of memory, so these scripts could use up to 1.4 mb of memory and be listed as 0.0%).
I don't think generating each email is causing me trouble - at least on my end. I run a couple mysql queries which probably take 0.1 seconds or less per email.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
When you say a server load of ten do you mean 10.0 (as in 1000%) or do you mean 10% ? You ideally don't even want to go over 1.0 but that fluctuates in any case 
Do you know where the memory is being used? Is it in the sendmail process or in PHP?
If you could PM me a `ps' list I'd be very greatful, cheers
Do you know where the memory is being used? Is it in the sendmail process or in PHP?
If you could PM me a `ps' list I'd be very greatful, cheers
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Yeah, make sure you get the right version 
yeah, i installed the right now and I got:
The mailer failed to connect. Errors: Array ( [0] => Array ( [num] => 0 [time] => 0.89771800 1150410124 [message] => Connection to the given MTA failed. The Connection Interface said: No such file or directory ) ) . Log: Array ( ) Array ( )
But my smtp server is running. Postfix.
Cause if i type telnet localhost 25 I get respond.
The mailer failed to connect. Errors: Array ( [0] => Array ( [num] => 0 [time] => 0.89771800 1150410124 [message] => Connection to the given MTA failed. The Connection Interface said: No such file or directory ) ) . Log: Array ( ) Array ( )
But my smtp server is running. Postfix.
Cause if i type telnet localhost 25 I get respond.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Can you post the code please? I'm confused by the SMTP connection returning an error to do with files/directoriesNiGHTFiRE wrote:yeah, i installed the right now and I got:
The mailer failed to connect. Errors: Array ( [0] => Array ( [num] => 0 [time] => 0.89771800 1150410124 [message] => Connection to the given MTA failed. The Connection Interface said: No such file or directory ) ) . Log: Array ( ) Array ( )
But my smtp server is running. Postfix.
Cause if i type telnet localhost 25 I get respond.