docs/features/workload-attributes.rst
A typical database has more than one :term:workload <workload> running simultaneously with a different acceptable level of latency and
throughput. By defining the attributes of each workload, you can specify how ScyllaDB will handle requests depending on
the workload to which they are assigned.
You can define a workload's attribute using the service level concept. The service level CQL commands allow you to attach attributes to users and roles. When a user logs into the system, all of the attributes attached to that user and to the roles granted to that user are combined and become a set of workload attributes.
See :ref:Service Level Management <workload-priorization-service-level-management> for more information about service levels.
authenticated </operating-scylla/security/runtime-authentication> and :doc:authorized </operating-scylla/security/enable-authorization> userrole created <create-role-statement>.#. Create a service level with the desired attribute.
.. code-block:: cql
CREATE SERVICE LEVEL <service_level_name> WITH <attribute> [ AND <attribute>];
For example:
.. code-block:: cql
CREATE SERVICE LEVEL sl2 WITH timeout = 500ms AND workload_type=interactive;
See :ref:`Available Attributes <workload-attributes-available-attributes>`.
#. Assign a service level to a role or user:
.. code-block:: cql
ATTACH SERVICE_LEVEL <service_level_name> TO <role_name|user_name>;
For example:
.. code-block:: cql
ATTACH SERVICE LEVEL sl2 TO scylla;
You can modify the service level attributes with the ALTER SERVICE LEVEL command:
.. code-block:: cql
ALTER SERVICE LEVEL <service_level_name> WITH <attribute> [ AND <attribute>];
For example:
.. code-block:: cql
ALTER SERVICE LEVEL sl2 WITH timeout = null;
.. _workload-attributes-available-attributes:
.. list-table:: :widths: 30 70 :header-rows: 1
timeoutSpecifying Service Level Timeout <workload-attributes-timeout>workload_typeSpecifying Workload Type<workload-attributes-workload-type>.. _workload-attributes-timeout:
You can specify the timeout for a service level (in milliseconds or seconds) with the timeout attribute.
For example:
.. code-block:: cql
CREATE SERVICE LEVEL primary WITH timeout = 30ms;
Specifying the timeout value is useful when your workloads have different acceptable latency levels.
.. _workload-attributes-workload-type:
You can specify the workload type for a service level with the workload_type attribute.
For example:
.. code-block:: cql
CREATE SERVICE LEVEL secondary WITH workload_type = 'batch';
Specifying the workload type allows ScyllaDB to handle sessions more efficiently (for example, depending on whether the workload is sensitive to latency).
Available Workload Types ^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. list-table:: :widths: 20 80 :header-rows: 1
unspecifiedinteractiveOLTP </features/workload-prioritization>. For example, a workload assigned to users clicking on a website and generating events with their clicks.batchOLAP </features/workload-prioritization>. For example, a workload assigned to processing billions of historical sales records to generate statistics.