3 ms·
I'd argue a lot of web apps are just serializing to json, after doing minimal business logic that likely has to do db requests. Once again, I said to look at w
by ehutch79 4y ago
I'd argue a lot of web apps are just serializing to json, after doing minimal business logic that likely has to do db requests.
Once again, I said to look at what your load actually is. If you're CPU bound, then yes, buy a bigger instance, optimize, or switch languages.
It's like how if you are putting up a blog, you probably shouldn't be looking at running kubernetes clusters for just that blog.
- skrtskrt 4y agoYeah I’ve profiled slow Python apps before and it’s almost always serialization that’s the sticking point. Default implementation of date parsing in particular is really bad
- PathOfEclipse 4y agoYou might be surprised to find out how CPU-intensive even something as simple as a DB request can be. Your driver has to do the work of communicating with the DB server via its protocol, which is similar in cost to any other network request. More importantly, it has to deserialize the result and marshal the data into objects on the managed heap. Most DB drivers don't support streaming, so for larger requests you have to read all the data into memory, then convert it all into objects at once. And that's not even taking into account frameworks and ORMs like Hibernate, which itself can multiply the CPU used several-fold on top of JDBC, or whatever lower-level interface it wraps. I've never measured frameworks in dynamic languages, but I have no reason to believe they aren't similarly inefficient. And, yes, one of the optimizations I did for my reverse proxy app was to upgrade the JSON library, which brought a significant performance boost. But it's not the only source of CPU usage for apps, nor was it the only major optimization I successfully applied.