EBS Vs EFS Vs NFS for Moodledata : A Comprehensive Comparison

When it comes to hosting Moodledata on AWS, choosing the right storage solution is crucial for optimal performance. In this evaluation, we compare the performance of Amazon Elastic Block Store (EBS), Elastic File System (EFS), and Network File System (NFS) in the AWS Ireland region, using Moodle version 4.3 on a single T3 medium machine running Ubuntu 22.04.

Why the EFS and NFS are in scope ?

due to horizontal scaling or setting up moodle cluster, we need a shared storage

Why EBS then ?

just to compare the performance agianst shared storage

Why EFS standard is not in scope?

That’s add additional overhead due to multi az replication, so, slower than One zone EFS [30%]

Setup Details

  • Moodle data is hosted on a separate gp3 disk with a size of 50 GB, attached to the machine.
  • Two types of benchmarking are conducted:
    • Disk speed test
    • Using the Moodle benchmark report plugin (assuming localcache is already on the local disk)

Performance Comparison

Storage TypeSpeed (MB/s)Moodle Benchmark Report (Performance)Configuration
EBS7750.143GP3 / 50 GB
EFS Standard13024.8Standard, EFS SIZE 1 GB
EFS One Zone16015.6Standard, One Zone, EFS size: 1GB, Same AZ
NFS19014.3Ubuntu, m5.large, GP3, Same AZ

Moodle Data Directory Structure for a cluster

DirectoryLocationLockingPerformance ImpactOther Storage OptionUsage
DatadirShared storageEFS / NFSDefaut: all directory part of data dir and can contain more directory like land / repositories/ antivirus$CFG->dataroot
filedirShared storageLowS3 / any other filesystemActual uploaded files are here$CFG->filedir
cachedirShared storageLocking requiredHighredis/mongoInternally used for caching, not directly replaceable as component file is used$CFG->cachedir
mucShared storageLocking requiredredis/mongoInternally used for caching$CFG->altcacheconfigpath
sessionsShared storageREDIS/DB$CFG->session_file_save_path 
tempdirShared storageLocking requiredEFS/ NFSInternally used for processing$CFG->tempdir
backuptempdirShared storageEFS/NFS$CFG->backuptempdir
localcacheCan be local to machine$CFG->localcachedir
trashdirCan be local $CFG->trashdir

  • Though Overall performance can be better if we utilize the MOODLE EFS / NFS with redis cache as it can remove many Hits from moodle data filesystem
  • To more optimize Setting UP session in Redis / Database can also help
$CFG->session_handler_class = '\core\session\file';
$CFG->session_file_save_path = $CFG->dataroot.'/sessions';
  • We can also remove the cachefile dependency from shared storage
$CFG->alternative_component_cache = '/local/cache/dir/core_component.php' would point to local node cache directory.

NOTE: Before upgrade the administrator MUST have to manually execute following on each node:

$ php admin/cli/alternative_component_cache.php --rebuild
  • MUC contains a config file which changes if there is any change in Cache configuration and contains custom cache store as well as their mapping. Let’s say you add a redis store and map it. This information will be under this directory
$CFG->altcacheconfigpath = '/var/www/localmoodledata/muc/';

My Solution using One zone EFS / NFS

DatadirOne zone EFS / NFS
filedirEFS/ NFS / S3
cachedirOne Zone EFS / NFS
tempdirOne Zone EFS / NFS
sessionsREDIS
Cache *REDIS
localcachedirLocal EBS
trashdirONE ZOne EFS / NFS
alternative_component_cacheLocal EBS on each node
  • cachedir should be on efs, but redis can be utilized to store cache then it will not much use of cachedir

Performance Comparison Detail

  • note : the below comparison is done on a moodle setup but does not use redis for cache
  • data dir on efs /nfs, localcachedir on ebs , cache core componenet file on local ebs

EBS

  • 50 GB GP3 volume mounted on EC2 utilized for moodle data

Disk Speed Test

Moodle Benchmark Report

EFS One Zone

  • One Zone EFS to improve performance, EFS initial size is 1 GB, so minimum IOPS are there

Disk Speed Test

Moodle Benchmark Report

NFS 

  • Ubuntu 22.04 with GP3 Disk of 50 GB setup in same az

Disk Speed Test

Moodle Benchmark Report

Setting up NFS -server and client

NFS server : following steps are done on a ubuntu 22.04 machine with 1 root volume 8gb and another 100 gb volume used for NFS is available at /dev/nvme1n1 [use *lsblk* command for dev output ]

sudo apt update -y && sudo apt upgrade -y
sudo apt install nfs-kernel-server lvm2

# Physical volume
sudo pvcreate /dev/nvme1n1

# virtual  volume group
sudo vgcreate vg1 /dev/nvme1n1

# you can check by : >> sudo pvs or >> sudo vgs
# create logical volume
sudo lvcreate -n lv1 -l 100%FREE /dev/vg1

# you can check by : >> sudo lvs
# then create a file system
sudo mkfs.xfs /dev/vg1/lv1
mkdir /nfs1

# entry in fstab file
/dev/vg1/lv1    /nfs1   xfs     defaults        0 0
mount -a

# add entry in /etc/exports
/nfs1    *(rw,sync,no_root_squash,no_subtree_check)
sudo systemctl restart nfs-kernel-server

NFS Client

sudo apt install nfs-common
mkdir /nfsmoodledata
#fstab entry
[NFS server ip]:/nfs1 /nfsmoodledata  nfs      defaults    0       0

mount -a

Shareable EBS

AWS Also supports sharing EBS volume among multiple ec2 in same az for upto 12 ec2. BUT XFS file system does not support locking by attaching multiple ec2 , still we need an distributed file system over there.
I have evalauted by attaching to multiple ec2, but, disk got corrupted and needed remounted again and again if requests are coming from multiple ec2 using XFS file system

Conclusion

While overall performance can be improved by utilizing Moodle with EFS/NFS and Redis cache, setting up sessions in Redis/Database and optimizing cache file dependencies on shared storage can further enhance the system. Consider implementing a solution using One Zone EFS for better performance, keeping in mind the specific configurations for each storage type. Choose the setup that aligns with your Moodle instance’s requirements and infrastructure constraints.

You can alos browse my post about EFS vs Redis for Caching soltuion

Leave a Reply

Your email address will not be published. Required fields are marked *