Hosting multiple web apps and databases on a single FreeBSD server, jails or vm bhyve? reddit / freebsd ---------------------------------------------------------------------- haqkm · 2022-01-18 06:08 Hi there, I am new to FreeBSD (have been a linux user all my life) and am trying to figure out how to set up multiple apps on a new FreeBSD server. I want to run all these apps under FreeBSD with good isolation for security. Should I use jails or vm bhyve for this? I'll be running a bunch of webservers and a postgres db and a redis db on the same server. ---------------------------------------------------------------------- RafneQ · 2022-01-18 06:48 Well I would say it depends on how many resources (CPU cores & RAM) you have and how comfortable you feel on FreeBSD. Both options (bhyve and jails) are good. If you want start with jails I would recommend Bastille which automates a lot of things with jails and makes it super easy: https://bastillebsd.org/ In the newest version there are also Linux containers included but I still didn't tried them so I can't say if they work fine. ---------------------------------------------------------------------- rykolepl · 2022-01-18 07:40 you will get less overhead (most notably on RAM usage) if you will use jails. Bhyve will provide better isolation. However you can use both (postgres and redis in jails, webservers in bhyve). ---------------------------------------------------------------------- PkHolm · 2022-01-18 12:57 One jail for Postgress, one jail for redis and one jail for webservers (assuming you are using virtual hosts). And do not forgot about FW between jails, and probaly use VNET jails. It should be lightest solution. ---------------------------------------------------------------------- DTangent · 2022-01-18 14:39 Don’t forget you can run all your processes in a MAC partition, you can limit what they can see or do on a file system with rc.bsdextended (UGIDFW), as well as chroot them. It always comes down to if a process in a jail or container is compromised how confident are you they didn’t escape? Jails and containers and chroot are not foolproof, so at what point do you decide a reinstall is the best option? ---------------------------------------------------------------------- execerror · 2022-01-18 15:42 :O There's proper Linux containers now!?! Thank you for bringing this up! ---------------------------------------------------------------------- RafneQ · 2022-01-18 16:41 Well depends what you mean by "proper" :-) in the latest release there is EXPERIMENTAL support for: Debian 11 "Bullseye", Debian 10 "Buster", Debian 9 "Stretch", Ubuntu 18.04 "Bionic" Ubuntu 20.04 "Focal". https://github.com/BastilleBSD/bastille/releases As I said I still didn't tried them and I would not assume that they are production ready. Anyway the development is ongoing and there was big progress last year. ---------------------------------------------------------------------- execerror · 2022-01-18 17:09 I wouldn't be using it in any sort of production environment anyway. I use Linux Jail's to run a few games that aren't ported to FreeBSD. It'll be nice to use Bastille for them now instead of the "manual" way. ---------------------------------------------------------------------- RafneQ · 2022-01-18 18:56 Whoa, that's nice ! I didn't expect this kind of "application" :O :) ---------------------------------------------------------------------- IanArcad · 2022-01-18 19:47 Personally, I use bhyve and like it - I think it is straightforward and easy to use, even for some complex configurations. Like one of my VMs has a VPN associated with it and NFS mounts all of its data from directories on the host, which I think is pretty cool. However, my own sense is that the more IO heavy your app is, the more you would probably benefit from jails rather than bhyve, so for example I probably wouldn't run a file server under bhyve. It will work fine but it wouldn't be all that efficient. Basically disk I/O performance is heavily optimized in FreeBSD via UFS/ZFS and you'll lose some of that by putting in the virtualization layer and most likely NFS on top of that. ---------------------------------------------------------------------- sirrkitt · 2022-01-18 21:36 Ye ---------------------------------------------------------------------- tofazzz · 2022-01-19 01:18 Are you using steamcmd by any chance? ---------------------------------------------------------------------- execerror · 2022-01-19 04:29 No I'm not, sorry