Hey everyone! I'm trying to run my Next.js application with Docker Swarm, but I've noticed it's significantly slower than when I run the container without Swarm. I even tried bypassing the overlay network, but that didn't seem to help. Has anyone else faced this issue, or does anyone know how to optimize Next.js for better performance on Swarm? I appreciate any tips you have!
1 Answer
There shouldn't be anything about Docker Swarm itself that slows down your app. It sounds like you might want to ask, 'What's wrong with my Docker setup?' Without more details, it's tough to pinpoint. I've run Swarm with various applications, including Next.js, and I've never noticed a performance drop. Start by checking if your app is only running on one node and make sure it isn't making unnecessary loopback network calls except to 127.0.0.1.

I think the speed issue might actually come from using the overlay network. I switched to the host network, exposing my Next.js port directly instead of routing through an Nginx container, and that solved my problem.