So, I’m in the early stages of rolling out an app to a client that is external to our organisation, which means I can no longer have direct control over the users
At first, I will have no issue with that app running on the hosted Anvil runtime. The app will be used for only a few hours a week to run maybe 50 or so server calls
As I expand this system out, I am starting to looking into the different solutions that exist with hosting an Anvil app. I obviously want some amount of redundancy, as well as keeping costs in check. I’d want it to be at least as performant as the hosted version of Anvil
While this will be the first self hosted/managed Anvil app, and also the first external web service that I would be deploying (besides Mongo Atlas, if that counts), it definitely won’t be the last. In the future, I will have the need to host other Anvil apps, as well as VMs for running Uplinks and a variety of other services (self-hosted Mongo, git server etc)
What are people using, what are costs, any tutorials or guides that may lead me in the right direction. I also wanna be able to monitor these sorts of services, so any advice here is great. As a current sole developer, I’m looking to spend as little time on things like configuring deployments and such. Having a single, large VM that runs a bunch of Docker containers would be fine, but performance and failover is usually the issue here
Just looking to start a discussion on this topic and pick some brains
I have the dedicated plan, which means everything runs on my 2-core aws vm, the database limit is the vm drive size, I have sql access, everything is managed by the Anvil team. By everything I mean I don’t even know and don’t want to know how to access that vm, they set it up for me, they will take care of restoring the web server, apps and database in case of failure.
If the traffic will increase, I will increase the number of cores, but for now 2 is just fine for the 50ish internal and occasional external daily users.
Our plan includes support both to ensure smooth service and a few monthly questions. It may seem a little expensive, but it’s one single bill and allows me to think only python and sleep peacefully.
This is not a complete answer to your question, but I often split my front end and back end between hosted at Anvil (front end) and uplink code running on digitalocean.com and linode.com.
So, taking the back end first, you could have multiple $10 (or even $5) VMs each running the same uplink scripts for all backend functionality. If two uplink scripts register the same function name, anvil will choose which one to send to (not sure if it load balances or just picks one randomly or round robin). This gives you some form of redundancy. You can then connect to any other service/database/whatever you desire. Both hosts allow you to make snapshots of a server, so once one is configured and working, make a snapshot and fire up the others from that and they’ll be ready out of the box with minimal (if any) further config required.
The front end - you could run the opensource anvil runtime on another VM (see @owen.campbell excellent tool for deploying this - Amoni, or you could run docker). I don’t do this myself yet, but I will have to shortly. I’m not sure how you would get failover for this, but my thought is some form of haproxy (heartbeat) arrangement to swap IPs betwen servers on failure. Not super simple but there are plenty of tutorials.
The uplink VMs could talk to the anvil runtime over private IPs (both DO and Linode have public and private IPs), so no public IP round trips (though I suspect traffic using the public IPs between two VMs in the same datacentre would probably never see the outside world either).
Oh, right, the uplink. I also have 3 identical machines that run the same few uplink scripts each. The scripts manage long running addins in excel, cad, cam, notes and other software that only run on windows (not on windows server) with a user logged in and may require old usb hardlock keys. So they are victims of automatic updates that reboot the machine and ask for questions about the configuration of whatever has been updated or even newly installed. Yay.
Most of the addins managed by the uplink scripts can only have one instance running at the same time, so the uplink attaches the machine name to the name of the registered functions, so the apps can make sure that the a function is not called on a machine that is busy. My “load balancing” always use the first machine if its not busy, otherwise uses the second, etc. If they all are busy it waits, sometimes for hours.
Sometimes one of them is down for a weekend and the other two take the load. The day I need more, I can just duplicate one of them, change its name and it will work automatically.
From everything I’ve seen, cloud services are expensive compared to hosting like Best Unmanaged VPS Web Hosting Services | A2 Hosting. 36 months of 4 cores, 4GB RAM, 450GB SSD HD storage, and 4TB data transfer is $9.99 per month, and you just install/run software on it using secure shell (as if you’re using the command line on a local machine) - no docker or other heavy infrastructure/deployment tools required.
We’re hosting the anvil-runtime in a podman container on Debian 11 on a linode 4-core shared VM. Another container on the same host is running PostgreSQL 15. We’re using nginx on the main VM to route sub-domains to the appropriate container and provide SSL certs using certbot/Let’s Encrypt. We had to overcome some challenges (and still are) mainly with migrating our data from hosted Anvil to discrete data tables and the occasionally OOM JVM error that takes things offline. I’m not 100% happy with the solution yet and there are many other items that you need to consider/account for: proper backups/recovery, log monitoring, uptime monitoring, etc.
It would be helpful if there was more sharing about self-hosted configurations and solutions (maybe in a new sub-forum?). We still have several open questions…