Plotly figure_factory is slow

Admin note: Moved into its own thread because it appears to be describing a more general issue

I am encountering a similar issue to when I was using matplotlib charts from a server-side function: the figure being returned is taking 2-3 seconds to be displayed on the client side. any suggestions on how to shorten this time?

Hi @boruchwoolstone,

Server functions are pretty snappy over here! Can you provide a Clone link for an app that demonstrates this problem?

https://anvil.works/build#clone:EFNZECOSZFEW4GUS=N6RUXZY4UU6RWOGFVTWRK43E

Thanks for the clone link – I’ve taken a look, and it spends nearly all that time importing plotly.figure_factory. I just tried it on my own desktop and confirmed – that library is genuinely slow to load!

I can suggest a couple of ideas for mitigating this issue:

  • Only import plotly.figure_factory in server functions that are going to use it, so loading Plotly doesn’t slow down your other Server Functions.

  • If you are on the Business Plan or higher, you can enable the “Keep server running” option, which keeps your application (and therefore Plotly) loaded persistently after your server call is finished. This means you only have to pay this startup cost once. (I just tried enabling that option on your app – the first time it took several seconds, but the second time was much snappier!)

2 Likes