I could use some advice. I have a simple Dash plotly app. I’m pulling in CSV files (each one is about 300kb, 5 total, but one at a time based on user selection) and rendering a few charts.
On my local machine, the app is running fast and smooth.
When I deploy to fly, I’m seeing significant delays in rendering when I switch from one data file to another. As I filter down, the data set gets smaller and smaller, so, the latency isn’t as noticeable.
Reduced file size. I reduced sizes from about 1.5mb to 350kb for each file. That sped things up a bit.
I attempted to use flask-caching. But, it actually slowed things down. Latency went from 11s to 15s. I believe it was correctly implemented.
serve_locally=True, to ensure I’m not making any external dash resource requests.
Increased server resources. Yep, tried increasing RAM and CPUs. Zero impact.
I noticed in my Sources (browser dev tools) that I have a full dash_renderer directory structure full of dash components but I only have a minified JS file in a dash_renderer/build directory on the server. I was wondering if this is a smaller deployment of Dash and I’m somehow having to pull assets from another server. I don’t know.
I don’t think it’s a hardware issue. 1.5mb isn’t a lot of data and Fly runs on NVMe (iirc.)
I think the issue lies in your final point - are you building/deploying a production build of your app? It looks like you have some unrelated deps that’s slogging your app.
I’m not familiar w/ Dash plotly, but when I go to their docs: https://dash.plotly.com/ the site takes a couple seconds to load… not a good first impression (even if it’s unrelated to your issue)
Even if their site is slow AND I’m pulling something from it (I can’t see anything coming in externally), then I would see the slowdown on my local deployment as well.
The only thing I can think of it is that the deployment package on fly is somehow different than how my server is running locally. I can see that the files and directory structure are very different. But, I’m not sure how to replicate what I have locally to fly. So, maybe it’s something having to do with how fly provisions a dash deployment.
Here it is. I tried to run with gunicorn, but that didn’t help. I did some additional tests and found that adding more charts to my app linearly increases the load time.
# Use the official Python base image
FROM python:3.9.7-bullseye
# Set the working directory
WORKDIR /app
# Copy your application code and the tools directory into the container
COPY ./viewer /app/viewer
# COPY ./data /app/data
COPY ./tools /app/tools
# Upgrade pip
RUN python -m pip install --upgrade pip
# Install your project's dependencies
COPY ./app.py /app/app.py
COPY ./requirements.txt /app/requirements.txt
RUN python -m pip install -r requirements.txt
# Expose the port your Dash application will run on
EXPOSE 8050
# Define the entry point
ENTRYPOINT ["python", "/app/app.py", "--server.port=8050", "--server.address=0.0.0.0"]
# CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8080", "app:server"]