The OctopusDSC package uses the PowerShell Invoke-WebRequest
and Invoke-RestMethod
commands to communicate with the Octopus server. Out of the box, these do not request any compression on the response, but the header can be explicitly included; if the result is gzip-compressed, it will automatically decompress the result.
Some of the endpoints on the Octopus server that the DSC resources access can be large - for example, our /machines/all
endpoint returns over 1 MB of JSON. With gzip enabled, that compresses down to only 64 KB over the wire.
It would be nice if the DSC code were updated to request gzip-compressed responses to reduce the amount of traffic we’re sending over the network. The Tentacle resource hits that /machines/all
endpoint each time DSC runs. Multiply that by 600+ Tentacles, and that’s a lot of network traffic every 15-30 minutes.
$results = Invoke-WebRequest -Uri $apiEndpoint -Headers @{"X-Octopus-ApiKey"="$APIKey"; "Accept-Encoding"="gzip"} -UseBasicParsing
If the Octopus server doesn’t support gzip for some reason, it would just ignore the header and send an uncompressed response like it does now.
Hi @andrew.timson ,
Thank you for contacting Octopus Support.
I’m going to pass this request along to our development team. However, I recommend also logging this request on our UserVoice forum here: https://octopusdeploy.uservoice.com/
I can definitely see how this would save bandwidth in your situation. We really appreciate suggestions like this that help us continue to improve Octopus.
If there is anything else we can assist with, please let us know.
Regards,
Donny
Hi @andrew.timson ,
I just wanted to respond with a quick update.
It looks like we have a PR in to get this addressed. You may follow along here:
OctopusDeploy:master
← OctopusDeploy:mattr/use-gzip
opened 03:57AM - 08 Jun 21 UTC
Requested by customer https://help.octopus.com/t/octopusdsc-use-gzip-when-talkin… g-to-octopus-server/26766
Comparing download responses:
### Old
```
$nonCompressedResults = Invoke-WebRequest -Uri https://example.octopus.app/api/machines/all -Headers @{"X-Octopus-ApiKey"="API-XXX"; } -UseBasicParsing
```
```
PS > $nonCompressedResults.Headers
Key Value
--- -----
Date {Tue, 08 Jun 2021 05:56:12 GMT}
Transfer-Encoding {chunked}
Connection {keep-alive}
Vary {Accept-Encoding}
Cache-Control {private}
Access-Control-Allow-Credentials {true}
Access-Control-Allow-Headers {cache-control, content-type, x-http-method-override, X-Octopus-Data-Version, X-Octopus-Authorization-Hash, X-Octopus-ApiKey, X-Octopus-Csrf-Token, X-Octopus-User-Agent, X-MiniProfiler-Ids}
Access-Control-Allow-Methods {GET, PUT, POST, DELETE, OPTIONS}
Access-Control-Allow-Origin {*}
Access-Control-Expose-Headers {X-Octopus-Data-Version, X-Octopus-Authorization-Hash, Octopus-Node}
Server-Timing {total;dur=45}
Content-Security-Policy {default-src 'none'; connect-src https://octopus.com https://capture.trackjs.com https://telemetry.octopus.com 'self'; font-src 'self'; img-src data: https://usage.trackjs.com https://www.gravatar.com 'sel…
Octopus-Node {name=octopus-<snip>; version=2021.2.4391}
Referrer-Policy {no-referrer}
X-Content-Type-Options {nosniff}
X-Frame-Options {DENY}
X-XSS-Protection {1; mode=block}
X-Robots-Tag {noindex, nofollow}
Strict-Transport-Security {max-age=15724800; includeSubDomains}
Content-Type {application/json; charset=utf-8}
Allow {GET}
Expires {Mon, 07 Jun 2021 05:56:12 GMT}
```
### New
```
$compressedResults = Invoke-WebRequest -Uri https://example.octopus.app/api/machines/all -Headers @{"X-Octopus-ApiKey"="API-XXX"; "Accept-Encoding"="gzip"} -UseBasicParsing
```
gives:
```
PS > $compressedResults.headers
Key Value
--- -----
Date {Tue, 08 Jun 2021 05:56:19 GMT}
Transfer-Encoding {chunked}
Connection {keep-alive}
Cache-Control {private}
Vary {Accept-Encoding}
Access-Control-Allow-Credentials {true}
Access-Control-Allow-Headers {cache-control, content-type, x-http-method-override, X-Octopus-Data-Version, X-Octopus-Authorization-Hash, X-Octopus-ApiKey, X-Octopus-Csrf-Token, X-Octopus-User-Agent, X-MiniProfiler-Ids}
Access-Control-Allow-Methods {GET, PUT, POST, DELETE, OPTIONS}
Access-Control-Allow-Origin {*}
Access-Control-Expose-Headers {X-Octopus-Data-Version, X-Octopus-Authorization-Hash, Octopus-Node}
Server-Timing {total;dur=44}
Content-Security-Policy {default-src 'none'; connect-src https://octopus.com https://capture.trackjs.com https://telemetry.octopus.com 'self'; font-src 'self'; img-src data: https://usage.trackjs.com https://www.gravatar.com 'sel…
Octopus-Node {name=octopus-<snip>; version=2021.2.4391}
Referrer-Policy {no-referrer}
X-Content-Type-Options {nosniff}
X-Frame-Options {DENY}
X-XSS-Protection {1; mode=block}
X-Robots-Tag {noindex, nofollow}
Strict-Transport-Security {max-age=15724800; includeSubDomains}
Content-Type {application/json; charset=utf-8}
Allow {GET}
Content-Encoding {gzip}
Expires {Mon, 07 Jun 2021 05:56:19 GMT}
```
Note the additonal
```
Content-Encoding {gzip}
```
Once that is pushed to master, be sure to check for a new version of OctopusDSC here:
PowerShell Gallery | OctopusDSC 4.0.1055
If you have any questions, please let us know.
Regards,
Donny
system
(system)
Closed
9 July 2021 20:23
6
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.