Performance: SMTP Or Mail()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jafo
    Senior Member
    • Apr 2004
    • 278

    Performance: SMTP Or Mail()

    Are there any performance hits switching to SMTP over the mail() function in VB? We have a cluster of servers on our network and I was thinking about using just 1 for sending mail. Would this be significantly slower than using mail()?
  • kentaurus
    Senior Member
    • May 2000
    • 361
    • 3.6.x

    #2
    Originally posted by Jafo
    Are there any performance hits switching to SMTP over the mail() function in VB? We have a cluster of servers on our network and I was thinking about using just 1 for sending mail. Would this be significantly slower than using mail()?
    There could be a performance hit, since instead of the servers alternating on sending the email, one server would be dedicated to sending it.

    Here are some pointers:

    1. the mail() function may use internal pipes to call the sendmail process over the same server, this can be a little faster, although not for that much, than sending it over sockets on the network
    2. unless your cluster is a really weird setup, and assuming that all the servers are connected to the same switch, sending a mail over smtp would be really fast
    3. centralizing the mail sending could be a really really good idea, since you have only one failure point in the event that the mail is not relayed. Administration-wise, it is a good idea to have this
    4. Depending on the tool you are using for load-balancing (pen,pound,fcgi farm, something more?) you may be able to configure a lower load for the server dedicated to the mail process
    5. Security wise, you need to take extra steps to make sure that the smtp server you configure isn't open for relay and thus can't be used as a spam gateway, and that only your server cluster is able to send mail through it



    How big is your fourm? Unless you are sending thousands of emails most likely you won't see any performance penalty
    CemZoo Wiki - The complete anime encyclopedia
    CemZoo Foros - Spanish Anime & Gaming Community (also browse our archive)

    Comment

    • Jafo
      Senior Member
      • Apr 2004
      • 278

      #3
      We are sending out many thousands a day and have millions of posts.

      Right now we get spikes of traffic where we can have almost 20,000 users constantly hitting the refresh button over and over for up to 5 minutes to get certain information we release. This creates quite a load as you can imagine. We have put together many methods are reducing our load from the main httpd servers, and one technique is offloading duties to other servers that do not serve pages.

      Example, like many other large boards, we have separated our DB tasks from our httpd servers.

      We now want to offload all of the mail functions to another server that is not serving http, but just a utility server. It has always been my thought that making one server do the mail duties is better than all of them doing it.

      My only concern is, even though the connection is on the same switch, would there be any lag time due to the connections? Realize, when a few thousand users are banging on one server over and over in a minute, every little performance gain is a plus.

      Comment

      • Jafo
        Senior Member
        • Apr 2004
        • 278

        #4
        Since my apache servers are using Postfix, I decided to configure it to use the relay server instead:

        Code:
        relayhost = [123.255.123.5]
        The relay server is accepting mail from all servers on the LAN, and port 25 (SMTP) is blocked on the firewall. That should do it.

        I have a sneaky suspicion that the Mail() function is faster.

        Comment

        • kentaurus
          Senior Member
          • May 2000
          • 361
          • 3.6.x

          #5
          Originally posted by Jafo
          We are sending out many thousands a day and have millions of posts.

          Right now we get spikes of traffic where we can have almost 20,000 users constantly hitting the refresh button over and over for up to 5 minutes to get certain information we release. This creates quite a load as you can imagine. We have put together many methods are reducing our load from the main httpd servers, and one technique is offloading duties to other servers that do not serve pages.

          Example, like many other large boards, we have separated our DB tasks from our httpd servers.

          We now want to offload all of the mail functions to another server that is not serving http, but just a utility server. It has always been my thought that making one server do the mail duties is better than all of them doing it.

          My only concern is, even though the connection is on the same switch, would there be any lag time due to the connections? Realize, when a few thousand users are banging on one server over and over in a minute, every little performance gain is a plus.
          You would also want to play with the "batch email" configuration at the vbulletin options, it can either send the mail immediately, or queue it and send them in batch each n minutes defined by a vBulletin cron job

          offloading the mail could be indeed a good idea

          I have been under that scenario you described, 20,000 users hitting refresh, for that, instead of load balancing, a proxy cache is also a good solution, provided it is viable for you. A trill to have it setup properly but it works as it frees the server from any php processing
          CemZoo Wiki - The complete anime encyclopedia
          CemZoo Foros - Spanish Anime & Gaming Community (also browse our archive)

          Comment

          • Jafo
            Senior Member
            • Apr 2004
            • 278

            #6
            Originally posted by kentaurus
            You would also want to play with the "batch email" configuration at the vbulletin options, it can either send the mail immediately, or queue it and send them in batch each n minutes defined by a vBulletin cron job

            offloading the mail could be indeed a good idea

            I have been under that scenario you described, 20,000 users hitting refresh, for that, instead of load balancing, a proxy cache is also a good solution, provided it is viable for you. A trill to have it setup properly but it works as it frees the server from any php processing
            The only thing I do not like about batch email being setup by VB is that it uses Apache to execute the cron. Apache processes are precious to us and I would rather use them to serve data directly to client than perform background processing. Instead, I am going to set queue limits on the outgoing mail server to batch send. Since that server does not even run Apache, it will be perfect.

            We do perform some caching, but due to the content being so fluid and dynamic, it would be rather difficult to get a proxy cache to work properly under all circumstances. It is not a bad idea for just the one aspect of our site, but we have many other gadgets that really require us to have multiple balanced servers.

            To get back on point though, I just think letting the server do the mail processing with applications such as sendmail/procmail etc is probably less resource intensive than having PHP socket connect to an SMTP server and perfrom the send itself. The mail programs are running as daemons so no interpreting is needed and if configured to batch send, it can reduce the amount of open connections as it can send multiple emails to the relay host with one connect.

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...