Coder Social home page Coder Social logo

Comments (15)

lesismal avatar lesismal commented on June 1, 2024

不同IOMod处理方式不同,默认是 IOModNonBlocking,是IO协程池(等同于poller协程,写成数量为NPoller)、逻辑协程池处理所有连接,逻辑协程池size可定制(MessageHandlerPoolSize

IOMod可以看下这里:
https://github.com/lesismal/nbio#different-iomod

from nbio.

ericjing83 avatar ericjing83 commented on June 1, 2024

好的。
请教下,如果用这个库开发一个云服务,有上百万个用户的websocket连接,您建议用哪种IOMod,服务端读消息和推送消息的性能比较高?

from nbio.

lesismal avatar lesismal commented on June 1, 2024

如果持续高在线量的话 IOModNonBlocking 就可以,如果低峰时段在线量不那么大,用 IOModMixed 可以响应延迟略低、更好些

from nbio.

ericjing83 avatar ericjing83 commented on June 1, 2024

好的。
这个库,调用linux操作系统的epoll,是通过cgo吗?还是通过纯的go代码实现的?

from nbio.

lesismal avatar lesismal commented on June 1, 2024

没有使用cgo,所有功能都是纯go的。
也相当于没有三方依赖,只依赖标准库。tls依赖的llib是我自己的库,是基于标准库魔改的代码,由于标准库开源协议不是MIT,所以单独拆到llib里了

from nbio.

ericjing83 avatar ericjing83 commented on June 1, 2024

非常感谢指导。
再请教下,如果上百万个用户连接,有些用户可能比较频繁操作系统,发送请求,另一些用户可能不是很频繁操作。无论间隔多长时间客户端和服务端相互之间没有发送任何消息,我想让服务端始终保持websocket连接。这个库可以保持连接吗?有没有相关的服务端启动参数之类的?

from nbio.

lesismal avatar lesismal commented on June 1, 2024

你的双方不主动关闭就可以保持连接。
为了避免僵尸连接,通常有心跳机制,正常发心跳就可以了,心跳可以参考这里的建议:
lesismal/nbio-examples#12

from nbio.

github-actions avatar github-actions commented on June 1, 2024

This issue is stale because it has been open for 30 days with no activity.

from nbio.

7c0o avatar 7c0o commented on June 1, 2024

不同IOMod处理方式不同,默认是 IOModNonBlocking,是IO协程池(等同于poller协程,写成数量为NPoller)、逻辑协程池处理所有连接,逻辑协程池size可定制(MessageHandlerPoolSize

IOMod可以看下这里: https://github.com/lesismal/nbio#different-iomod

io协程和连接协程有啥区别

from nbio.

lesismal avatar lesismal commented on June 1, 2024

io协程和连接协程有啥区别

io协程是nbio自己的协程池、数量不大、可以自己配置数量
基于标准库的连接每个连接一个协程、在线数大的时候协程数量大

from nbio.

7c0o avatar 7c0o commented on June 1, 2024

io协程和连接协程有啥区别

io协程是nbio自己的协程池、数量不大、可以自己配置数量 基于标准库的连接每个连接一个协程、在线数大的时候协程数量大

能直接在连接协程里面,进行数据库操作等比较耗时的操作吗?现在测试过程发现,在连接协程做耗时的操作 影响用户连接。

from nbio.

lesismal avatar lesismal commented on June 1, 2024

提供下示例代码

from nbio.

lesismal avatar lesismal commented on June 1, 2024

你说的 “连接协程” 是指nbio的处理连接的逻辑协程,还是指基于标准库的每个连接一个协程?
先把术语对齐,然后提供下你的有问题的示例

@7c0o

from nbio.

github-actions avatar github-actions commented on June 1, 2024

This issue is stale because it has been open for 30 days with no activity.

from nbio.

github-actions avatar github-actions commented on June 1, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

from nbio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.