I’ve been seeing poor runtime performance with my Bokeh application. After seeing bokeh version >0.12.10 incredibly slow, and noticing that my Console is giving me a lot of warnings about layout computes taking a long time, I decided to try using Bootstrap to layout the application, embedding individual Bokeh components into it.
This greatly improved the runtime performance. However, the loading time of the website is now quite abysmal. Running Chrome’s Lighthouse Audit (Optimize website speed - Chrome Developers), I see that the issue is the initial server response time. Basically, it’s taking a long time for the server to deliver the HTML page.
In debugging the issue, I’ve found that this embedding method works well when there are only a few Bokeh components, but it scales poorly as the number of Bokeh components increases, getting very slow once there are a few hundred components (and in my application, there are indeed a few hundred components).
I illustrate this issue here: GitHub - EfremBraun/bokeh-scaling-demo. I took the Movies example from https://github.com/bokeh/bokeh/tree/branch-3.0/examples/app/movies and made some changes. original-0
was taken directly from the example, with 0 new widgets added, original-100
added 100 additional Slider widgets, and original-200
added 200 additional Slider widgets. embed-0
is the original example, but using embedding/Bootstrap for the display; embed-100
took that and added 100 additional Slider widgets, and embed-200
added 200 additional Slider widgets.
When I run bokeh serve original-0
, open the application in a Chrome Incognito tab, and run the Lighthouse Audit, I get a 65 performance score. bokeh serve original-100
stays at 65, and bokeh serve original-200
finally goes down to 64. However, while bokeh serve embed-0
gets a 62 performance score (already lower than the original page, though not so bad), bokeh serve embed-100
gets a 60, and bokeh serve original-200
gets a 56, and the page load time is noticeably slower.
Any idea why this is happening and if there’s a way around this?