Installing zRAM
After the upgrade to node 1.26.1 we noticed that nodes started eating up more RAM resources. If you are running on a minimum requirement of 4 gigs RAM you will probably see that after the update your resource is completely full and if you have a SWAP file it is actively used. The problem with SWAP file is that it is too slow and processes sit in line waiting for their turn. In order to speed things up and remove the line from this file you can use zRAM. here are the instructions. I hope this helps!
If you are running on DO then most likely your linux package does not have zRAM so we will need to download a new image
1
sudo apt-get install linux-image-generic zram-tools
Copied!
After we install the image we need to reboot the machine
1
sudo reboot
Copied!
After your node comes back up you can check if zRAM was installed
1
sudo modinfo zram
Copied!
You should see something like this
filename: /lib/modules/5.8.0-49-generic/kernel/drivers/block/zram/zram.ko description: Compressed RAM Block Device author: Nitin Gupta [email protected] license: Dual BSD/GPL srcversion: FE7B8E790FDF36085E688FD depends: retpoline: Y intree: Y name: zram vermagic: 5.8.0-49-generic SMP mod_unload modversions sig_id: PKCS#7 signer: Build time autogenerated kernel key sig_key: 28:C6:28:04:BF:BF:3D:4B:37:0D:61:7C:C4:1E:A4:AB:71:B1:5A:21 sig_hashalgo: sha512 signature: 07:DA:C1:B7:EF:B9:00:4C:A4:ED:A4:2D:BD:AA:B9:CE:A5:1F:1E:0F: 80:C4:C6:C2:06:2F:5B:9E:F7:0A:C0:E3:1C:44:CA:D6:99:2E:74:C7: DD:FC:C6:64:D6:C0:9C:18:78:88:E6:34:A1:09:C8:C7:11:66:A8:3B: A4:FE:86:A3:FD:57:81:53:35:C8:5D:69:DE:DA:FB:58:BC:1C:7F:59: 8F:75:9D:54:25:2A:38:4F:56:7D:B1:61:1F:09:9D:74:C1:30:78:C4: AF:E6:80:CB:F3:D2:51:4E:D5:FC:A2:6F:B9:CA:01:C3:C3:6D:38:E6: D6:93:E9:18:A0:A3:F2:2C:66:62:1A:C7:22:FA:CF:57:77:49:5B:EF: A1:CA:84:CB:19:3D:12:9D:16:5F:AD:33:FC:06:E2:3C:0E:00:24:11: 02:A7:57:E6:33:C0:8A:4C:51:64:09:D6:34:FE:3E:65:9A:9D:73:B6: 24:F3:5E:6A:FE:2B:52:DD:F4:DC:FE:43:CE:A4:5B:24:03:5B:F8:58: 16:91:0E:F1:26:5A:48:DA:DF:04:D7:21:79:F0:60:E2:22:A9:02:26: 15:80:54:C5:72:87:C7:E1:BE:59:6F:C4:54:8A:45:D3:35:EB:C7:34: F7:FB:A0:A2:40:7E:5B:C9:87:4C:71:6E:3B:B8:68:9D:8B:32:A1:19: 68:A7:78:B1:C4:BF:9B:4B:00:43:FF:F9:BE:C4:40:84:2E:92:A6:33: D4:1A:39:00:73:CA:0B:CE:C1:DF:31:0A:25:35:77:19:86:BD:46:D4: 8F:47:A7:E8:1A:1E:96:6C:AD:29:BA:36:A5:EC:42:64:88:36:D2:82: 74:7F:CB:6C:FB:06:01:D7:AA:BD:26:4D:64:D1:26:75:0B:2B:72:BF: 1C:ED:06:D9:19:38:AE:AA:75:37:D7:4E:2B:65:C0:B7:FE:EA:5C:73: 22:AF:4F:40:AC:98:9E:D9:D1:EA:15:64:66:20:67:FB:12:83:0B:3F: F5:31:3F:57:32:0D:E9:CA:71:E4:97:E6:29:17:B0:AC:EA:0A:0D:B0: 7F:11:A3:C9:EC:3A:F7:C2:3A:39:EF:8B:40:78:10:31:B6:39:91:E4: D9:1E:EC:76:98:73:98:DC:7C:00:17:D9:1F:43:ED:06:22:7B:A1:BD: E6:8B:DD:E7:0C:87:3B:80:44:F9:AA:5E:DE:E8:F3:AC:F7:10:03:53: D9:4C:85:0E:B9:3D:EB:C0:1B:D5:14:11:33:16:38:5D:63:15:1E:85: A1:49:6C:AF:95:61:1F:6B:22:0B:15:44:C6:9F:15:8F:E2:AD:61:9A: 89:E5:53:39:59:89:EB:DB:B5:12:1F:04 parm: num_devices:Number of pre-created zram devices (uint)
Now we need to enable the service and then start the service and check the status
1
sudo systemctl enable zramswap.service
Copied!
1
sudo systemctl start zramswap.service
2
sudo systemctl status zramswap.service
Copied!
zramswap.service - Linux zramswap setup Loaded: loaded (/lib/systemd/system/zramswap.service; enabled; vendor preset: enabled) Active: active (exited) since Thu 2021-04-15 06:56:15 UTC; 7min ago Docs: man:zramswap(8) Main PID: 742 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 4609) Memory: 0B CGroup: /system.slice/zramswap.service
With this command you can check how your SWAP file and zRAM are behaving. You will see that by default 128m has been allocated to each partition and SWAP file priority has been changed to -2 and zRAM is 100. So system will used zRAMfirst
1
sudo swapon
Copied!
NAME TYPE SIZE USED PRIO /swapfile file 3G 0B -2 /dev/ zram0 partition 128M 0B 100 /dev/ zram1 partition 128M 0B 100
If you check the above command in a couple of minuted you will see that zRAM partition is already full so you can allocate more space to zRAM by configuring this file:
1
sudo nano /etc/default/zramswap
Copied!
I changed the allocated space to 512. then you need to exit and save the file and restart the service
1
sudo systemctl stop zramswap.service
2
sudo systemctl start zramswap.service
3
#or use this command
4
sudo systemctl restart zramswap.service
Copied!
If you check the resources again you will see that now we have 2 partitions totaling to 512 and only 248 megs are used. If you need more change accordingly.
1
sudo swapon
Copied!
NAME TYPE SIZE USED PRIO
/swapfile file 3G 59.8M -2
/dev/zram0 partition 256M 248.1M 100
/dev/zram1 partition 256M 249.1M 100
Ofcourse it is better to run on 8gigs RAM, but if you are on 4 this will significantly help with the machines performace.
Copy link