Multi go instance share one public channel

1/3/2019

I have an implementation about a channel which will keep there are an only limited number of tasks(20) in this channel due to some performance issue. (The performance issue is from an outside system, this system can not handle more than 20 tasks at the same time).

Now I want to move this logic to a microservice on Kubernetes, the problem is that the replica of pod number will change to an unknown number. So I cannot set the channel length to a specified number to control the total number. Is there a way to cover this case that I can use one public channel for multi go instance? Or some other lights about this case? Thanks.

\========================supplementary instruction=======================

I have an api in my microservice, which will call an outside system api to handle some operations. The outside system api can only handle 20 concurrency and currently I can not fix it because it is out of my control. So I implemented a channel in my project(single instance) which will handle this case. For example, if 30 request come in at the same time, I will put 20 of them to the channel and 10 request waiting. If the request in the channel completed one by one and the left 10 request will go to the channel one by one. Now comes to the multi instance case and I encountered this problem.

-- yangyang
go
kubernetes

0 Answers