1

I need to consume several APIs concurrently. In order to do that I decided to containerize each API client code and manage them using Kubernetes. Some of those APIs need to be "walked". They basically have this one endpoint from which you get more endpoints and so on. These "trees" are not that deep, but are constantly changing so hard coding them is not an option. Main challenge is limiting the number of open TCP connections. If I just spawn a goroutine as soon as I get the endpoints program will die because of too many open file descriptors. So the obvious solution is to implement a worker pool. The question is how big should it be?

As far as my understanding of these technologies goes, whole Kubernetes cluster has it's own limit of open TCP connections, so the sum of connections on each container should not exceed it. And I should also be able to set maximum number of TCP connections for Docker containers. I think that somehow getting the system limit and then making a worker pool of that size makes sense.

3
  • I think from the standpoint of your container, the open file connections limitation should be only in your pod. Your API design appears as though it would be fragile. Do you have any idea on the average number of APIs that have to be "walked"? Commented Sep 15, 2021 at 22:09
  • @BerinLoritsch It is not my API that I have to consume unfortunately. Yes, each API client has it's own container and works on one API. Commented Sep 16, 2021 at 7:33
  • This sounds like client connections not properly closed. Can you show us some example code? Or is it possible that you create a new client per request? Commented Apr 24 at 22:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.