Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running with multiple replicas #1424

Open
ffzzhong opened this issue May 23, 2024 · 6 comments
Open

Running with multiple replicas #1424

ffzzhong opened this issue May 23, 2024 · 6 comments

Comments

@ffzzhong
Copy link

hi, I plan to run miniserve in k8s with multiple replicas behind a nginx ingress controller, in this pattern, multiple replicas make the service more robust and there will be automatic load balancing inside the cluster.

I found if I run only 1 replica, everything works fine, but if I run with multiple replicas, say 2 or 3, then page sometimes rendered without CSS, it throws Failed to load resource: the server responded with a status of 404 () because it's trying to look for the https://my.service.domain/xxxxxxxx static CSS file, I guess this path is only available on one replica but not all of them.

my entrypoint is straightforward and easy, just following the guide, /app/miniserve /data-folder

Am I missing some configuration? as I think it could be a typical use case that running multiple replicas, Any suggestion about how to make it work?

@svenstaro
Copy link
Owner

The static CSS file is inside the binary. It's not a real file and as such should exist in all instances. miniserve is entirely stateless and should as such be an ideal server to run for multiple replicas. I'm actually pretty confused why it would sometimes work and sometimes not.

@ffzzhong
Copy link
Author

@svenstaro
Copy link
Owner

Depending on what the issue and how you run it and how you're accessing it, it might help to use --route-prefix.

@ahti
Copy link
Contributor

ahti commented May 24, 2024

I think this is due to miniserve creating a random route for css and favicon on each launch (config.rs:196...), so different instances disagree on what the route should be. I would suggest switching to a .well-known/miniserve/... route for those.

@ffzzhong
Copy link
Author

@svenstaro actually I had already tried adding the --route-prefix, also configured ingress/livenessprobe/readinessprobe accordingly, the instances launched successfully but still got the same issue
the root cause might be like what @ahti mentioned?

@svenstaro
Copy link
Owner

Yes, that's very likely the cause. I'll look at it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants