Wednesday, 13 February 2019

How to increase express compression middleware bandwidth?

Hi,I'm writing a rather simple express.js server to serve mongodb documents to my frontend. I'm using the compression middleware to send the json.Originally I was quite happy with this because the amount of data was small. But now my db got more documents and sometimes the uncompressed file size of the response is 50-80 MB. The middleware brings this down to below 5 MB which is great, but at the same time, the bandwidth suffers a lot.When I don't use the compression middleware, my server sends me files at 3 to 4 MB per second. With the compression middleware, the server sends only at 50 to 200 KB per second. Overall due to the reduced file size, the compressed transmission still finishes faster, but not by a lot and I would love to speed it up instead of waiting for data for half a minute.I've played around with the compression level and memory usage setting, but reducing the compression level only increases bandwidth by about 10% while making files a lot larger, so not quite worth it.Are there any other ways to make this faster? I've read that I should put nginx in front of node and let it handle the compression. Would that actually be faster?Would a hardware upgrade solve this? Currently the server is using an intel g4400 (2c/2t), 16 GB DDR4 ram and an SSD. Is the underlying zlib compression profiting from multiple cores? CPU usage isn't even shown as high actually :/I'm out of ideas. We also have a server on aws, using the same conpression middleware and it sends stuff super fast.

Submitted February 13, 2019 at 05:45PM by Type-21

No comments:

Post a Comment