Server-Client Communication Custom Domain Speeds vs anvil.app speed

Hello Anvil Community,

I have an app deployed with to a custom domain with a dedicated plan with a decent sized dedicated server. We use persistent server.

Has anyone seen slowdowns on custom domains relative to their anvil.app counterpart? If so any tips on how to improve performance on the custom domain?

The Situation
We are in the process of optimizing our client server speeds. Recently, I’ve noticed that our load speeds to our custom domain are about 10x slower then the same environment deployed to a generic anvil.app domain. I’m not sure if this is a recent thing or if I am more sensitive to it now. I can see the same RPC requests on the same computer taking 5-10s instead of 0.2-0.4s. In some ways it almost has the responsiveness prior to having persistent server.

We are planning on deploying some of the other great optimization tips that this community has generated to minimize the number of calls during app start up. Thank you for all the great feedback that you have already provided.

I don’t know if they are related, but often come right after an exceptionally long RPC request. I notice occasionally that I get these postMessages in my browser console:
image

Load from anvil.app:

Load from custom domain:

What I’ve tried and what’s not working:
I’ve tried forcing a rebuild the container.
Creating a new branch and linking the custom domain to that.
Switching environment databases.

UPDATE: Load Timing
custom domain: 17.6s average (13.3s, 17.9s, 21.5s)
anvil.app: 6.7s average (6.9s, 6.4s, 6.8s)

@stucork Do you have any insight into this?
I read through all the threads I could find on Custom Domains and I see your name come up in those threads quite a bit.

Call on anvil.app version of the environment: ~300-350 ms

Same exact call on custom domain: ~6400 ms

Hmmm, it almost seems like ‘persistent server’ isn’t active for my custom packages when on the custom domain. Is that something that is possible?
On the custom domain calls to anvil.user go normal speed, but as soon as I call a custom module with imports a few imports it acts like it is importing those again.

I was able to confirm with print commands that persistent server isn’t functioning on our production deployment at our custom domain. I was able to resolve by:

Detection

  1. Add print command at the front of package to see (@stefano.menci thank you for this trick)
  2. If persistent server is off tons of print lines will populate as you do server calls.

Resolution

  1. Kill all production background tasks
  2. Select production branch (in my case it still showed the Persistent server as being checked). Apparently this doesn’t work if you do this on another branch and then roll production to that commit.
  3. Add a dummy package to trigger a container rebuild (thank you @meredydd).
  4. Check your print commands
2 Likes

I was thinking more about what might have caused this to occur so that it won’t happen again. It looks like my stripe package very recently updated to the latest version. Anvil Team (@stucork @patricia) is there any chance that when a package updates to the latest version that it rebuilds it’s container and doesn’t pull the persistent server settings along with it?

Persistent server turned itself off again right after pushing to production. This hasn’t happened in the last production pushes a week ago using the same method. Fixed using the same fix.
It happened after I used the “Reset Production to this branch”.

@stucork @patricia could you please add this to the bug list for fixing?

Confirmed to happen again when using the Publish-> Change App Version of putting. Corrected using the same method as before.

Hi @FrostLabs,

Thanks so much for posting the results of your (very thorough) investigations here! That’s definitely a bug, and we’ll look into it. I’m glad you found the workaround in the meantime. We’ll be sure to post an update on this thread as soon as we have one.

By the way, repeatedly tagging staff members in Forum threads won’t get an answer any quicker - we keep a close eye on the forum anyway, and we’ll jump in to help when we can. If you’re looking for help with a guaranteed response time, please get in touch to discuss one of our Support Contracts.

[Moved to bug reports]

2 Likes

Thank you daviesian!

Understood, I’ll respect that in the future. Is there a preferred way of users flagging things to get added to bug reports?

Hi @FrostLabs

What you did is exactly right - start a new thread in Q&A and we’ll move it to bug reports once we’ve verified the issue. We especially appreciate it when people investigate and report back as thoroughly as you did, so thanks for that! Hopefully we’ll have an update for you soon.

1 Like