Then configure it properly, according to your application's memory demand. And limit your vnode cache accordingly. (Yes, there is a bit of math involved.)
I have never had to do this, while as mentioned the limitation of the cache is indispensable for me
Swapping doesnt crash programs, it just makes them slow (and rots SSD drives). Unless they are broken anyway.
In theory.
Practically swapping can crashes programs, at least on FreeBSD, it doesn't just make them slower.
A fact that has been established for years on dozens of servers, in the hard way.
It essentially depends on WHICH programs: as indicated above I am referring specifically to virtualbox, and, to a lesser extent, mysql
Certainly broken, but there isn't much of an alternative.
In fact, it happens that, for some inexplicable reason, mysql (mariadb) (or rather FreeBSD) decides to do some swapping for a few tens of MBs even when the use of its memory is limited and there are at least a hundred GB of free RAM
Why? I don't know, in fact it's too hard to spot on busy servers.
I should stop one and monitor it thoroughly, but the effort is not worth the result.
arc_meta_limit is advisory only. It doesn't limit the meta, it just gives a preference when evicting.
In fact I put both settings to vary.
Always based on inexplicable crash of virtualbox, then solved.
Concerning the original question: I would recommend to provide as much swap as the machine may move out within realistic time. For a standard SSD with a practical thruput of 250MBsec, it could fill 15GB within a minute. So I would say that is a realistic size that leaves you some chance to catch a runaway process before the the oom killer hits in. Faster devices accordingly bigger.
In my experience (with drives much faster than 250MB/s, at least 10 times faster, when not 30x) I never needed more than 16GB to have stable systems capable of unlimited uptime.
Of course I am referring to my servers, running the jobs of my clients.
I certainly cannot give advice for "any" server and "any" use.
All of them 11 or 12, nothing 13+
Short version: I don't suggest 4GB of swap file, under any circumstances.
Certainly not 2x the RAM (requiring way more than 1TB of swap in my case!)
On the other hand, it costs so little to increase it during the installation phase that I don't see any real reasons why not (on normal machines, not embedded systems etc).
For different scenarios (desktop, SOHO) I don't know, I never use them.
For a server, you don't need much, if any.
As in the example above there is a mysql process that, for some reason, decided to force some swap on a machine with 768GB of RAM.
I really don't recommend BSD servers without swap files.
Certainly not huge, for example I never, ever use hibernation.
But certainly not zero