google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

Lower memory overhead

Open pnico opened this issue 2 years ago • 1 comments

Just importing many of these libraries has memory overhead that is large enough to cause problems in production especially in memory-constrained environments such as F1 instances.

Appengine customers are being directed to use these libraries for everything, including simply for getting app logs that are correlated per request (even though it's almost as easy to do this without using the python-logging library at all). Ideally this would be fine, but unfortunately the libraries are not designed in a way that allows selective or lazy imports, if you import one thing you bring in most of the library. If this increased memory overhead causes your instances to be killed, you might then need to increase the instance size and consequently your application's operating costs.

The discovery-based API client is being neglected on purpose, with long-standing bugs remaining unfixed, presumably to encourage everyone to use these libraries instead. We would like to use them, but we can't because they use too much memory.

https://github.com/googleapis/python-logging/issues/623#issuecomment-1532913477

pnico avatar May 09 '23 13:05 pnico

I didn't intend this issue to be specifically about lazy imports, that was just one of the possible things I mentioned that might address the memory overhead issue. My intention here was just to point out the memory overhead.

If you are planning on implementing lazy loading in any case, feel free to link this issue with the one you make for that.

pnico avatar Jun 22 '23 07:06 pnico