2

I have an Elastic Beanstalk worker app that is doing some memory-intensive single-threaded computation. All the available instance types that meet my memory requirements (16 Gb) have 2+ vCPUs, so I only hit 50% CPU usage. Edit: This is just a quirk of how CPU usage is reported when hyperthreading is enabled

I see that on the instance types I'm interested in, I should be able to disable hyper-threading by setting the ThreadsPerCore CPU option to 1, giving me a free performance boost, but Elastic Beanstalk doesn't seem to provide a way to set this in it's standard settings.

The docs have plenty of examples of how to add custom resources using cloud formation in .ebextensions. They also allude to the fact that the standard resources created by EB can be modified; but I couldn't find any examples of this in practice. Having not used cloud formation before, I'm struggling to put the pieces together!

Update: Looking at this answer, it looked like I could just "redeclare" the EB resources and override the config, so I tried the following in an .ebextensions .config file:

Resources:
  AWSEBEC2LaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateData:
        CpuOptions:
          ThreadsPerCore: 1

This feels like it gets me closer, but now when I deploy to Elastic Beanstalk, I get the following error: InvalidParameterValue: Both EC2 Launch Template and AS Launch Configuration exist in the template. No results on Google for that one.

This seems like it might be a reference to the fact that an autoscaling group uses either a launch template, or a lauch configuration, but not both; but I haven't touched the scaling group, and when I look at the resources that EB creates as standard, there is no launch configuration, only a launch template.

Mike Rippon
  • 121
  • 2
  • 2
    My reading of non-authoritative sources suggests you might get 2-4% improvement in speed in a single threaded workload, but don't forget the operating system and other processes will benefit from having a second core available. In short, you may not get any speed-up from this, and if you do it will probably be a very small benefit. You'd probably be better off using a more suitable instance size. – Tim Jun 08 '20 at 22:39
  • You're absolutely right, I tried benchmarking manually on an instance with hyper-threading disabled. In the AWS console (and looking at `top`) total CPU usage went up to 100% from 50%, but I actually saw no performance gain whatsoever. I didn't realize the 50% was just a quirk of how CPU usage is reported when hyperthreading is enabled. I guess I'll leave the question up for now as editing CPU options via EB still seems like a valid question, even if it doesn't apply to my situation any more. – Mike Rippon Jun 09 '20 at 23:30
  • Indeed, whan you have e.g. 4 cores (whether 'real' or hyperthreading it's irrelevant) your CPU usage will max out at 400%, not 100%. – Marcello Romani Jan 11 '21 at 11:29

0 Answers0