Bokeh server creates same session twice

Hi,

I am running a bokeh application in bokeh server mode (version 2.4.1) with an authentication module. The application retrieves data via SQL and visualizes the data. This works all fine except that when I start a new session, the bokeh server creates the application twice, i.e. I can see from the debug output that the data authentication module, the data retrieval and the visualization get called twice.

Is there any reason which causes the bokeh server to recreate a session?

Some observations I have made during debugging this double creation:

  1. creating the session twice only happens when I use add_next_tick_callback to add one “populate”-callback which adds next_tick_callbacks for data retrieval and visualization.
  2. If I run the methods for data retrieval and visualization directly in the application code, then there is no double creation
  3. When I change the SQL query (add a where clause) then the double creation vanishes, too.
  4. the session id is the same after both sessions have been created.

Hi @christoph123 this behaviour is expected in one specific instance: If you are running multiple Bokeh servers behind a load balancer, and the initial HTTP request and subsequent websocket upgrade land on different processes, this will occur. We suggest turning on session affinity to avoid this, since existing sessions from the HTTP request should be re-used if the websocket connection lands on the same process. Can you comment about your situation? If you are seeing this with a single Bokeh server process that is not expected and it would be helpful to have full instructions to reproduce.

Hi @Bryan,

thank you for your feedback. I am running a single bokeh server process.

I tried to create a simple application to reproduce the issue. Unfortunately, I could not reproduce the issue with this simple application. Apparently, a more complex application is needed to trigger the issue. As soon as I have found such an application code, I will post it here.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.