Trouble in deploying streamlit with NGINX load balancer

Recently I got aware of the fact that streamlit natively runs on a single core and that’s a big problem. In order to circumvent the problem I thought of creating multiple docker containers each allowed to use a particular cpu core (by using cpuset argument of docker) and then put a nginx load balancer container in front to load balance traffic into the underlying streamlit containers . MI started out the deployment code in my local , I created 2 container for streamlit and a third container for nginx. For the time being I kept cpu share out of the equation just to test if everything is working as expected. Full disclosure , I know nothing about Nginx . I took some of the nginx configuration codes from the internet

I don’t see any error . What I see is the streamlit page hanging up on “Please wait” till the connection is lost. app1 writes “I’m app1” and app2 writes “I’m app2” … (What a revelation right !!! :stuck_out_tongue: )

The file structure

Dockerfile for each app

Streamlit config.toml

Below are all the sections and options you can have in ~/.streamlit/config.toml.


Whether to enable st.cache.

Default: true

caching = true

If false, makes your Streamlit script not draw to a Streamlit app.

Default: true

displayEnabled = true


Allows you to type a variable or string by itself in a single line of Python code to write it to the app.

Default: true

magicEnabled = true

Install a Python tracer to allow you to stop or pause your script at any point and introspect it. As a side-effect, this slows down your script’s execution.

Default: false

installTracer = false

Sets the MPLBACKEND environment variable to Agg inside Streamlit to prevent Python crashing.

Default: true

fixMatplotlib = true


List of folders that should not be watched for changes. Relative paths will be taken as relative to the current working directory.

Example: [‘/home/user1/env’, ‘relative/path/to/folder’]


folderWatchBlacklist = [‘’]

If false, will attempt to open a browser window on start.

Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) server.liveSave is set.

headless = true

Automatically rerun script when the file is modified on disk.

Default: false

runOnSave = false

The port where the server will listen for client and browser connections.

Default: 8501

port = 8501

Enables support for Cross-Origin Request Sharing, for added security.

Default: true

enableCORS = true


Internet address of the server server that the browser should connect to. Can be IP address or DNS name.

Default: ‘localhost’

serverAddress = “”

Whether to send usage statistics to Streamlit.

Default: true

gatherUsageStats = true

Port that the browser should use to connect to the server when in liveSave mode.

Default: whatever value is set in server.port.

serverPort = 8501

Dockerfile for nginx

Nginx config

Docker compose

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