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

Implement CPU and Memory runtime controls #8251

Closed
wants to merge 15 commits into from

Conversation

PineappleIOnic
Copy link
Member

@PineappleIOnic PineappleIOnic commented Jun 10, 2024

What does this PR do?

This PR implements CPU and Memory controls for Runtimes, adding new cpus and memory attributes onto the functions document and it's relevant API endpoints. _APP_FUNCTIONS_CPUS and _APP_FUNCTIONS_MEMORY are now utilised as the max amount of memory and CPUs that can be allocated to a function.

To be implemented

  • Plan Differentiators in API Parameters
  • Using _APP_FUNCTIONS_CPUS and _APP_FUNCTIONS_MEMORY as limiters and to reflect that in the API
  • Implementing the API in console
  • Fixing the issue we're having with TS Enums having numeric names
  • Implement Tests

Test Plan

  1. Create a function and execution then check it's stats
  2. Change the runtime memory, rebuild and check it's stats again
  3. Change the runtime CPU, rebuild and check it's stats one more time

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@PineappleIOnic PineappleIOnic marked this pull request as ready for review June 13, 2024 05:50
.env Outdated Show resolved Hide resolved
Comment on lines 413 to 414
cpus: $function->getAttribute('cpus', 1),
memory: $function->getAttribute('memory', 128),
Copy link
Contributor

Choose a reason for hiding this comment

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

Execution specs and build specs should remain different. We should either hard-code build specs (very high), or make it configurable separatelly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I hard-coded 2 cpu cores and 1024 memory, that should be enough right?

Comment on lines +148 to +155
->addRule('memory', [
'type' => self::TYPE_INTEGER,
'description' => 'Function execution memory limit in MB.',
'default' => 512,
'example' => 1024,
])
->addRule('cpus', [
'type' => self::TYPE_INTEGER,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's confirm with team lead.. Should this be integer, or string? If it's integer I would expect slider on Console. If it was string, I would expect select dropdown.
Same for developers using API, integer indicates I might be able to set it to anything. Using ENUM here might work better

Copy link
Member Author

@PineappleIOnic PineappleIOnic Jul 9, 2024

Choose a reason for hiding this comment

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

Enum will probably make more sense here, will update appropriately

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we add enums to models? I can't seem to see a self::TYPE_ENUM in the Model class

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, if we never did it, we can do STRING. Check what we did for plan in billing, I think that behaves as enum

Comment on lines -86 to -88
'cpus' => $this->cpus,
'memory' => $this->memory,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove those $this variables, they shouldn' be needed anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, done

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant those:

CleanShot 2024-07-10 at 09 16 16@2x

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, my bad. Fixing now

@PineappleIOnic
Copy link
Member Author

PineappleIOnic commented Jul 10, 2024

@Meldiron I think we should change the values in the .env to be 2 cores and 1024 memory so we can test changing it. Otherwise we won't be able to. Appwrite's listed minimum specs is 2 cpu cores and 4GB of memory so we should be fine here

@PineappleIOnic PineappleIOnic changed the base branch from main to 1.6.x July 10, 2024 07:59
@PineappleIOnic
Copy link
Member Author

Closing this to retarget it to 1.5.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants