fast exec task with go and less mem ops
Why we need executor?
Go with goroutine is the best structure, it’s help developer folk a thread easy than other language.
Go have chanel mechanic to connect goroutine(thread) data.
But what problem??
gokeywork folk goroutine but go not commit late time. Then you exact your goroutine can run but you don’t know when? It’s oke fast with small traffic but when server high load you will scare about that, because is slow, and when you create many goroutine is very slow.
waste of time
Second, when you create and release goroutine many time, it’s with increase memory and CPU time of system, Sometime some developer forgot release, It’s can be make app heavy.
waste of resource
How to resolve problem??
This’s my resolver.
dynamicnumber goroutines. Then using
Jobis a unit bring data information to
Workerto process. Worker no need release and you only create 1 time or reset when you update config.
Job bring 2 importance field is:
exectorand you can call them like
exector(param)and get all result and return on
It’s help your app no need create and release goroutine continuity.
Easy to access and using when coding.
- At you know. If you using callback maybe memory leak if you not control bester.
- If buffer chanel full you need wait a little bits for executed job.
Now it’s time you can install lib and experience
go get github.com/teng231/executor