Skip to content

aws-ecs: Support MaxSwap and Swappiness in LinuxParameters #18460

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

Closed
2 tasks
joelchen opened this issue Jan 16, 2022 · 4 comments · Fixed by #18703
Closed
2 tasks

aws-ecs: Support MaxSwap and Swappiness in LinuxParameters #18460

joelchen opened this issue Jan 16, 2022 · 4 comments · Fixed by #18703
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@joelchen
Copy link

joelchen commented Jan 16, 2022

Description

Please support MaxSwap (https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/cfnspec/spec-source/specification/000_cfn/000_official/000_AWS_ECS.json#L975) and Swappiness (https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/cfnspec/spec-source/specification/000_cfn/000_official/000_AWS_ECS.json#L987) in LinuxParameters (https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts).

Use Case

Using swap allows the container to write excess memory requirements to disk when the container has exhausted all the RAM that is available to it.

Proposed Solution

export interface LinuxParametersProps {
  /**
   * Specifies whether to run an init process inside the container that forwards signals and reaps processes.
   *
   * @default false
   */
  readonly initProcessEnabled?: boolean;

  /**
   * The value for the size (in MiB) of the /dev/shm volume.
   *
   * @default No shared memory.
   */
  readonly sharedMemorySize?: number;

  /**
   * The total amount of swap memory (in MiB) a container can use.
   *
   * @default No swap.
   */
  readonly maxSwap?: number;

  /**
   * This allows you to tune a container's memory swappiness behavior.
   *
   * @default 60
   */
  readonly swappiness?: number;
}

constructor(scope: Construct, id: string, props: LinuxParametersProps = {}) {
  super(scope, id);

  this.sharedMemorySize = props.sharedMemorySize;
  this.initProcessEnabled = props.initProcessEnabled;
  this.maxSwap = props.maxSwap;
  this.swappiness = props.swappiness;
}

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@joelchen joelchen added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jan 16, 2022
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Jan 16, 2022
@mjgp2
Copy link

mjgp2 commented Jan 17, 2022

Example workaround:

// https://github.com/aws/aws-cdk/issues/18460
export class LinuxParams extends LinuxParameters {

  renderLinuxParameters(): ecs.CfnTaskDefinition.LinuxParametersProperty {
      const p = super.renderLinuxParameters() as any;
      p.maxSwap = 5e3;
      p.swappiness = 0;
      return p;
  }
}

@joelchen
Copy link
Author

joelchen commented Jan 18, 2022

@mjgp2 Thank you, it got registered in repository's template.json and tree.json. However after deployment, docker inspect the running container of bottlerocket-os shows MemorySwappiness with new value but MemorySwap is 0.

@mjgp2
Copy link

mjgp2 commented Jan 18, 2022

@joelchen - you probably need to enable some swap space on the EC2 host instance.

@madeline-k madeline-k removed their assignment Jan 20, 2022
@madeline-k madeline-k added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 20, 2022
@mergify mergify bot closed this as completed in #18703 Sep 6, 2022
mergify bot pushed a commit that referenced this issue Sep 6, 2022
…rs (#18703)

Add support to `MaxSwap ` and `Swappiness` attributes in the `LinuxParameters` construct.

Closes #18460

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants