How to create a Swap partition on your EC2 instance
This applies to SFTP Gateway versions prior to 1.003
For handling production workloads, it's recommended to resize your EC2 instance to at least an
family can handle short memory bursts, but does not handle sustained volume well.
In addition to upgrading your EC2 instance type, it's also a good idea to add a Swap partition. This gives you a soft memory ceiling, so Linux doesn't start terminating process when you run out of RAM.
First, run the
top command. Note that the Swap space is currently zero.
Then, run the following commands:
sudo /bin/dd if=/dev/zero of=/mnt/swap.1 bs=1M count=2048 sudo /sbin/mkswap /mnt/swap.1 sudo chmod 600 /mnt/swap.1 sudo /sbin/swapon /mnt/swap.1 echo "/mnt/swap.1 swap swap defaults 0 0" >> /etc/fstab
This creates a Swap partition that uses 2 GB of hard disk space. It also creates an entry in
fstab so the file system
change survives a reboot.
top again, and you should see your Swap partition.
Finally, reboot and verify that your changes stick.
Once a swap partition is added, the 2GB of disk space used by the swap file is not longer available for normal use by the server. If you need to add more disk space to your instance, refer to this wiki page.