service handles only one socket per core

I am writing a server application using Boost Asio:

  • Server: Running io_service.run() from pool of threads (one thread per core), accepting connections & reading data from sockets is done asynchronously.
  • Client: Each client connects and sends a heavy file (~500MB) to the server.
  • Issue: All Clients are connected to the server (number of clients > number of server cores); io_service handles only one connection/socket per thread while data from other sockets are not processed until one of the processed connections completes.

    I would expect that data from all connected sockets gets processed by the io_service thread pool at a same time?


    What is the expected behavior? Your io_service can only invoke n handlers if you have n threads invoking io_service::run() . If the number of outstanding asynchronous operations is greater than n , their handlers will wait in the io_service queue until a thread is free to invoke them.

    链接地址: http://www.djcxy.com/p/62670.html

    上一篇: 关于boost :: asio :: io

    下一篇: 服务每个核心只处理一个套接字