What are the performance considerations for using anvil.server.route
from anvil-uplink rather than a server module?
I assume (and may be wrong) that the call to a decorated uplink function goes through the Anvil server anyway, so I assume (and may be wrong) that from the performance point of view, a decorated server function that calls an uplink callable is identical to a decorated uplink function.
Instead of decorating a function in an uplink script I always decorate the function in the server, then call the uplink callable from the server.
I do this not because of performance considerations, but for reliability considerations: the Anvil server is up more than my uplink scripts for two reasons: my uplink server may be down when Anvil is up, and my uplink scripts are always down when Anvil is down. So I put the decorator in a server module that can have some fallback logic in case the uplink fails to respond.
The short answer is “the same as for any other server function served by the uplink”. When a request for your app comes into Anvil, it will make a server call. If you have an uplink for that environment (or a shared one for that app) that has registered a route with the correct name, then the call will be sent to that uplink to execute; otherwise, the call will be sent to your server-side Python environment to execute. This carries additional latency (your uplink is further away than the server-side Python environment), but your uplink code is probably running there for a reason – perhaps you have a ton of compute, or it’s located next to an important database.