[Python-Dev] Investigating Python memory footprint of one real Web application
INADA Naoki
songofacandy at gmail.com
Fri Jan 20 05:49:01 EST 2017
Hi, all.
After reading Instagram's blog article [1], I’m thinking about how
Python can reduce memory usage of Web applications.
My company creating API server with Flask, SQLAlchemy and typing.
(sorry, it's closed source).
So I can get some data from it's codebase.
[1]: https://engineering.instagram.com/dismissing-python-garbage-collection-at-instagram-4dca40b29172#.lenebvdgn
Report is here
https://gist.github.com/methane/ce723adb9a4d32d32dc7525b738d3c31
My thoughts are:
* Interning (None,) seems worth enough.
* There are many empty dicts. Allocating ma_keys lazily may reduce
memory usage.
* Most large strings are docstring. Is it worth enough that option
for trim docstrings, without disabling asserts?
* typing may increase memory footprint, through functions
__attributes__ and abc.
* Can we add option to remove or lazy evaluate __attributes__ ?
* Using string literal for annotating generic type may reduce WeakRef usage.
* Since typing will be used very widely in this year. Need more
investigating.
More information about the Python-Dev
mailing list