Replies: 1 comment 4 replies
-
I'm not sure if this is what you're looking for, but tomchristie, the creator of the django rest framework, wrote this article about performance. https://www.dabapps.com/insights/api-performance-profiling-django-rest-framework/ Just out of curiosity, is the latency of the ModelSerializer significantly slower than other operations like database connections, sql queries, etc? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi folks,
I was working on optimizing the performance of a small(ish) project we have in production and found out that most of our computing time is spent in ModelSerializers. I've made some isolated benchmarks and found out that ModelSerializers are pretty pretty slow when compared to Serializers, roughly 3 to 6 times slower, depending on the method of measuring.
I've looked through issues and discussions to see if someone has done research and optimization work before but have not found much. I understand that ModelSerializers involve more runtime magic, but is this 3 to 6 fold difference in speed realistic?
I've had a brief look using a profiler but found no obvious low hanging fruits (other than sometimes using
except
clause on the happy path depending on the use case).Given the maturity of DRF I'd be surprised to be the first one looking into this, but I have some time available for having a closer look. Any advice or pointers would be appreciated.
(I am aware that caching might be a way to optimize for performance, but in our case responses are dynamically generated for pretty much all requests. And of course rewriting to plain Serializers is still an option, but hoping that we don't have to go down that path.)
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions