Are there performance impacts to using gzip for web services

compressiongzipweb services

I have a very typical scenario:

browser -> web server -> web service

I've seen lots of articles/documentation about the benefit of compressing the data sent from the web server to the browser to save bandwidth, but I'm wondering if there are similar benefits to compressing the data between the web service and the web server?

XML should compress very small, so of course we'd get the same benefits in terms of bandwidth, but I'm specifically wondering if that will be offset by the processing power needed on the web server, to decrypt the SOAP messages that it receives.

Has anyone enabled gzip for web services, and has there been any performance improvement?

For that matter, will web service clients even understand gzip in the first place? Or would enabling encryption be a waste of time, that would never never be taken advantage of by the web service client?

Best Answer

The question comes down to what does your server have to spare -- CPU or bandwidth? If you're constantly waiting for the network but your CPU is idle, then you probably should be looking into compression. If your CPU is busy but you're not sending much data, then compression probably isn't for you.

XML is a very verbose (and more importantly, repetitive) language, so compression will probably make a decent difference in the amount of data transmitted.

Compression is only useful if both sides support it, otherwise flipping the switch will do nothing. Advertising that you support compression makes very little difference if compression isn't ever actually used.

Finally, it's not necessarily all-or-nothing if you're the one transmitting. Gzip compression (LZ77) is tunable to optimize for speed, size, or something in between. How that tuning is done depends on your implementation, but only the side SENDING the data gets to decide. Decompressing gzip'ed data that is highly compressed takes no more resources than decompressing data that was only lightly compressed, so the recipient shouldn't care anyway.