I have an optimization question in the realm of "before I do something
foolish..." regarding the contextFactory passed to twisted.web.client.Agent.
I have (several) twisted applications running on a Cortex-A5 system, one of
which interfaces with a web service using the twisted.web.client.Agent
problem I've observed is that requests to this web service result in a higher
than desired CPU load. To understand the source of the load I isolated the
server interactions and profiled.
The profile data revealed the load in question stemmed from TLS related
calls, specifically optionsForClientTLS, which is called once per connection.
In looking (briefly) at what optionsForClientTLS does, it seemed
that there was an opportunity for optimization in my specific case.
The optimization is to create a custom contextFactory that caches the connection
creator since the host is not changing. I prototyped an implementation and the
load was reduced by a factor of ten.
Is it safe/sane to reuse a connection creator if the host to which I'm
not going to change?
* Technically this code is inside an open source third party SDK, but were I in
their shoes I'd write it the same way, so I've no issues with their