Coder Social home page Coder Social logo

Comments (4)

hi-wayne avatar hi-wayne commented on July 23, 2024

consumer使用pull的方式去拉取数据
你拉取到数据后,扔给threadpool去处理
全部扔入threadpool后,consumer进行下一次拉取数据操作
看你的描述,没办法搞清楚,你具体每条信息消费的耗时,所以没办法衡量扔入threadpool是否会比直接处理消息,吞吐更快一些。

还有getExecutor()部分应该每次都返回是同一个threadpool实例,不需要每次new一个,没看到你贴这部分代码,不是太清楚你如何实现的。

from metamorphosis.

killme2008 avatar killme2008 commented on July 23, 2024

@rottle

线程池并不能提高单个消息的处理速度,原来是什么速度,现在还是什么速度,你想想是不是这样。

线程池的意义在于可以不阻塞消息接受的线程,提高消息处理的吞吐量。

from metamorphosis.

rottle avatar rottle commented on July 23, 2024

嗯。非常谢谢两位的回复。
可能我的描述不太清楚。举个例子吧。比如一次拉取6000条消息,getExecutor(){return null}是采用单线程处理,共耗时300秒,即每条消息耗时50ms;同样,一次拉取6000条消息,如果通过getExecutor(){ return pool},即返回一个线程池(固定大小8),共耗时应该小于300S,可能为200S。基于上述,消息吞吐量应该是提高了。@killme2008 的回复,我清楚意思。
我的问题是:我经过测试发现,上述情况,6000条的处理时间,在线程池中基本还是300S,按道理总耗时应该更少的???????

from metamorphosis.

killme2008 avatar killme2008 commented on July 23, 2024

@rottle
return
null不是单线程处理,默认是CPU个数的线程做消息拉取,你在拉取线程跑,那就是至少cpu个线程在处理消息。这个可以通过ConsumerConfig.fetchRunnerCount设置。也就是拉取本身就是多线程的。

你的机器如果是4核,8核的,那跟你创建一个线程池跑不会有太大区别。也取决于你的任务类型,如果是CPU密集型,更多线程也不会带来提升,甚至可能下降。

在 2013年3月21日下午3:56,rottle [email protected]写道:

嗯。非常谢谢两位的回复。
可能我的描述不太清楚。举个例子吧。比如一次拉取6000条消息,getExecutor(){return
null}是采用单线程处理,共耗时300秒,即每条消息耗时50ms;同样,一次拉取6000条消息,如果通过getExecutor(){ return
pool},即返回一个线程池(固定大小8),共耗时应该小于300S,可能为200S。基于上述,消息吞吐量应该是提高了。@killme2008https://github.com/killme2008的回复,我清楚意思。
我的问题是:我经过测试发现,上述情况,6000条的处理时间,在线程池中基本还是300S,按道理总耗时应该更少的???????


Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-15223631
.

庄晓丹
Email: [email protected] [email protected]
Site: http://fnil.net
Twitter: @killme2008

from metamorphosis.

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.