Slow responses from a web app in swarm cluster

Hello,
I have some kind of a problem with my docker set-up.
Here is the case:
I have a web-app (java spring-boot). The app servers JSON
I also have angular app which calls this API.

The problem i see, is that the response times are almost double when the app is running inside the swarm cluster.

If the app is started in stand-alone docker container, it works fine(almost the same as when started on the command line w/o docker at all)

BUT
When the app is running as a service in swarm cluster, my response times are almost double compared to the stand-alone app and stand-alone docker container.
The application is 100% the same in stand-alone and in swarm mode(one and the same JAR file)

The response sizes vary from ~3MB to few KB. The responses are slow even with very small response sizes…

From what i see/understand, the difference is the network type. In stand-alone docker container it is bridge, and in swarm mode it is overlay.

For not this is a show stopper for me as the responses in swarm mode exceed ~750ms compared to ~400ms in stand-alone mode.

Has anyone had this problem ?
Any ideas what can i do to solve it ?

ı definetly having same issue one angular app and one aspnet 4.5 web api . my resposes are too slow :frowning: have you fixed this issue or found a workaround for this ?

When you publish a port in swarm, not only the additional overhead for the overlay network needs to be considered, but also the overhead for the ingress routing mesh.

If you don’t need the routing mesh, you can try to bypass it:

ports:
  - target: 80
    published: 8080
    protocol: tcp
    mode: host

see: https://docs.docker.com/compose/compose-file/#long-syntax-1

If you don’t rely on multi-container on multi-host communication, you can even skip the overlay network:

version: "3.7"
services:
  web:
    networks:
      hostnet: {}

networks:
  hostnet:
    external: true
    name: host

see: https://docs.docker.com/compose/compose-file/#host-or-none