Allenxuxu / gev

🚀Gev is a lightweight, fast non-blocking TCP network library / websocket server based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
MIT License
1.73k stars 194 forks source link

Are the writes to socket blocking or non-blocking? #120

Closed indexk09 closed 2 years ago

indexk09 commented 2 years ago

The write to socket here in the websocket broadcast example https://github.com/Allenxuxu/gev/blob/master/example/websocket/main.go#L144 makes a blocking or non blocking system call? If blocking is there anyway to do or advisable to do non-blocking system call for low latency applications?

Allenxuxu commented 2 years ago

It's non blocking call.

indexk09 commented 2 years ago

@Allenxuxu Can you please share some info on how this would make non blocking "system call". Also if is non-blocking system call how do I make sure I don't run into OOM? for example, lets says server is constantly broadcasting/writing at a high speed and clients may not keep up with that speed. wouldn't that result in OOM? if so, how do I prevent it?

Allenxuxu commented 2 years ago

@Allenxuxu Can you please share some info on how this would make non blocking "system call". Also if is non-blocking system call how do I make sure I don't run into OOM? for example, lets says server is constantly broadcasting/writing at a high speed and clients may not keep up with that speed. wouldn't that result in OOM? if so, how do I prevent it?

https://github.com/Allenxuxu/gev/issues/52

look at this