Skip to content

Conversation

vittoriasalim
Copy link
Contributor

@vittoriasalim vittoriasalim commented Jul 14, 2025

This PR introduces a POST request scenario to kperf aimed at measuring the latency associated with mutating operations, specifically the creation of Kubernetes resources. The purpose is to evaluate the performance impact of mutation during resource creation.

TODO: replace body with resource template for efficiency (in next PR)

Example Use Case

  requests:
    - post:
        version: v1
        resource: pods
        namespace: kperf
        body: |
          {
            "apiVersion": "v1",
            "kind": "Pod",
            "metadata": {
              "name": "test-mutation"
            },
            "spec": {
              "containers": [
                {
                  "name": "fake-container",
                  "image": "fake-image"
                }
              ]
            }
          }
      shares: 1000

Issue

When totalRequests is greater than 1, the API server receives multiple create requests, which may result in the same resource being created more than once.

Result

kperf -v 10 runner run --kubeconfig $KUBECONFIG --config /mnt/c/Users/vsalim/Documents/kperf/contrib/internal/manifests/loadprofile/test_mutation.yaml
I0714 14:20:16.954555   76388 loader.go:395] Config loaded from file:  /home/vitto/kubeconfig_kperf.yaml
I0714 14:20:16.956968   76388 schedule.go:117] "Setting" clients=10 connections=10 rate=10 total=1 duration=0 http2=true content-type="json"
I0714 14:20:16.957014   76388 request.go:1351] Request Body: {
  "apiVersion": "v1",
  "kind": "Pod",
  "metadata": {
    "name": "test-mutation"
  },
  "spec": {
    "containers": [
      {
        "name": "pause",
        "image": "k8s.gcr.io/pause:3.1"
      }
    ]
  }
}
I0714 14:20:16.957038   76388 schedule.go:74] Request URL: https://kperf-hlyucs88.hcp.rojy1hd8x.e2e.azmk8s.io:443/api/v1/namespaces/kperf/pods
I0714 14:20:16.957093   76388 round_trippers.go:466] curl -v -XPOST  -H "Accept: application/json, */*" -H "User-Agent: kperf/v0.0.0 (linux/amd64) kubernetes/$Format" -H "Authorization: Bearer <masked>" 'https://kperf-hlyucs88.hcp.rojy1hd8x.e2e.azmk8s.io:443/api/v1/namespaces/kperf/pods?timeout=1m0s'
I0714 14:20:16.969043   76388 round_trippers.go:495] HTTP Trace: DNS Lookup for kperf-hlyucs88.hcp.rojy1hd8x.e2e.azmk8s.io resolved to [{135.237.215.71 }]
I0714 14:20:17.230079   76388 round_trippers.go:510] HTTP Trace: Dial to tcp:135.237.215.71:443 succeed
I0714 14:20:17.850664   76388 round_trippers.go:553] POST https://kperf-hlyucs88.hcp.rojy1hd8x.e2e.azmk8s.io:443/api/v1/namespaces/kperf/pods?timeout=1m0s 201 Created in 893 milliseconds
I0714 14:20:17.850763   76388 round_trippers.go:570] HTTP Statistics: DNSLookup 11 ms Dial 260 ms TLSHandshake 307 ms ServerProcessing 312 ms Duration 893 ms
I0714 14:20:17.850799   76388 round_trippers.go:577] Response Headers:
I0714 14:20:17.850832   76388 round_trippers.go:580]     Audit-Id: e519cb66-b3a3-4849-b2b7-7be4ea456c57
I0714 14:20:17.850845   76388 round_trippers.go:580]     Cache-Control: no-cache, private
I0714 14:20:17.850873   76388 round_trippers.go:580]     Content-Type: application/json
I0714 14:20:17.850880   76388 round_trippers.go:580]     X-Kubernetes-Pf-Flowschema-Uid: 158b0756-e88c-42e8-a324-8df387410d8f
I0714 14:20:17.850884   76388 round_trippers.go:580]     X-Kubernetes-Pf-Prioritylevel-Uid: 10eb2f20-020e-4695-a814-2c338ec738d4
I0714 14:20:17.850890   76388 round_trippers.go:580]     Content-Length: 1924
I0714 14:20:17.850894   76388 round_trippers.go:580]     Date: Mon, 14 Jul 2025 04:20:17 GMT
{
  "total": 1,
  "duration": "893.987676ms",
  "totalReceivedBytes": 1924,
  "percentileLatencies": [
    [
      0,
      0.893889171
    ],
    [
      0.5,
      0.893889171
    ],
    [
      0.9,
      0.893889171
    ],
    [
      0.95,
      0.893889171
    ],
    [
      0.99,
      0.893889171
    ],
    [
      1,
      0.893889171
    ]
  ],
  "percentileLatenciesByURL": {
    "https://kperf-hlyucs88.hcp.rojy1hd8x.e2e.azmk8s.io:443/api/v1/namespaces/kperf/pods?timeout=1m0s": [
      [
        0,
        0.893889171
      ],
      [
        0.5,
        0.893889171
      ],
      [
        0.9,
        0.893889171
      ],
      [
        0.95,
        0.893889171
      ],
      [
        0.99,
        0.893889171
      ],
      [
        1,
        0.893889171
      ]
    ]
  }
}

@xinWeiWei24
Copy link
Contributor

Using parameter configuration may be more readable and user-friendly than providing an entire request body.

@vittoriasalim vittoriasalim marked this pull request as draft July 16, 2025 23:53
@vittoriasalim vittoriasalim marked this pull request as ready for review July 17, 2025 02:55
@vittoriasalim
Copy link
Contributor Author

We will make POST and DELETE operations as one, as per this discussion. A new PR will be opened once the adjustments are made.

@vittoriasalim vittoriasalim deleted the add_POST branch August 6, 2025 04:54
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.

3 participants