Skip to content

Insight and analysis of technology and business strategy

Optimizing CPU cores and threads for Oracle on AWS

About a couple of weeks ago, AWS introduced a new option to manage CPU cores and threads on EC2 or RDS instances. So now you can reduce the number of cores or threads per core for your AWS instances. It doesn't mean you are going to pay less money to Amazon when you reduce cores or threads, but it might help if you have software licensed by CPU cores or if you are not CPU bound and want a certain instance type that provides the desirable memory and IO bandwidth. Here is an example: You want your system to have at least 200 GiB memory and sustain IO load up to 7,000 MBs and 37,500 IOPS. An r4.8xlarge instance fulfills all the requirements, but it has 32 vCPU when you need only 16 vCPU and you don't want to pay for additional licenses. In some cases, the licensing costs can be quite heavy. Let's imagine that one CPU core license for our software costs $50,000. Considering that one core is two vCPU, it adds up to 50,000 x 8 which is $400,000 in licensing costs plus another $90,000 for yearly support. This total is for the additional 8 CPU/16 vCPU licensing cost. Having the option to reduce the number of cores and threads can save you about half of million and save another hundred thousand every year. It sounds like a good option even if you still pay AWS for those unused cores. So how we can do that? The procedure is pretty simple. I am going to use AWS RDS for Oracle as an example. If you create a new instance, you can choose a number of cores when you either launch a new database or restore from a snapshot. Also, you can modify an existing instance. Unfortunately, the GUI Web interface doesn't provide those options for now. As far as I have been told, the AWS team is working to restore functionality and plans to make it available soon. Let's see how we can do it using AWS CLI. We have one new option "--processor-features" for creating, modifying or restoring an RDS instance from a command line. If you already have a template you use to provision or restoring your instances, you need to just add the parameter and provide the number of cores and threads you plan to make available. Or, if you rely on the GUI interface, you can create the instance from the AWS console and then modify it from the command line. I will show you both methods. Before doing anything in the AWS command line make sure you have the latest version of AWS CLI or you may get a message like "Unknown options: --processor-features, Name=coreCount,Value.." For some reason, the pip upgrade didn't work on my Mac, so I used the bundle to update the tool.
MacBook:~ $ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
 Password:
 Running cmd: /anaconda3/bin/python virtualenv.py --no-download --python /anaconda3/bin/python ...
 You can now run: /usr/local/bin/aws --version
 MacBook:~ $ aws --version
 aws-cli/1.15.59 Python/3.6.5 Darwin/17.7.0 botocore/1.10.58
 MacBook:~ $
 
With our tool updated, we can run the command "aws rds create-db-instance" and create an instance with the reduced number of cores. I used db.r3.xlarge class instance for AWS RDS for Oracle for the demonstration. The full command looks like :
aws rds create-db-instance --db-instance-identifier orcl --allocated-storage 20 --db-instance-class db.r3.xlarge --engine oracle-ee --master-username superdba --master-user-password "Mysecretpassword" --no-multi-az --backup-retention-period 0 --engine-version 12.1.0.2.v12 --license-model bring-your-own-license --publicly-accessible --storage-type gp2 --processor-features "Name=coreCount,Value=1"
 
The instance was created and, for db.r3.xlarge, we should have 2 CPU cores and 4 vCPU (threads) by default. We have reduced the number of cores from default 2 to 1 or to 2 vCPU having two threads per core. It should now show only two CPUs used by the Oracle instance. Let's connect to the instance and check it out.
orcl.qwrrtdbklb.us-east-1.rds.amazonaws.com:1521/orcl> show parameter cpu_count
 NAME TYPE VALUE
 ------------------------------- ------- ----- 
 cpu_count integer 2
 orcl.qwrrtdbklb.us-east-1.rds.amazonaws.com:1521/orcl> 
 
It looks right and even if we don't see it from the Web GUI interface, we always can confirm it using the CLI command "aws rds describe-db-instances":
MacBook:~ $ aws rds describe-db-instances 
 {
  "DBInstances": [
  {
  "DBInstanceIdentifier": "orcl",
  "DBInstanceClass": "db.r3.xlarge",
  "Engine": "oracle-ee",
 ….
  "PerformanceInsightsEnabled": false,
  "ProcessorFeatures": [
  {
  "Name": "coreCount",
  "Value": "1"
  }
  ]
  }
  ]
 }
 MacBook:~ $ 
 
Let's modify the number of threads per core reducing number of vCPU to one.
MacBook:~ $ aws rds modify-db-instance --db-instance-identifier orcl --processor-features "Name=threadsPerCore,Value=1" --apply-immediately 
 {
  "DBInstance": {
  "DBInstanceIdentifier": "orcl",
  "DBInstanceClass": "db.r3.xlarge",
  "Engine": "oracle-ee",
 …
 
After the maintenance has been completed, we can verify the number of CPUs used by the instance again.
orcl.qwrrtdbklb.us-east-1.rds.amazonaws.com:1521/orcl> show parameter cpu_count
 NAME TYPE VALUE 
 --------- ------- -----
 cpu_count integer 1 
 orcl.qwrrtdbklb.us-east-1.rds.amazonaws.com:1521/orcl> 
 
It worked correctly and now we can return everything back to default using the option "--use-default-processor-features".
MacBook:~ $ aws rds modify-db-instance --db-instance-identifier orcl --use-default-processor-features --apply-immediately 
 {
  "DBInstance": {
  "DBInstanceIdentifier": "orcl",
  "DBInstanceClass": "db.r3.xlarge",
  "Engine": "oracle-ee",
 
 …
 
 orcl.qwrrtdbklb.us-east-1.rds.amazonaws.com:1521/orcl> show parameter cpu_count
 NAME TYPE VALUE
 --------- ------- ----- 
 cpu_count integer 4
 orcl.qwrrtdbklb.us-east-1.rds.amazonaws.com:1521/orcl> 
 
It has worked pretty well from the command line and I hope the GUI interface is going to be fixed soon so that we are able to set it up and see it from the web console. I think the new feature may help some customers with their cloud migration, providing more options to choose instance type, according to the load rather than the CPU count.

Top Categories

  • There are no suggestions because the search field is empty.

Tell us how we can help!

dba-cloud-services
Upcoming-Events-banner