I dont recommend swapfiles for servers, just get 20% more ram than you need. Its really simple why, Nvme / SSD and physical disks have such poor read speeds for web ops. Besides if you are swapping - its almost always the case that you dont have enough memory. If you have a rogue process or just get hammered - the swapfile will get completely used and the OOM will kill the process anyway (and at this stage any wordpress or database app is not going to be usable anyway).
Make use of memory by looking at your database sizing, you want your whole database to be held in memory all of the time. Tune your innodb_buffer_pool_size to some amount of memory you can fit and that is bigger than your database. Check after a few days how the buffer pool is being used, and then resize it down. You want good utilization without hitting 100% and not wasting memory by sitting at 90% unused.