When choosing a disk solution, one of the most important features in addition to its size is the protection of data to be kept there. CEPH technologoy, in addition to the scalable solution, which enables to freely increase the disk space, offers proven data protection methods: Replications and Erasure Code.
What is the difference and which solution to choose in our system ?

Object replication is the default option for CEPH protection. In involves storing several copies of the same object in a cluster. We will not lose data in the event of a failure of one of OSDs, because there is a specific number of replicas in the cluster. We should keep in mind however, that the higher the number of replicas, the more available disk space is occupied by the copies of objects.

Erasure Codeing is the second much more interesting method for protection of data in CEPH. Each object is stored in K+M pieces in the pool of configured erasure codings. The object is divided into K fragments and M redundant ones.

How it works:
The figure shows the principle of operation of erasure coding for K=3 and M=2. When writing data, the object is encoded and split into pieces and then each of the fragments is saved on subsequent OSDs. If any of the OSDs fails, the fragment which is missing will be rebuilt from redundant parts located on other OSDs. The value of M tells us how many OSDs may fail without data loss. Configurations should start by creating a profile, in which we declare such parameters, i.e. K, M or the encoding algorithm.
In order to view the default profile settings, we will use the following command:
ceph osd erasure-code-profile get default
Przykład stworzenia profilu:
ceph osd erasure-code-profile set myprofile k=3 m=2
We should also remember that we should use the Cache Tiering functionality in order to configure the Erasure Coding.

Which one do we choose?
Each of the presented methods has its advantages and disadvantages. In the case of replication, the undoubted benefit is its clarity and simplicity of configuration. There is a drawback in that we consume a lot of disk space for storing the replicas of the object. In the case of a replication set to 2, the usable area of our cluster is reduced by half.
Erasure coding requires more work on the configuration and the machines having more computing power. The division of objects into data pieces requires more CPU usage. However, the savings in disk space compensate for these defects. At 10 OSD and K=7 fragments and M=3 redundant ones, we get EC ratio equal to 0.7. This means that in order to have X TB of usable space we need to create a disk cluster with the size of X * (1/0.7) = X * 1.42. Despite the system being fail-safe at level 3, the data will not occupy 3 times more space, but only 1.42.