Coder Social home page Coder Social logo

Comments (5)

Barenboim avatar Barenboim commented on August 16, 2024 1

噢噢,连接复用的原理是有空闲连接就复用,如果没有空闲连接而且并发连接数没有超过最大值(默认200),则发起新连接;达到最大值,则得到EAGAIN错误。你的第一个case是100个请求同时发起,那么很大概率上是并发请求,所以没有办法复用连接。

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

没有道理啊,连接复用非常智能的,每个请求都建立连接是不是对方主动关闭了连接?
task->get_task_seq()可以看到当前任务是连接上的第几次请求。你可以打一下。

from workflow.

wooviet avatar wooviet commented on August 16, 2024

我又测试了一下,以下是一个简单的总结:
前提:访问同一个url,不设置connection字段
结论:
1.一个循环中建立task并start,循环100次,基本上不复用
2.前一个task的回调中创建新的task并start,如此循环5次,复用
3.前一个task的回调中创建新的task,将新的task放到前一个task series中,如此循环5次,复用

前提:访问不同url(服务器地址相同),不设置connection字段
结论:
1.不复用 2.复用 3.复用

from workflow.

wooviet avatar wooviet commented on August 16, 2024

我理解的复用是同一个地址的请求,都应该复用,无论我是在哪个线程发起的请求,但根据测试结果来看,在回调线程中发起下一个请求才是复用的。

from workflow.

wooviet avatar wooviet commented on August 16, 2024

测了一下,确实是这样,感谢! @Barenboim

from workflow.

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.