I noticed that my very simple server calls (e.g. just return an int) had really high latency, like 2-3 seconds. I’m trying to find out why and get that down to an acceptable level. I’ve probably read all forum posts concerning latency and server optimization but I’m really just trying to call a function like this:
@anvil.server.callable def get_int(): return 7
The only imports in my server module are
from anvil.tables import app_tables import anvil.server
I call this from the client like this:
def button_1_click(self, **event_args): """This method is called when the button is clicked""" start = datetime.datetime.now() number = anvil.server.call_s('get_int') print('got number', number, datetime.datetime.now() - start)
My app is making no other server calls and has no background tasks. When I run this app, the call usually takes between 1.5 and 2 seconds, which is obviously very slow. Interestingly, when I created a new app, and copy-pasted the exact same code on both client and server side, it works much faster, with timings around 0.3 seconds.
What could explain the difference in the latency while running the exact same code on two different apps?