What is SWAP ? SWAP is a technology used to emulate RAM using any item recognized as block device. In other words it "expands" amount of available RAM using disk mounted locally/remotely. However, SWAP isn't so fast as RAM even if SSD/NVMe drives are used for swapping. So huge swap disk has no sense because than more intense SWAP is used by the server/computer than slower the server/computer works.
In case your server has 2Gb of RAM then create SWAP disk (mount a file as a swap disk) of size 2Gb-4Gb (2Gb is recommended).