Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: implement websocket compression setting (fixes #3292) #5928

Merged
merged 3 commits into from
Oct 12, 2020

Conversation

gahag
Copy link
Contributor

@gahag gahag commented Oct 5, 2020

Description

As discussed, the websocket package has a compression setting built-in.
This commit implements the wiring to allow such configuration through
the connection-compression command line flag, or the
HASURA_GRAPHQL_CONNECTION_COMPRESSION environment variable.

Changelog

  • CHANGELOG.md is updated with user-facing content relevant to this PR. If no changelog is required, then add the no-changelog-required label.

Affected components

  • Server

Related Issues

#3292

Solution and Design

As discussed, the websocket package has a compression setting built-in.
This commit implements the wiring to allow such configuration through
the connection-compression command line flag, or the
HASURA_GRAPHQL_CONNECTION_COMPRESSION environment variable.

Steps to test and verify

Run graphql with the compression flag, and send a big but low entropy string through a graphql client.

Limitations, known bugs & workarounds

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes
    • Does run_sql auto manages the new metadata through schema diffing?
      • Yes
      • Not required
    • Does run_sql auto manages the definitions of metadata on renaming?
      • Yes
      • Not required
    • Does export_metadata/replace_metadata supports the new metadata added?
      • Yes
      • Not required

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated:
    • New types and typenames are correlated

Breaking changes

  • No Breaking changes

  • There are breaking changes:

    1. Metadata API

      Existing query types:

      • Modify args payload which is not backward compatible
      • Behavioural change of the API
      • Change in response JSON schema
      • Change in error code
    2. GraphQL API

      Schema Generation:

      • Change in any NamedType
      • Change in table field names

      Schema Resolve:-

      • Change in treatment of null value for any input fields
    3. Logging

      • Log JSON schema has changed
      • Log type names have changed

As discussed, the websocket package has a compression setting built-in.
This commit implements the wiring to allow such configuration through
the `connection-compression` command line flag, or the
`HASURA_GRAPHQL_CONNECTION_COMPRESSION` environment variable.
@gahag gahag requested a review from a team as a code owner October 5, 2020 18:40
@hasura-bot
Copy link
Contributor

Beep boop! 🤖

Hey @gahag, thanks for your PR!

One of my human friends will review this PR and get back to you as soon as possible.

Stay awesome! 😎

@netlify
Copy link

netlify bot commented Oct 5, 2020

Deploy preview for hasura-docs ready!

Built with commit f559c00

https://deploy-preview-5928--hasura-docs.netlify.app

@mehtavishwa30 mehtavishwa30 changed the title implement websocket compression setting (fix #3292) (Server): Implement websocket compression setting (fixes #3292) Oct 6, 2020
@mehtavishwa30 mehtavishwa30 changed the title (Server): Implement websocket compression setting (fixes #3292) Server: Implement websocket compression setting (fixes #3292) Oct 6, 2020
@mehtavishwa30 mehtavishwa30 requested a review from a team October 6, 2020 04:33
@0x777 0x777 requested a review from abooij October 6, 2020 05:31
Copy link
Contributor

@abooij abooij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks for this PR, @gahag!

@0x777, do we want to have some kind of unit test for this? I suppose it might be difficult to integrate a test for this into our testing suite...

server/src-lib/Hasura/Server/Init.hs Outdated Show resolved Hide resolved
@gahag
Copy link
Contributor Author

gahag commented Oct 6, 2020

@lexi-lambda I've made a new commit with the suggested changes. Thanks for the review! Should I squash the two commits?

@gahag gahag requested a review from lexi-lambda October 7, 2020 20:46
@abooij
Copy link
Contributor

abooij commented Oct 8, 2020

@lexi-lambda I've made a new commit with the suggested changes. Thanks for the review! Should I squash the two commits?

You can leave the commits as-is, we usually squash the commits in a PR at merge time. Let's give Alexis some more time to have another look.

@abooij abooij changed the title Server: Implement websocket compression setting (fixes #3292) server: implement websocket compression setting (fixes #3292) Oct 8, 2020
Copy link
Contributor

@tirumaraiselvan tirumaraiselvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog

@kodiakhq kodiakhq bot merged commit 19b4f55 into hasura:master Oct 12, 2020
@hasura-bot
Copy link
Contributor

Beep boop! 🤖

GIF

Awesome work @gahag! All of us at Hasura ❤️ what you did.

Thanks again 🤗

@abooij abooij added the hacktoberfest-accepted Valid hacktoberfest PR label Oct 12, 2020
@mehtavishwa30
Copy link
Contributor

Hello @gahag!

Thanks so much for your contribution to Hasura OSS during the Hacktoberfest 2020! We'd love to send you some Hasura swag as a token of appreciation and you will be getting an email with the swag form shortly. ✨

@kokroo
Copy link

kokroo commented Jul 19, 2023

Compression on websockets doesn't seem to actually work anymore. The headers indicate that permessage-deflate is on, but the packets are still not compressed. After checking with wireshark, even with that header present, the frame size is the same as the length of the payload. Manually using the deflate tool shows that the text is 1000% compressible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/server Related to server hacktoberfest hacktoberfest-accepted Valid hacktoberfest PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants