Share Struct
Represents a group of Job Definitions.
All Job Definitions that declare a share identifier will be considered members of the Share defined by that share identifier.
The Scheduler divides the maximum available vCPUs of the ComputeEnvironment among Jobs in the Queue based on their shareIdentifier and the weightFactor associated with that shareIdentifier.
| Source | aws-batch/lib/scheduling-policy.ts |
|---|---|
| Type last changed |
Example
const fairsharePolicy = new batch.FairshareSchedulingPolicy(this, 'myFairsharePolicy');
fairsharePolicy.addShare({
shareIdentifier: 'A',
weightFactor: 1,
});
fairsharePolicy.addShare({
shareIdentifier: 'B',
weightFactor: 1,
});
new batch.JobQueue(this, 'JobQueue', {
schedulingPolicy: fairsharePolicy,
});
fairshare_policy = batch.FairshareSchedulingPolicy(self, "myFairsharePolicy")
fairshare_policy.add_share(
share_identifier="A",
weight_factor=1
)
fairshare_policy.add_share(
share_identifier="B",
weight_factor=1
)
batch.JobQueue(self, "JobQueue",
scheduling_policy=fairshare_policy
)
FairshareSchedulingPolicy fairsharePolicy = new FairshareSchedulingPolicy(this, "myFairsharePolicy");
fairsharePolicy.addShare(Share.builder()
.shareIdentifier("A")
.weightFactor(1)
.build());
fairsharePolicy.addShare(Share.builder()
.shareIdentifier("B")
.weightFactor(1)
.build());
JobQueue.Builder.create(this, "JobQueue")
.schedulingPolicy(fairsharePolicy)
.build();
// Install: dotnet add package Amazon.CDK.Lib
var fairsharePolicy = new FairshareSchedulingPolicy(this, "myFairsharePolicy");
fairsharePolicy.AddShare(new Share {
ShareIdentifier = "A",
WeightFactor = 1
});
fairsharePolicy.AddShare(new Share {
ShareIdentifier = "B",
WeightFactor = 1
});
new JobQueue(this, "JobQueue", new JobQueueProps {
SchedulingPolicy = fairsharePolicy
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
fairsharePolicy := batch.NewFairshareSchedulingPolicy(this, jsii.String("myFairsharePolicy"))
fairsharePolicy.AddShare(&Share{
ShareIdentifier: jsii.String("A"),
WeightFactor: jsii.Number(1),
})
fairsharePolicy.AddShare(&Share{
ShareIdentifier: jsii.String("B"),
WeightFactor: jsii.Number(1),
})
batch.NewJobQueue(this, jsii.String("JobQueue"), &JobQueueProps{
SchedulingPolicy: fairsharePolicy,
})
Properties
weightFactornumberweight_factorint | floatweightFactorNumberWeightFactordoubleWeightFactor*float64 required #notes
The Scheduler decides which jobs to put in the Compute Environment such that the following ratio is equal for each job:
sharevCpu / weightFactor,
where sharevCpu is the total amount of vCPU given to that particular share; that is, the sum of the vCPU of each job currently in the Compute Environment for that share.
See the readme of this module for a detailed example that shows how these are used, how it relates to computeReservation, and how shareDecay affects these calculations.