Target URL Load Balancing in Docker Swarm environment


I have a Tyk gateway in a swarm env (1 manager with tyk, 2 workers).
In the workers I have a microservice on both (1 ms instance in each worker)

An overlay network permits the communications between gateway and microservices.

Then an API is defined using, in target url, the microservice name in the form


All works if I execute

curl http://microservice/api

INSIDE the tyk gateway container: Swarm correctly applies load balancing, calling different ms each time.

But when I call the gateway thru the API, only one ms is called.

BUT if I wait 30 seconds before to re-call the API, then the second ms is called.

I could understand that this 30 seconds retain could be useful to maintain an open connection to the ms endpoint, but the same behavior still occurs if I call the API from another client … but also in this case the same ms is called until … 30 seconds.

So: this 30 seconds policy is managed by Tyk or by other SO layer (DNS cache ?). I suppose is a Tik logic because the test with Curl (inside the gateway container) works without issue.

How can I optimize Tyk in order to call different ms (and still maintains an open connection) ?



You would benefit from talking to one of the Tyk engineers about this. Do you hold a paid licence? If so you can post to the Support Helpdesk rather than rely on the community forum.

If not, drop an email to [email protected] Tyk .io with some more info on your use-case and plans for using Tyk and one of the team should get back to you.