Multiple plots, multiple servers?

I have the need to create plots on-demand in my app. That is, user clicks something, the python back-end grabs data, and then a plot is rendered somewhere. The plots are highly interactive, so I wanted to use Bokeh servers to allow for maximum interactivity and performance.

The plots are created as-needed, since the user can generate as many of these plots as they need. However, each plot needs to be rendered to the same page, so I need to be able to get the placeholder js.

I have a few questions on how to approach this scenario:

  1. It seems like the most performant thing to do is call something like “bokeh serve” for each plot. Is this the case?
  2. If so, how can I call this serve command from within a python script to avoid having to use e.g. subprocess?
  3. Once the server is up, how do I interact with it since it’s possible that multiple servers are running at the same time?
    Thanks for any help or direction,

Nick

If you don’t need to update ypur plots each second (e.g. to add new points) but have a fixed set of data I would just reload the page and add a new plot each time.
You could store the info about active plots and its data in the server’s session variable.

···

On Monday, November 14, 2016 at 9:25:58 PM UTC+1, Nicholas Earl wrote:

I have the need to create plots on-demand in my app. That is, user clicks something, the python back-end grabs data, and then a plot is rendered somewhere. The plots are highly interactive, so I wanted to use Bokeh servers to allow for maximum interactivity and performance.

The plots are created as-needed, since the user can generate as many of these plots as they need. However, each plot needs to be rendered to the same page, so I need to be able to get the placeholder js.

I have a few questions on how to approach this scenario:

  1. It seems like the most performant thing to do is call something like “bokeh serve” for each plot. Is this the case?
  2. If so, how can I call this serve command from within a python script to avoid having to use e.g. subprocess?
  3. Once the server is up, how do I interact with it since it’s possible that multiple servers are running at the same time?
    Thanks for any help or direction,

Nick

There's alot of different possible ways to slice this, it's hard to give concrete guidance without getting into specifics. But a few comments.

It's possible to run multiple apps from one "bokeh serve" invocation:

  bokeh serve app1.py app2.py

If you expect to need to "scale out" then running a "bokeh serve" process is recommended.

However, there is also now guidance for embedding a Bokeh server as a library, e.g. directly in side a Flask or Tornado app (or just a standalone "normal" python script):

  http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#embedding-bokeh-server-as-a-library

Which might be preferable to you if you do not want to have to coordinate multiple processes. The examples are intentionally simple, and only demonstrate installing a single app, but the technique could be extended simply enough.

The last question, I am afraid I don't quite understand. Once a Bokeh server is running (either as a separate process, or on an IOLoop you start yourself) then you interact with it by loading sessions from it. This is usually accomplished by:

* embedding the URL to the app in an iframe
* using autoload_server to get a script tag that embeds the app

However it is also possible to use bokeh.client and push_session, etc. to exert finer grained control over sessions. But this is a more sophisticated usage, so I'd advise seeing whether more typical usage patterns cover your needs first.

Regarding the overall architecture, again details matter. It might be that you want one app, that is configurable via HTML request parameters, and shows different things based on those. Or maybe you want a different apps for different things. This is where details are needed.

Thanks,

Bryan

···

On Nov 14, 2016, at 2:25 PM, Nicholas Earl <[email protected]> wrote:

I have the need to create plots on-demand in my app. That is, user clicks something, the python back-end grabs data, and then a plot is rendered somewhere. The plots are highly interactive, so I wanted to use Bokeh servers to allow for maximum interactivity and performance.

The plots are created as-needed, since the user can generate as many of these plots as they need. However, each plot needs to be rendered to the same page, so I need to be able to get the placeholder js.

I have a few questions on how to approach this scenario:
  • It seems like the most performant thing to do is call something like "bokeh serve" for each plot. Is this the case?
  • If so, how can I call this serve command from within a python script to avoid having to use e.g. subprocess?
  • Once the server is up, how do I interact with it since it's possible that multiple servers are running at the same time?
Thanks for any help or direction,

Nick

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/11e380c8-ce78-4cd1-a0f5-c7178b1af874%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.