Reuse TCP connections between successive mailer jobs
In gitlab.com SaaS, we use GCP Cloud NAT for all internet egress. We observe high NAT port utilization from sidekiq VMs, often correlating high NAT error rates (due to port exhaustion) with high rates of error in the mailers queue. We've started to suspect that the high port demand is due to TCP connection churn to gitlab.com's mail provider, as successive ActionMailer jobs might be opening and closing TCP connections.
Would it be possible to configure the mail client to reuse TCP connections between successive sidekiq jobs that run on the same sidekiq worker process, where possible? This might only be possible within each thread, but that might still make a big impact.
See https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/10629, and issues linked there, for some more context.