Uplink vs server module

Hello I would like to know what are the pros and cons of using uplink vs the server module that is available.

I understand that the uplink api allows for local database access and that is definitely of enormous value. But will the function call in uplink run slower? Will the application allow running large python scripts from my local machine?

When calling functions in the server module you have restrictions in how long operations can perform, i.e. how long a script can run. This means that processes handed over to the server module can time out before they are done. Since many processes should be handed over to the server module for security reasons risk of time outs should be thought into what operations your functions do.
That being said the server module can handle a lot and with a paid subscription it is my understanding that you can contact pro-support@anvil.works and extend the time that processes can run. So in most use cases the server module should suffice. The great part about the server module is that it is ready all the time and you don’t have to worry about it going down or being unavailable when the client/user calls a function it should handle.

Anvil uplink on the other hand will easily run on a computer/server that you have to maintain and keep an eye on. It requires more effort to make sure that the script containing the Anvil Uplink code is constantly running - otherwise functions calls to functions in the Uplink script can’t be executed and receive/return values from/to the client. I have played around with the uplink (using raspberry pi and more massive hardware) and file transfer speeds and processing of scripts from an Uplink server on a raspberry pi can be instantaneous. The Uplink works great but I have had some fallouts (lost connections) but this is mainly my own fault, since this should be overcome be setting up the computer the re-run the python script containing the Uplink code if it fails. Since Uplink uses ressources from the local computer it should be able to run as long as you require - no time outs here. In fact it is advisable to run ressource hungry through an Uplink.

3 Likes

Exactly the information I needed. Thanks!

Just wanted to throw in my tuppence. The short version is that server modules are a lot simpler and easier to use, so if you’re not sure, you should start with server modules, then move code to the uplink only when you need to.

Server modules:

Advantages:

  • No setup necessary (they Just Work)
  • They are part of your app. For example:
    • Unified version control - server and client are saved together, rollback both at the same time, publish both at the same time, etc.
    • Autocomplete - because both server and client code are in the Anvil editor, it knows what you pass into (and return from) each server function. (Watch my talk at PyCon UK about how this works!)
    • Your server functions can share Modules with client code.

Disadvantages:

  • Only runs while you are calling a server function
  • CPU/memory/time limits

Uplink:

Advantages:

  • Your code can run anywhere (on an IoT device, in your data centre, even as part of another app)
  • You have complete control of the execution environment (install whatever modules you like, run it on whatever hardware you like)
  • You control what data touches Anvil’s infrastructure (eg if your Uplink can see sensitive data that must not be accessible outside your network, you can still perform non-sensitive queries over the Uplink. Of course, if you have requirements like these you should really be looking at an on-site Anvil installation.)

Disadvantages:

  • You are responsible for setting up the environment in which it runs, doing security updates, etc
  • You are responsible for making sure that your uplink code stays running 24/7 (devops-y stuff)
  • The code isn’t part of your Anvil app. (This means you are responsible for keeping your Uplink code in sync with your Anvil app, and doing your own version control, managing development & published environments, etc)
2 Likes

I have a follow up question regarding how the Uplink connection works between client and Uplink connected server.
@meredydd could you briefly explain what happens when a client calls a server function on a Uplink server. Is the datatransfer setup directly between client and Uplink server after user verificarion etc. on Anvils server module? Or will the data be served to the client by passing it through Anvils server module?

1 Like

The client makes no distinction as to the location of the function in the server call. It will behave the same on an uplink server function as it would on an inbuilt server function (ie it’s RPC over websockets : https://anvil.works/doc/index.html#server-communication)

1 Like

So that means that sensitive information can indeed be shared with the client via Uplink code with the certainly the it is not “seen” by others, e.g. Anvil’s servers in the transfer?

1 Like

I believe so but maybe Anvil Central can confirm for certain.

(speculation edit) - actually, whilst the process is invisible to the client, the uplinked server is connected to the Anvil back end. The client probably doesn’t connect straight to the uplinked server so in that respect the data does pass through the Anvil server I would think. Whether it stays encrypted until it gets to the client is one for them - I guess yes :slight_smile:

1 Like

Just to clarify: Data transferred between uplink and client is secure between uplink and Anvil servers, and secure between Anvil servers and client, but it does not remain encrypted while passing through our servers, it moves between the two SSL-encrypted websockets “in the clear”. If you need complete control of end-to-end security, you would need an on-site installation.

Please contact us if this is something you would like to discuss further.

I hope that helps to clarify things!

3 Likes