Oracle Standard Edition on AWS ☁ socket arithmetic
Tags: oracle, standardedition, aws, license
Published: 2021-05-15 04:59:02

Note that I've written previously about Oracle Standard Edition 2 licensing before but a few rules change. This is written in May 2020.
TL;DR: 4 vCPU count for 1 socket and 2 sockets count for 1 server wherever hyper-threading is enabled or not.

<h3>The SE2 rules</h3>
I think the Standard Edition rules are quite clear now: maximum server capacity, cluster limit, minimum NUP, and processor metric. Oracle has them in the <a href="https://www.oracle.com/assets/databaselicensing-070584.pdf" rel="noopener noreferrer" target="_blank">Database Licensing</a> guideline.
<h4>2 socket capacity per server</h4>
<em>Oracle Database Standard Edition 2 may only be licensed on servers that have a maximum capacity of 2 sockets.</em>

We are talking about capacity which means that even when you remove a processor from a 4 socket server, it is still a 4 socket server. You cannot run Standard Edition if the servers have be the possibility for more than 2 sockets per server whether there is a processor in the socket or not.

<h4>2 socket used per cluster</h4>
<em>When used with Oracle Real Application Clusters, Oracle Database Standard Edition 2 may only be licensed on a maximum of 2 one-socket servers</em>

This one is not about capacity. You can remove a processor from a bi-socket to become a one-socket server, and then build a cluster running RAC in Standard Edition with 2 of those nodes. The good thing is that you can even use Oracle hypervisor (OVM or KVM), LPAR or Zones to pin one socket only for the usage of Oracle, and use the other for something else. The bad thing is that as of 19c, RAC with Standard Edition is not possible anymore. You can run the new SE HA which allows more on one node (up to the 2 socket rule) because the other node is stopped (the 10 days rule).

<h4>At least 10 NUP per server</h4>
<em>The minimum when licensing by Named User Plus (NUP) metric is 10 NUP licenses per server.</em>

Even when you didn't choose the processor metric you need to count the servers. For example, if your vSphere cluster runs on 4 bi-socket servers, you need to buy 40 NUP licenses even if you can count a smaller population of users.

<h4>Processor metric</h4>
<em>When licensing Oracle programs with ... Standard Edition in the product name, a processor is counted equivalent to a socket; however, in the case of multi-chip modules, each chip in the multi-chip module is counted as one occupied socket. </em>

A socket is a plastic slot where you can put a processor in it. This is what counts for the "2 socket capacity per server". An occupied socket is one with a processor, physically or pinned with an <a href="https://www.oracle.com/assets/partitioning-070609.pdf" rel="noopener noreferrer" target="_blank">accepted hard partitioning</a> hypervisor method (Solaris Zones, IBM LPAR, Oracle OVM or KVM,...). This is what counts for the "2 socket occupied per cluster" rule. Intel is not concerned by the multi-module chip exception.

<h3>What about the cloud?</h3>

So, the rules mention servers, sockets and processors. How does this apply to modern computing where you provision a number of vCPU without knowing anything about the underlying hardware? In the AWS shared responsibility model you are responsible for the Oracle Licences (BYOL - Bring Your Own Licences) but they are responsible for the physical servers.

Oracle established the rules (which may or may not be referenced by your contract) in the <a href="https://www.oracle.com/assets/cloud-licensing-070579.pdf" rel="noopener noreferrer" target="_blank">Licensing Oracle Software in the Cloud Computing Environment</a> (for educational purposes only - refer to your contract if you want the legal interpretation).

This document is only for AWS and Azure. There's no agreement with Google Cloud and then you cannot run an Oracle software under license. Same without your local cloud provider: you are reduced to hosting on physical servers. The Oracle Public Cloud has its own rules and you can license Standard Edition on a compute instance with up to 16 OCPU and one processor license covers 4 OCPU (which is 2 hyper-threaded Intel cores).

Oracle authorizes to run on those 2 competitor public clouds. But they generally double the licenses required on competitor platforms in order to be cheaper on their own. They did that on-premises a long time ago for IBM processors and they do that now for Amazon AWS and Microsoft Azure.

So, the arithmetic is based on the following idea: 4 vCPU counts for 1 socket and 2 sockets counts for 1 server

Note that there was a time where it was 1 socket = 2 cores which meant that it was 4 vCPU when hyper-threading is enabled but 2 vCPU when not. They have changed the document and we count vCPU without looking at cores or threads. Needless to say that for optimal performance/price in SE you should disable hyper-threading in AWS in order to have your processes running on full cores. And use instance caging to limit the user sessions in order to leave a core available for the background processes.

Here are the rules:
<ul>	<li>2 socket capacity per server: maximum 8 vCPU</li>
	<li>2 socket occupied per cluster: forget about RAC in Standard Edition and RAC in AWS</li>
	<li>Minimum NUP: 10 NUP are ok to cover the maximum allowed 8 vCPU</li>
	<li>Processor metric: 1 license covers 4 vCPU</li>
</ul>

<h3>Example</h3>

The maximum you can use for one database:
2 SE2 processor licences = 1 server = 2 sockets = 8 AWS vCPU
2 SE2 processor licences = 8 cores = 16 OCPU in Oracle Cloud

The cheaper option means smaller capacity:
1 SE2 processor licences = 1 sockets = 4 AWS vCPU
1 SE2 processor licences = 4 cores = 8 OCPU in Oracle Cloud

As you can see The difference between Standard and Enterprise Edition in the clouds is much smaller than on-premises where a socket can run more and more cores. The per-socket licensing was made at a time where processors had only a few cores. With the evolution, Oracle realized that SE was too cheap. They caged the SE2 usage to 16 threads per database and limit further on their competitor's cloud. Those limits are not technical but governed by revenue management: they provide a lot of features in SE but also need to ensure that large companies still require EE.

<h3>But...</h3>
... there's always an exception. It seems that Amazon has a special deal to allow Oracle Standard Edition on AWS RDS with EC2 instances up to 16 vCPU:

<a href="https://blog.dbi-services.com/wp-insides/uploads/sites/2/2020/05/Annotation-2020-05-19-203820-1.jpg"><img src="https://blog.dbi-services.com/wp-insides/uploads/sites/2/2020/05/Annotation-2020-05-19-203820-1-1024x714.jpg" alt="" width="1024" height="714" class="aligncenter size-large wp-image-39930" /></a>

You know that I always try to test what I'm writing in a blog post. So, at least as of the publishing date and with the tested versions, it gets some verified facts. 
I started an AWS RDS Oracle database on db.m4.4xlarge which is 16 vCPU. I've installed the instant client in my bastion console to access it:

<pre><code>
sudo yum localinstall http://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.5-basic-19.5.0.0.0-1.x86_64.rpm
sudo yum localinstall http://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.5-sqlplus-19.5.0.0.0-1.x86_64.rpm
</code></pre>

This is Standard Edition 2:
<pre><code>
[ec2-user@ip-10-0-2-28 ~]$ sqlplus admin/FranckPachot@//database-1.ce45l0qjpoax.us-east-1.rds.amazonaws.com/ORCL

SQL*Plus: Release 19.0.0.0.0 - Production on Tue May 19 21:32:47 2020
Version 19.5.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Last Successful login time: Tue May 19 2020 21:32:38 +00:00

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0
</code></pre>
On 16 vCPU:
<pre><code>
SQL&gt; show parameter cpu_count

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cpu_count                            integer     16
</code></pre>
On AWS:
<pre><code>SQL&gt; host curl http://169.254.169.254/latest/meta-data/services/domain
amazonaws.com
</code></pre>
With more than 16 threads in CPU:
<pre><code>SQL&gt; @ snapper.sql ash 10 1 all
Sampling SID all with interval 10 seconds, taking 1 snapshots...

-- Session Snapper v4.31 - by Tanel Poder ( http://blog.tanelpoder.com/snapper ) - Enjoy the Most Advanced Oracle Troubleshooting Script on the Planet! :)


---------------------------------------------------------------------------------------------------------------
  ActSes   %Thread | INST | SQL_ID          | SQL_CHILD | EVENT                               | WAIT_CLASS
---------------------------------------------------------------------------------------------------------------
   19.29   (1929%) |    1 | 3zkr1jbq4ufuk   | 0         | ON CPU                              | ON CPU
    2.71    (271%) |    1 | 3zkr1jbq4ufuk   | 0         | resmgr:cpu quantum                  | Scheduler
     .06      (6%) |    1 |                 | 0         | ON CPU                              | ON CPU

--  End of ASH snap 1, end=2020-05-19 21:34:00, seconds=10, samples_taken=49, AAS=22.1

PL/SQL procedure successfully completed.

</code></pre>
I also checked on CloudWatch (the AWS monitoring from the hypervisor) that I am running 100% on CPU.

I tested this on a very limited time free lab environment (this configuration is expensive) and didn't check whether hyperthreading was enabled or not (my guess is: disabled) and I didn't test if setting CPU_COUNT would enable instance caging (SE2 is supposed to be internally caged at 16 CPUs but I see more sessions on CPU there).

{% twitter 1262867624305872902 %}