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 or later
  • Ubuntu 18.10 or later
  • SUSE Linux 12 SP4 or 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 retained. Persistent memory can be used as memory or local disks.
  • When persistent memory is used as memory, you can move data such as non-hot data that does not require high-speed storage access from regular memory to persistent memory. Persistent memory offers large capacity at a low price per GiB and can help reduce the total cost of ownership (TCO) per GiB of memory.
  • When persistent memory is used as local disks, it delivers ultra-high I/O performance and a read/write latency as low as 170 nanoseconds. You can use persistent memory for core application databases that require consistent response time. You can also replace Non-Volatile Memory Express (NVMe) SSDs with persistent memory used as local disks to achieve higher IOPS, higher bandwidth, and lower latency and solve performance bottlenecks.
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 increases the risks of single points of failure (SPOFs). 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.
  • On instances of ecs.re6p, ecs.re7p, and ecs.r7p instance types, persistent memory can be used as memory or local disks.
  • On instances of ecs.re6p-redis.<nx>large, ecs.re7p, and ecs.r7p instance types, persistent memory can be used only as memory.
For more information about instance types, see Instance family.
In this example, the following configurations are used:
  • Instance type: ecs.re6p.2xlarge
  • Image: Alibaba Cloud Linux 2.1903 LTS 64-bit

Configure persistent memory as memory

You can use memkind to allocate memory space. For more information about how to use memkind, visit 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

Configure 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 && \
    ipmctl create -goal PersistentMemoryType=AppDirectNotInterleaved
    ndctl create-namespace --region region0 --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.

    The following table describes the performance comparison between local NVMe SSDs, enhanced SSDs (ESSDs), and persistent memory that is used as local SSDs.
    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 of 800 GiB at performance level 1 (PL1)
    Read bandwidth 8 to 10 GB/s 2 to 3 GB/s 0.2 to 0.3 GB/s
    Read/write bandwidth 8 to 10 GB/s 1 to 2 GB/s 0.2 to 0.3 GB/s
    Write bandwidth 2 to 3 GB/s 1 to 2 GB/s 0.2 to 0.3 GB/s
    Read IOPS 1,000,000 500,000 20,000 to 30,000
    Read/write IOPS 1,000,000 300,000 20,000 to 30,000
    Write IOPS 1,000,000 300,000 20,000 to 30,000
    Read latency 300 to 400 nanoseconds 100,000 nanoseconds 250,000 nanoseconds
    Write latency 300 to 400 nanoseconds 20,000 nanoseconds 150,000 nanoseconds