Skip to content

Invoke-RestMethod does not perform HTTP connection pooling #13109

Closed

Description

@xtqqczze

The Invoke-RestMethod cmdlet since PowerShell 6 does not perform HTTP connection pooling.

The behaviour in Windows PowerShell 5.1 was to perform connection pooling, so there is a performance regression in PowerShell Core.

This issue was discovered in #12764.

Steps to reproduce

While running a packet capture, compare execution of the following with execution under Windows PowerShell 5.1:

(Measure-Command {
    (1..100).ForEach{
        Invoke-RestMethod -Uri "https://postman-echo.com/get?i=$_"
    }
}).TotalSeconds

Expected behavior

A single HTTP connection is used for all requests, as was the case in Windows PowerShell 5.1.

Actual behavior

A new HTTP connection is opened for every request and a TLS handshake is perfomed for each request, resulting in much worse performance than Windows PowerShell 5.1.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jul 5, 2020
  2. iSazonov commented on Jul 6, 2020

    @iSazonov
    Collaborator

    Why duplicate #12764?

  3. xtqqczze commented on Jul 6, 2020

    @xtqqczze
    ContributorAuthor

    Ilya (@iSazonov) There was a lot of unrelated discussion and misleading information in #12764 so I thought it would be good to open a new issue with a clear description of the issue, is this not the way?

  4. iSazonov commented on Jul 6, 2020

    @iSazonov
    Collaborator

    xtqqczze That would be nice, but most of the issues are similarly confusing. Since we have already a conclusion in #12764 we can close current issue.

  5. xtqqczze commented on Jul 6, 2020

    @xtqqczze
    ContributorAuthor

    Ilya (@iSazonov) I will close this issue, perhaps you could edit the title of #12764 for clarity?

  6. ghost closed this as completedon Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-DuplicateThe issue is a duplicate.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions