Handling a stateful workload
You can use instance groups to host applications with stateful, stateless, and combined workloads.
The difference between stateful and stateless workloads lies in whether the application saves data about its states and/or user interaction history:
- Stateful: State data is stored. Examples include RESTless services, databases, message queues, monitoring servers, and log servers.
- Stateless: State data is not stored. Examples include RESTful services and web application frontend.
Application states can be stored on secondary disks of the group instances or in the cloud resources independent of the instance group.
Storing states on group instance disks
Warning
We do not recommend storing states on instance boot disks. This significantly restricts operations with an instance group. For example, you cannot freely restart, delete, recreate, and scale an instance in such a group.
You can store application states on secondary disks of the group instances if you:
-
Do not decrease the group size.
-
Do not decrease the instance disk size.
-
Use the
max_expansion
parameter (the maximum number of instances by which you can expand the target size of the group) set to0
in the deployment policy. -
Do not delete VM instances via instance group interfaces:
- In the management console
, on the Instance groups tab. - Using the CLI yc compute instance-group delete-instances command.
- Using the InstanceGroupService/DeleteInstances gRPC API call.
These actions will delete the secondary disk along with the VM. You can directly delete a VM in Compute Cloud without deleting its secondary disk.
- In the management console
If you meet these conditions, the instance group will not delete secondary disks, even if any VM needs to be recreated. The secondary disks will be saved and attached to the new VM.
Storing states outside the instance group
To freely manage group instances with stateful workload applications running, save the application state to cloud resources independent of the instance group:
- Managed databases
- File storages (for more information, see Creating an instance group connected to a file storage)
- Yandex Object Storage buckets (for more information, see Creating an instance group connected to Yandex Object Storage)