Persistent memory on Elastic Compute Service (ECS) instances can be used as memory or local disks based on the instance type. This topic describes how to configure the usage mode of persistent memory.

Prerequisites

The instance uses an image of one of the following versions:
  • Alibaba Cloud Linux 2
  • CentOS 7.6 and later
  • Ubuntu 18.10 and later
  • SUSE Linux 12 SP4 and later

Background information

The access latency of persistent memory is lower than that of regular memory. When an instance is stopped or restarted, data in its persistent memory is not lost. Persistent memory can be used as memory or local disks.
  • When persistent memory is used as memory, you can store some data (such as data that does not require rapid access) to persistent memory instead of regular memory. Persistent memory offers large capacity at a lower price per GiB and can help reduce the total cost of ownership (TCO) per GiB of memory.
  • When persistent memory is used as a local disk, it functions like a local SSD to deliver ultra-high performance and a read/write latency as low as 400 nanoseconds. You can use persistent memory for core application databases that require consistent response time. You can also replace cache disks with persistent memory to achieve higher IOPS, higher bandwidth, and lower latency and improve the business performance of an entire cluster.
Notice The reliability of data stored in persistent memory depends on the reliability of persistent memory devices and the physical servers to which these devices are attached. This may cause risks of single points of failure. To ensure the reliability of application data, we recommend that you implement data redundancy at the application layer and use cloud disks for long-term data storage.
The usage mode of persistent memory is determined by instance types.
  • On ecs.re6p.large, ecs.re6p.xlarge, ecs.re6p.2xlarge, ecs.re6p.13xlarge, or ecs.re6p.26xlarge instances, persistent memory can be used as memory or local disks.
  • On ecs.re6p-redis.large, ecs.re6p-redis.xlarge, ecs.re6p-redis.2xlarge, or ecs.re6p-redis.13xlarge instances, persistent memory can be used only as memory.
In this example, the following configurations are used:
  • Instance type: ecs.re6p.2xlarge
  • Image: Alibaba Cloud Linux 2.1903 LTS 64-bit

Use persistent memory as memory

When persistent memory is used as memory, it is byte addressable like regular memory. The space of persistent memory and regular memory is independent of each other. You can also use memkind to allocate memory space. For more information about how to use memkind, see memkind.

  1. Log on to the instance.
    For more information, see Connection methods.
  2. Install the persistent memory management tool and set the usage mode to devdax.
    yum install -y ndctl daxctl && \
    ndctl create-namespace -f -e namespace0.0 --mode=devdax
  3. Check the memory size.
    • Check the size of persistent memory.
      ndctl list -R
      pmem-size
    • Check the size of regular memory.
      cat /proc/meminfo

Use persistent memory as a local disk

  1. Log on to the instance.
    For more information, see Connection methods.
  2. Install the persistent memory management tool and set the usage mode to fsdax.
    yum install -y ndctl daxctl && \
    ndctl create-namespace -f -e namespace0.0 --mode=fsdax
  3. Format the persistent memory to be used as a local disk and mount the disk.
    mkfs -t ext4 /dev/pmem0 && \
    mkdir /mnt/sdb && \
    mount -o dax,noatime /dev/pmem0 /mnt/sdb
  4. View the mounted disk.
    df -h
    pmem-as-ssd

    After the disks are mounted, you can use disk performance test tools to test their performance.

    For information about how to use fio to test disk performance on a re6p instance, see the "Commands used to test the performance of local disks" section of the Test the performance of Elastic Block Storage devices topic. The following table describes the performance comparison between local Non-Volatile Memory Express (NVMe) SSDs, enhanced SSDs (ESSDs), and persistent memory that is used as local disks on re6p instances.
    Note The performance data in the following table is for reference only. Data in the results of your own tests prevails.
    Metric Persistent memory of 128 GiB NVMe SSD of 1,788 GiB ESSD at performance level 1 (PL1) of 800 GiB
    Read bandwidth 8-10 GB/s 2-3 GB/s 0.2-0.3 GB/s
    Read/write bandwidth 8-10 GB/s 1-2 GB/s 0.2-0.3 GB/s
    Write bandwidth 4-6 GB/s 1-2 GB/s 0.2-0.3 GB/s
    Read IOPS 1,000,000 500,000 20,000-30,000
    Read/write IOPS 1,000,000 300,000 20,000-30,000
    Write IOPS 1,000,000 300,000 20,000-30,000
    Read latency 300-400 nanoseconds 100,000 nanoseconds 250,000 nanoseconds
    Write latency 300-400 nanoseconds 20,000 nanoseconds 150,000 nanoseconds