Skip to content

Streaming Encoding for LIST Responses #5116

Closed

Description

@serathius

Enhancement Description

Milestones:

Beta

Activity

  1. added
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Jan 31, 2025
  2. serathius commented on Jan 31, 2025

    @serathius
    MemberAuthor

    /sig api-machinery

  3. added
    sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.
    and removed
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Jan 31, 2025
  4. changed the title [-]Streaming Response Encoding[/-] [+]Streaming Encoding for LIST Responses[/+] on Jan 31, 2025
  5. chenk008 commented on Feb 7, 2025

    @chenk008
    Contributor

    I'm glad to see this proposal. We have also implemented similar capabilities in our inner repo and are preparing to push this part to upstream. We have submitted a CFP for the upcoming KubeCon China conference.

    In our implementation, we use sync.Pool to efficiently manage memory allocation and cache the serialized results of each item. When the buffer reaches a certain size, we execute a flush operation to parallelize the serialization processing and write to http2.

    Additionally, we have added support for gzip compression, which is only enabled when the first batch of cached data reaches 128 * 1024.

    For json serialization, we have customized the StreamMarshal method for unstructuredList.

    As for protobuf, we generate code through a generator to ensure reverse protobuf marshalling compatibility.

    type StreamMarshaller interface {
    	// return the object size and the item size slice
    	StreamSize() (uint64, []int)
    
    	StreamMarshal(w stream.Writer, itemSize []int) error
    }
    

    And it has conducted extensive testing with large datasets and have obtained comparative results. @yulongfang Can you share some benchmark results?

  6. yulongfang commented on Feb 8, 2025

    @yulongfang

    Thank @chenk008 for your introduction. We have many large-scale clusters in Alibaba Cloud. When the controllers of these large-scale clusters are restarted, they will initiate a full list request to the apiserver, which will have a certain impact on the stability of the cluster. We have to use larger machines to run the apiserver, resulting in a waste of resources.

    In this context, we adopted the method to carry out relevant optimization and achieved the following results.

    list json format return data stress test scenario description:

    • apiserver version: 1.30
    • apiserver specification: 32c 128GB
    • apiserver replica number: 1 replica
    • number of stock resources: build 10,000 100kb cr information
    • stress test scenario: increase pressure according to the gradient of qps 0.1 / 0.5

    list json format return data related stress test data:

    qps 0.05

    • before optimization: cpu 35.7 c mem 89Gb
    • stream json after optimization: cpu 6.22 c mem 60 Gb

    qps 0.1

    • before optimization: cpu 11 c mem 146Gb
    • stream json after optimization: cpu 7.45 c mem 97 Gb

    list protobuf Format Returned data Stress test scenario description:

    • apiserver version: 1.30
    • apiserver specification: 32c 128GB
    • apiserver replica number: 1 replica
    • Number of existing resources: Build 10,000 configmaps information of size 100kb
    • Stress test scenario: Increase pressure according to the gradient of qps 0.1 / 0.5

    list configmaps format Returned data Related stress test data:

    qps 0.05

    • Before optimization: cpu 16.8 c mem 54.3Gb
    • After stream json optimization: cpu 16.8 c mem 16.1 Gb

    qps 0.1

    • Before optimization: cpu 42 c mem 122Gb
    • After stream json optimization: cpu 42 c mem 18 Gb
  7. BenTheElder commented on Feb 12, 2025

    @BenTheElder
    Member

    FYI: Technical details are usually discussed in KEP PRs or elsewhere, with the KEP issue serving as a place to link back work.

    @chenk008 @yulongfang you might consider reviewing #5119

  8. serathius commented on Feb 13, 2025

    @serathius
    MemberAuthor

    Hey @chenk008 @yulongfang please see the previous discussion in kubernetes/kubernetes#129304 and kubernetes/kubernetes#129334.
    We also have already done a performance analysis of our changes in kubernetes/kubernetes#129304 (comment).

    We also added running a automatic benchmark of list requests. You can see the results in https://perf-dash.k8s.io/#/?jobname=benchmark%20list&metriccategoryname=E2E&metricname=Resources&Resource=memory&PodName=kube-apiserver-benchmark-list-master%2Fkube-apiserver

    We currently run it in JSON + configmap with RV="" configuration, hope to expand it to include Proto, Pods, CustomResources and other types of LIST request. Would be awesome if you can contribute.

  9. serathius commented on Feb 13, 2025

    @serathius
    MemberAuthor

    /milestone v1.33

  10. added this to the v1.33 milestone on Feb 13, 2025
  11. pacoxu commented on Feb 14, 2025

    @pacoxu
    Member

    @jpbetz @dipesh-rawat this is target to v1.33 and the KEP was merged.
    Should the lead-opted-in and tracked label be added and tracked by release team?

  12. dipesh-rawat commented on Feb 14, 2025

    @dipesh-rawat
    Member

    @serathius @pacoxu Unfortunately, the enhancement freeze deadline has passed, and this KEP issue was not lead-opted-in, so it wasn’t added to the tracking board for the v1.33 release. Post-freeze, we've disabled the automated sync job for KEP issues to the tracking board.

    To move forward, we’ll need a short exception request filed so the team can add the lead-opted-in label and manually include this in the tracking board.

    If you still wish to progress this enhancement in v1.33, please file an exception request as soon as possible, within three days. If you have any questions, you can reach out in the #release-enhancements channel on Slack and we'll be happy to help. Thanks!

    (cc v1.33 Release Lead @npolshakova)

  13. serathius commented on Feb 14, 2025

    @serathius
    MemberAuthor

    Ups, @jpbetz is OOO. @deads2k can you take a look?

  14. serathius commented on Feb 14, 2025

    @serathius
    MemberAuthor
  15. 58 remaining items

  16. yujen77300 commented on Jul 21, 2025

    @yujen77300
    Member

    Hello @serathius 👋, 1.34 Docs Shadow here. 
    Please take a look at Documenting for a release - PR Ready for Review to get your PR ready for review before Tuesday July 29th 2025 18:00 PST.
    Thank you!

  17. moved this from At risk for code freeze to Tracked for enhancements freeze in 1.34 Enhancements Trackingon Jul 22, 2025
  18. moved this from Tracked for enhancements freeze to At risk for code freeze in 1.34 Enhancements Trackingon Jul 22, 2025
  19. jpbetz commented on Jul 22, 2025

    @jpbetz
    Contributor

    Hi @fykaa, SIG API Machinery lead here. I just wanted to confirm this is code complete for code freeze. There are a couple PRs that were listed as "optional" that were listed under the stable graduation criteria. I've confirmed that there are not blocking and moved them out of the graduation criteria. This should not be good to go for code freeze.

  20. fykaa commented on Jul 23, 2025

    @fykaa

    @jpbetz your response makes it eligible to be tracked for code freeze!
    Thanks for the update!

  21. moved this from At risk for code freeze to Tracked for code freeze in 1.34 Enhancements Trackingon Jul 23, 2025
  22. rayandas commented on Sep 16, 2025

    @rayandas
    Member

    Hi @serathius 👋, v1.35 Enhancements Lead here.

    I am closing the v1.34 milestone now.

    If you'd like to work on this enhancement in v1.35, please have the SIG lead opt-in by adding the lead-opted-in label, which ensures it gets added to the tracking board. Also, please set the milestone to v1.35 using /milestone v1.35.

    Thanks!

    /remove-label lead-opted-in
    /remove-label tracked/yes
    /milestone clear

  23. removed this from the v1.34 milestone on Sep 16, 2025
  24. removed
    lead-opted-inDenotes that an issue has been opted in to a release
    tracked/yesDenotes an enhancement issue is actively being tracked by the Release Team
    on Sep 16, 2025
  25. k8s-triage-robot commented on Dec 15, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  26. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Dec 15, 2025
  27. serathius commented on Dec 16, 2025

    @serathius
    MemberAuthor

    Let's close and track followup separatly
    /close

  28. k8s-ci-robot commented on Dec 16, 2025

    @k8s-ci-robot
    Contributor

    @serathius: Closing this issue.

    Details

    In response to this:

    Let's close and track followup separatly
    /close

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.stage/stableDenotes an issue tracking an enhancement targeted for Stable/GA status

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy