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

Fix proxy slowdown with intercepted HTTPS requests #6705

Merged
merged 8 commits into from
Mar 11, 2020

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Mar 11, 2020

User facing changelog

  • Fixed a regression introduced in v3.8.3 where HTTPS requests could experience slowdown.

Additional details

  • in 3.5.0 Error: write EPROTO 3343909432:error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL:../../third_party/boringssl/src/ssl/handshake_client.cc:569: #5446, we set the TLS minimum version to TLSv1
  • however, this also caused slowdowns in the proxy, which are visible in the server-performance-specs if you look before and after this got merged
  • all intercepted (not passthru) HTTPS connections were affected
  • this PR makes it so that minVersion is set to TLSv1 only if the initial connection failed with a TLS version mismatch error
  • this PR also fixes the proxy_performance_spec
    • previously, the heuristics it was using were way too loose, and also easy to misunderstand
    • now, it's as simple as "our proxy should never be more than 3x as slow as regular Chrome, under any conditions"
    • 4.5x for the case where our proxy goes through another HTTPS upstream proxy
  • also noticed that requests that used an HTTPS upstream were slower - after adding setNoDelay(true), they are slightly faster, though not as fast as requests with an HTTP upstream

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue been tagged with a release in ZenHub?
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 11, 2020

Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.

  • Please write [WIP] in the title of your Pull Request if your PR is not ready for review - someone will review your PR as soon as the [WIP] is removed.
  • Please familiarize yourself with the PR Review Checklist and feel free to make updates on your PR based on these guidelines.

PR Review Checklist

If any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'.

User Experience

  • The feature/bugfix is self-documenting from within the product.
  • The change provides the end user with a way to fix their problem (no dead ends).

Functionality

  • The code works and performs its intended function with the correct logic.
  • Performance has been factored in (for example, the code cleans up after itself to not cause memory leaks).
  • The code guards against edge cases and invalid input and has tests to cover it.

Maintainability

  • The code is readable (too many nested 'if's are a bad sign).
  • Names used for variables, methods, etc, clearly describe their function.
  • The code is easy to understood and there are relevant comments explaining.
  • New algorithms are documented in the code with link(s) to external docs (flowcharts, w3c, chrome, firefox).
  • There are comments containing link(s) to the addressed issue (in tests and code).

Quality

  • The change does not reimplement code.
  • There's not a module from the ecosystem that should be used instead.
  • There is no redundant or duplicate code.
  • There are no irrelevant comments left in the code.
  • Tests are testing the code’s intended functionality in the best way possible.

Internal

  • The original issue has been tagged with a release in ZenHub.

@cypress
Copy link

cypress bot commented Mar 11, 2020



Test summary

6966 0 97 0


Run details

Project cypress
Status Passed
Commit 7c7a0ed
Started Mar 11, 2020 9:11 PM
Ended Mar 11, 2020 9:18 PM
Duration 06:49 💡
OS Linux Debian - 10.0
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@flotwig flotwig force-pushed the issue-6659-https-proxy-slowdown branch from 85c6688 to c7041e2 Compare March 11, 2020 19:23
@flotwig flotwig changed the title [WIP] Fix proxy slowdown with intercepted HTTPS requests Fix proxy slowdown with intercepted HTTPS requests Mar 11, 2020
@flotwig
Copy link
Contributor Author

flotwig commented Mar 11, 2020

Used this script to play with minVersion outside of Cypress:

/* eslint-disable no-console */
const _ = require('lodash')
const Bluebird = require('bluebird')
const rp = require('request-promise')
const { Agent } = require('https')

const test = async () => {
  await Bluebird.delay(500)

  let agent = new Agent({ keepAlive: false })

  console.time('making 100 https requests')
  await Bluebird.all(_.times(100, async () => {
    await rp('https://weeny.chary.us/static/5MB.zip', { agent, gzip: false })
  }))

  console.timeEnd('making 100 https requests')

  await Bluebird.delay(500)

  agent = new Agent({ keepAlive: false })
  agent.createConnection = function (options, cb) {
    options.minVersion = 'TLSv1'
    cb(null, Agent.prototype.createConnection.call(agent, options))
  }

  console.time('making 100 https requests with minVersion = TLSv1')
  await Bluebird.all(_.times(100, async () => {
    await rp('https://weeny.chary.us/static/5MB.zip', { agent, gzip: false })
  }))

  console.timeEnd('making 100 https requests with minVersion = TLSv1')
}

Bluebird.mapSeries(_.times(1), test)

brian-mann
brian-mann previously approved these changes Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Network requests taking a long time to complete
2 participants