GoSNMPServer icon indicating copy to clipboard operation
GoSNMPServer copied to clipboard

How do I solve the concurrency problem

Open Chien-W opened this issue 3 years ago • 3 comments

I found that after receiving the packet from the network, the code in the warehouse seems to execute each event in a single step. Is there a high concurrency problem in the library? After the network packet is unwrapped, can each event independently open a coroutine to complete the logic of data acquisition in its own business and then return to the other party?

Chien-W avatar Sep 23 '22 06:09 Chien-W

Currently, the server runs under a single coroutine, so there may be a certain bottleneck in busy traffic.

The server itself is completely stateless, so you can reroute traffic to other coroutines to improve the ability to handle traffic.

As a rule of thumb, most of the CPU consumption will be in OID computation (MIB library).

slayercat avatar Sep 23 '22 09:09 slayercat

Hello, that is to say, I need to improve the ability to handle traffic, so I can only modify your library and add coroutines to accelerate the processing of business logic. Your library does not do coroutine forwarding, right?

Chien-W avatar Sep 23 '22 09:09 Chien-W

Thank you for ask, and I would appreciate it if you would like to contribute your implementation.

slayercat avatar Sep 26 '22 09:09 slayercat

I added a simple coroutine pool to ensure coroutine processing of transactions. I tested it a little and it seems to be fine. I'm not sure if it triggers any special bugs.

Chien-W avatar Nov 16 '22 08:11 Chien-W

Thank you very much for your contribution. I have carefully considered it, but I still believe that handling concurrency through multiple Goroutines in Golang is the responsibility of the library's users. Therefore, I regret to inform you that I cannot accept this modification.

If you have any feedback or suggestions, or if you would like to provide a demo or sample program, please feel free to engage in further discussion.

slayercat avatar Oct 19 '23 07:10 slayercat