Hello!
On Tue, May 19, 2015 at 8:47 PM, Hamish Forbes wrote:
> I'm seeing issue where the trusted CA cert file seems to be loaded into
> memory for every server {} block defined with an SSL listen.
Yes, the OpenSSL context is per-server according to the current
implementation. So this is the expected behavior.
> As you can see ~60 ssl server blocks ends up using ~60MB per worker with a
> 770KB CA bundle.
> Also HUP'ing the master process approximately doubles the worker memory
> usage.
> It also makes workers very slow to startup.
>
The HUP thing should just be an artifact of (temporary) memory
fragmentation. Try keeping sending HUP to see if the memory grows
infinitely. It shouldn't be the case.
> This doesn't seem to happen on OS X,
Maybe different OpenSSL version? Or just OS X is better on handling
memory fragmentation in this very specific case?
> A little background, we need to terminate many different SSL hostnames via
> SNI on this server hence ~60 server blocks.
Seems like it's something you really need ssl_certificate_by_lua instead:
We have WAY more different SSL certificate/private-key pairs on each
production box with just a single server {} block in nginx.conf at
CloudFlare.
> We also need to proxy to HTTPS endpoints with the Lua tcp cosocket API and
> want to be able to verify these endpoints.
> As such lua_ssl_trusted_certificate is pointed at the OS's CA cert bundle
> (/etc/pki/tls/cert.pem on Redhat systems) with is around 770KB.
>
Also, try reducing the default root CA cert bundle to the minimum is
also a good idea. But as mentioned above, I really think you should
avoid so many server {} blocks in nginx.conf in the first place.
> Is this expected behaviour or a bug?
This is the expected behavior over all :)
> If expected is there anything we can do to work around it other than
> reducing the size of the trusted certs bundle?
>
See above. Regarding reducing the trusted cert bundle, you can
re-generate such bundles yourself by removing ones you don't really
need. Having said that, try combining your 60 server {} blocks into a
single one with ssl_certificate_by_lua first :)
Regards,
-agentzh
P.S. I'm very sorry for the late reply. I've been on vacation in China.