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

Add AIBrix Custom Autoscaling Algorithm APA #223

Merged
merged 4 commits into from
Oct 5, 2024

Conversation

kr11
Copy link
Collaborator

@kr11 kr11 commented Sep 25, 2024

Pull Request Description

Besides the existing KPA (KNative) and HPA (Kubernetes native) autoscalers, this pull request introduces a preliminary implementation of our custom autoscaling solution, APA. This implementation is inspired by HCPA discussed in the paper HCPA.

image

  1. Unlike KPA, which relies on metrics from a historical window, APC(HCPA) uses real-time metrics and does not incorporate a panic mode. Instead, APA introduces a tolerance factor to manage fluctuations in metric values.
  2. Furthermore, we have enhanced the original HCPA concept by integrating logic for down-scaling, which was previously absent.

Remaining Issues

  1. RBAC in e2e Tests: The end-to-end tests for both KPA and APA depend on the /metric endpoint of a mocked deployment llama2, which requires sufficient RBAC permissions to access k8s replica information inside the container. As discussed in this conversation, these permissions were removed in a previous PR. Should we consider reverting that change?

  2. Code Duplication Between KPA and APA: There is significant overlap in the implementation for KPA and APA, particularly in areas like Spec definition, MetricClient, and the reconciling pipeline. For the time being, this PR introduces APA algorithm as a if-branch within the KPA scaling function. Please refer to the detailed discussion in issue [RFC] Design of Custom Autoscaling Algorithms for KPA and AIBrix #224 .

This PR is a work in progress, any feedback is highly appreciated.

Related Issues

Resolves: #224

Important: Before submitting, please complete the description above and review the checklist below.


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

@kr11 kr11 changed the title [WIP] Kangrong/features/autoscaling hpca [WIP] Add AIBrix Custom Autoscaling Algorithm APA Sep 25, 2024
@kr11 kr11 requested a review from Jeffwan September 25, 2024 12:56
//
// Huo, Qizheng, et al. "High Concurrency Response Strategy based on Kubernetes Horizontal Pod Autoscaler."
// Journal of Physics: Conference Series. Vol. 2451. No. 1. IOP Publishing, 2023.
func (k *KpaAutoscaler) APA_Scale(currentPodCount float64, currentUsePerPod float64, spec *DeciderKpaSpec) int32 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we create a separate autoscaler for APA?

return r.reconcileKPA(ctx, pa)
case autoscalingv1alpha1.APA:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's have some discussion here. I think we should create a new autoscaler. I understand some common parts have been implemented. We just need to figure out the long term plan. It looks good to me for short term

@@ -53,6 +53,54 @@ spec:
targetPort: 8000
nodePort: 30081
type: NodePort
---
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's create a separate service account this time

Copy link
Collaborator

Choose a reason for hiding this comment

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

I added a commit to address this change. 2a5b389

@varungup90 varungup90 force-pushed the main branch 2 times, most recently from 506a803 to d72a9c0 Compare October 2, 2024 23:10
@Jeffwan
Copy link
Collaborator

Jeffwan commented Oct 4, 2024

two remaining issues make a lot of sense.

RBAC in e2e Tests

Let's add it back. The reason I suggest to remove it in the last PR is we need a separate service account/role/rolebinding for it. Let's do not attach the role to the default service account

Code Duplication Between KPA and APA:

Let me take a look as well. Let's better abstract the algorithm and autoscaler part. it indeed has a lots of code can be reused

@Jeffwan Jeffwan force-pushed the kangrong/features/autoscaling_hpca branch from b58a21c to 2a5b389 Compare October 4, 2024 23:26
@Jeffwan Jeffwan changed the title [WIP] Add AIBrix Custom Autoscaling Algorithm APA Add AIBrix Custom Autoscaling Algorithm APA Oct 5, 2024
@Jeffwan Jeffwan merged commit a70c82d into main Oct 5, 2024
10 checks passed
@Jeffwan Jeffwan deleted the kangrong/features/autoscaling_hpca branch October 5, 2024 04:51
gangmuk pushed a commit that referenced this pull request Jan 25, 2025
* add apa algorithm

* Add HPCA algorithm as a implementation of APA

* fix make lint

* Add separate pod-autoscaler service account

---------

Co-authored-by: Jiaxin Shan <seedjeffwan@gmail.com>
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.

[RFC] Design of Custom Autoscaling Algorithms for KPA and AIBrix
2 participants