What I’m trying to do:
Understand the tradeoffs of using run_app_via_uplink, versus other methods of running my Server code, so I can decide whether it’s something I would want to use.
It isn’t listed in Documentation search.
It pops up in a lot of Forum messages, but they’re on a variety of topics. Topic titles vary widely, and seem to have little or nothing to do with run_app_via_uplink.
What I’ve gathered so far (which might be incorrect), is that anyone with Anvil Uplink installed can run their entire Server program locally, on a single PC, without a full install of Anvil Server.
The code runs as an Uplink program, using anvil.server.wait_forever(). Consequences to this:
- The instance stays running, as it would with Persistent Server.
- Hence global variables are retained between calls.
- This can be great for performance.
- However, because each incoming call starts in its own thread, any number of calls may be running simultaneously. If use of shared global state (including the file system) is not sufficiently disciplined, this can create race conditions that are very hard to find, reproduce, and debug.
- Hence global variables are retained between calls.
- That instance can easily access PC-local resources, that a regular Server program cannot.
- That instance can crash, and there’s nothing built in to Uplink to restart it. In that case, calls would revert to being serviced by instances running in Anvil’s servers (or by any additional instances you’ve started).
- All calls and return values are still routed through Anvil’s servers, so there might be an extra network hop, i.e., between your Uplinked server code and Anvil. If you’re on a different continent, that might be significant.
- Database operations still take place remotely, on Anvil’s servers.
- If the instance is running inside an IDE, the IDE’s breakpoints may work.
- You can run multiple instances simultaneously, and Anvil’s servers will attempt to load-balance the calls. This does not necessarily mean that all of a Client’s calls will be routed to the same instance.
Am I missing anything?