Bokeh Server Multiple users?

We’ve built our own report server using flask and bokeh servers!

It’s a neat little thing, completely deployed behind an apache reverse proxy, and everything works perfectly.

Except one little problem. The bokeh servers can only talk to one person at a time.

The Flask portion of the app is a platform that serves users to the bokeh servers while the bokeh servers are reports, themselves, executing queries against a database and displaying the results.

here:

How fun is that? Pretty fun.

So anyway, let’s say a user runs this report and it takes 30 seconds to fetch the data. While the query is running, nobody else can open the page.

We’re wondering what we should do about this. It would be great if we could tell bokeh server to be concurrent rather than spin up multiple instances of the same bokeh server.

Anyway, what would you guys suggest?

By the way here’s the route our flask app uses for a report, this should help you get a feel for how we have it setup. (notice we’re using bokeh.embed.server_document):

@app.route('/finance/gl-multiselect')
@verify_login
@verify_access
def finance__gl_multiselect():
    ''' bokeh for Gl multiselect '''
    resp = {
        'script': server_document(
            url='http://localhost:6010/gl_multiselect',
            arguments={...,}
        ),
        'template': 'Flask',
        'report_name': 'gl_multiselect',
    }
    return render_template('report/bokeh.html', **resp)

It’s definitely important to try and avoid long blocking work in the main thread of bokeh event handlers. The user’s guide describes how you can put long running tasks in threads, then update the Bokeh side when those tasks complete:

https://docs.bokeh.org/en/latest/docs/user_guide/server.html#updating-from-threads

https://docs.bokeh.org/en/latest/docs/user_guide/server.html#updating-from-unlocked-callbacks

1 Like