Closed Bug 1082557 Opened 10 years ago Closed 10 years ago

Use a persistent connection to the SMTP server for improved performance

Categories

(Bugzilla :: Email Notifications, defect)

4.5.6
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 5.0

People

(Reporter: LpSolit, Assigned: LpSolit)

References

Details

(Keywords: perf)

Attachments

(1 file)

I did some profiling, and using a persistent connection to the SMTP server is 25% faster (with 4 recipients in my testing) to deliver bugmails, because you don't need to establish a new connection and authenticate again and again for each bugmail.
Attached patch patch, v1Splinter Review
Attachment #8504727 - Flags: review?(dylan)
All of my installs run as CGI, so I can't confirm the performance improvement just yet. It passed visual inspection & does seem to send email.
I need a mod_perl setup anyway I suppose.

One other thing I would like to understand is how Email::Sender::Transport::SMTP::Persistent handles random disconnections.
(In reply to Dylan William Hardison [:dylan] from comment #2)
> All of my installs run as CGI, so I can't confirm the performance

No, mod_perl doesn't matter here. I wrote it such that you create one single connection to the SMTP server and use it to send all bugmails. Once all bugmails are sent, the connection is closed. When another user edits a bug, a new connection is created again. This is *much* more efficient than creating a new connection for each bugmail (imagine a bug with 20 recipients: you have only one connection to send 20 bugmails instead of 20 connections).


> I need a mod_perl setup anyway I suppose.

No need, as said above. The connection is per request, not per process, i.e. Bugzilla->request_cache instead of Bugzilla->process_cache. The reason is that I don't think it's a good idea to let the connection to the SMTP server opened for too long.


> One other thing I would like to understand is how
> Email::Sender::Transport::SMTP::Persistent handles random disconnections.

It reconnects automatically.
Comment on attachment 8504727 [details] [diff] [review]
patch, v1

Review of attachment 8504727 [details] [diff] [review]:
-----------------------------------------------------------------

Right! request_cache is obviously per request, not per process.
I additionally tested this with jobqueue turned on & and it worked.

r=dylan
Attachment #8504727 - Flags: review?(dylan) → review+
Flags: approval?
any reason why this can't be in the process_cache instead of per-request?
Flags: needinfo?(LpSolit)
(In reply to Byron Jones ‹:glob› from comment #5)
> any reason why this can't be in the process_cache instead of per-request?

As I said in comment 3:

"The reason is that I don't think it's a good idea to let the connection to the SMTP server opened for too long."

Microsoft sets the default timeout in IIS 6.0 to 10 minutes for SMTP. As they say: "Connection timeouts help reduce the amount of memory resources that are consumed by idle connections."

And I think there is no reason to keep the connection opened as we don't know when the next bugmails will be sent.
Flags: needinfo?(LpSolit)
Flags: approval? → approval+
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   b1bdb0e..7ce5b04  master -> master
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: