Giter Site home page Giter Site logo

Comments (1)

hoytech avatar hoytech commented on May 23, 2024

Seasocks is an asynchronous server, using the linux-specific epoll() API. There is one thread responsible for managing all events, like reading from the socket, buffering messages, writing to the socket, etc.

If multiple threads could all interact with the socket, then there would need to be locking to protect the data-structures this thread uses, which would increase complexity and decrease performance.

But this typically isn't a problem, since actually sending/receiving messages takes so little resources. Usually it's your own code that you want to run in a separate thread anyway. What you can do is create a worker thread pool that takes requests off a queue. The workers will then do their expensive processing, and push the responses onto another queue, and then wake up the seasocks thread to send the messages.

You can also have multiple processes all accepting connections from the same websocket if you use SO_REUSEPORT.

from seasocks.

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.