线程池死锁:设计反对或检测(Threadpool Deadlock: designing against or detecting)
我希望这不是过分广泛; 我的问题是“如何设计一个具有多个Threadpool的服务,这些服务不会自行死锁?”。
我拥有一个Web服务,可以在单个用户请求中扇出100个线程,以低延迟执行数据聚合。 在我的服务中有许多ExecutorServices包装固定线程池,我需要帮助解决一个有趣的方法,这可能会造成死锁。
我有一个线程池
A
,用于保存发出网络请求的线程,另一个线程池B
,用于保存它们的“拥有”线程; 业务逻辑的聚合位可能会散布到少数请求中。 此外,当聚合可以通过聚合3个更简单的子聚合来完成聚合时,B
线程偶尔会向线程池B
提交一些工作。这种模式就是问题所在。 让我们考虑一个提交给
B
的请求x
样式,这会导致另外一个请求x'
被提交给B
我们还要考虑B
是50个线程的固定线程池。 当x
类型的50个请求同时进入时,B
中的所有线程都用于处理这些请求。 所有这些都将他们的x1
提交给B
,它位于等待线程的队列中。 然后,所有请求的所有处理都处于死锁状态60秒,直到达到超时并且x
请求所有返回异常。我考虑/试过的事情:
- 调整数字。 可以连接的最大用户数为50,
B
线程数为100.防止出现问题,但是当另一个开发人员在一年内调整不相关的数字并且无法解决为什么我们在负载下每周锁定一次时,这似乎是一个破解。 我想在设计中解决这个问题。B
向B'
(一个新的线程池)提交了工作。 不起作用,因为这个扇出可能会走多步(我创建B''
,B'''
,......?)B
没有最大线程。 可能接受,似乎很危险。- 另一个模型(更多回调?)线程不提交并等待相同的工作单元; 而是他们提交工作并向“run-after”池提交“回调”。 这样,没有什么可以在自己的池中等待某些东西。 有先例,这是个好主意吗?
- 将所有线程池折叠在一起并删除最大值?
I hope this isn't overly broad; my question is "How do I design a service with multiple Threadpools which can't deadlock itself?".
I own a web service which fans out to 100s of threads on a single user request, to perform data aggregation with low latency. There are a number of ExecutorServices wrapping fixed-thread pools sprinkled throughout my service, and I need help solving an interesting way this can create deadlock.
I have a threadpool
A
which is used to hold Threads making network requests, and another threadpoolB
which is used to hold their "owning" threads; aggregation bits of business-logic which might fan out into a handful of requests. Additionally, threads inB
occasionally submit bits of work to threadpoolB
, when an aggregation can be done by aggregating 3 simpler sub-aggregations.This pattern is the problem. Let's consider a style of request
x
submitted toB
which causes an additional requestx'
to be submitted toB
. Let's also considerB
is a fixed thread pool of 50 threads. When 50 requests of typex
come in at the same time, all threads inB
are used to handle these requests. All of them submit theirx1
toB
, which sits in the queue waiting for a thread. And then all processing of all requests sits in deadlock for 60 seconds until a timeout is hit and thex
requests all return Exceptions.Things I've considered/tried:
- Tweak numbers. Maximum users who can connect is 50, threads in
B
is 100. Prevents the problem, but seems like a hack that will break when another dev tweaks unrelated numbers in a year and no one can figure out why we lock up once a week under load. I want to solve this in the design.B
submits fanned out work toB'
, a new threadpool. Doesn't work because this fan-out can potentially go multiple steps (do I createB''
,B'''
, ...?)B
has no max threads. Possibly acceptable, seems dangerous.- Another model (more callbackish?) where threads don't submit and wait for the same unit of work; rather they submit work and submit a "callback" into the "run-after" pool. This way nothing can wait for something in its own pool. Is there precedent, is this a good idea?
- Collapse all thread pools together and remove the max?
原文:https://stackoverflow.com/questions/28329682
最满意答案
是的,Angular-nvD3 Charts对于通过Ionic框架制作的移动应用程序来说是最合适和最响应的。我开发了我的Android移动应用程序并显示了一些图表。
Yes, Angular-nvD3 Charts are best suitable and responsive for mobile apps made through the Ionic framework.I have developed my Android mobile app and display some charts.
相关问答
更多-
离子指令VS Angular材料指令与Ionic框架(Ionic directives VS Angular material directives with Ionic Framework)[2022-12-15]
我发现一个名为Materializecss的材质设计css框架。 看起来很有希望 它只是简单的CSS和JavaScript框架。 http://materializecss.com/ 优于其他框架 纯css类,不会与离子指令冲突。 没有性能损失。 在我看到的所有框架中,这是唯一紧跟材料设计规则的框架 几乎准备好了它有大约50多个贡献者是不到6个月的当前版本0.95.3 使用方便。 良好的记录与功能明智的导航。 它几乎具有应用程序所需的所有材料设计功能。 此页面http://materializecss.co ... -
目前,MobileFirst插件支持的Cordova android平台版本是:cordova-android:> = 6.1.2和<7.0 尝试使用命令'cordova platform add android@6.1.2'。 有关详细信息,请参阅此处: https : //mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/sdk/cordova/ Currently the Cordo ...
-
angular-nvd3图表放置在tab-content中时格式错误(angular-nvd3 graphs' bad formatting when placed inside tab-content)[2022-08-12]
经过一番研究,我发现如何纠正这个问题。 这可以使用nvd3的refresh()函数来解决 码: 在html文件中: 1)在导航按钮上添加单击功能- Pie Chart
- Histogram ...
-
在sinAndCos()方法中尝试此代码: //Line chart data should be sent as an array of series objects. return [ [{ values: sin, //values - represents the array of {x,y} data points key: 'Sine Wave', / ...
-
解决方案发布在这里如果有人需要更多deatils,欢迎您问:) :) :) :) :) The solution was posted here If anybody need more deatils, you are welcome to ask :):):):):)
-
是的,Angular-nvD3 Charts对于通过Ionic框架制作的移动应用程序来说是最合适和最响应的。我开发了我的Android移动应用程序并显示了一些图表。 Yes, Angular-nvD3 Charts are best suitable and responsive for mobile apps made through the Ionic framework.I have developed my Android mobile app and display some charts.
-
Ionic中的图表2(Charts in Ionic 2)[2023-12-04]
你应该使用ng2-charts ,它是Angular 2/4的ChartJS包装器。 使用此功能,您可以创建一个简单的圆环图(带有单击事件) ,如下所示: 模板离子框架与Famo.us(Ionic framework vs Famo.us)[2023-08-27]
这两个框架都与AngularJS一起工作,但它们来自不同的方向并有不同的目标。 离子的 建立在AngularJS的基础之上并对其进行扩展,为您提供按钮,网格和其他现成的UI元素,以帮助您真正快速地发布您的移动应用。 AngularJS专注于数据绑定和应用程序的MVC结构,并不关心它是在桌面浏览器还是在移动设备上运行。 Ionic专注于展示您的应用数据,并对AngularJS进行扩展,使其适用于移动设备,并为您提供移动用户期望的设计模式。 由于Ionic位于AngularJS之上,因此如果没有Angular, ...在Ionic框架中包含样式表的方式将具有在模拟器或移动设备中显示图表的缺点。 我正在使用github中的 Ionic框架在Charts上上传一个示例项目。 1.请按照github的readme.md文件中的步骤操作 2.下载所需的文件以运行项目 3.有任何疑问请回复 我认为你的项目的缺点是你包含的css文件的方式 我这样跟着修复。 问题是以下几行: var settingsApp = angular.module('monitoringApp', []); 本来应该: var settingsApp = angular.module('monitoringApp', ['nvd3']); 希望这有助于遇到这个非常微妙的错误的其他人。 Fixed it. Problem was the following line: var settingsApp = angular.module('monitoringApp', []); ...相关文章
更多- 大家帮忙分析mysql的死锁问题[根据下面的innodb status信息]
- Solr4.8.0源码分析(3)之index的线程池管理
- threadpool-Oceanus配置说明
- LeetCode:Word Break(DP)
- 关于线程的问题
- 关于线程
- 解决solr死锁问题
- APP常用检测
- 多线程问题
- action 线程问题。
最新问答
更多- h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
- 创建一个功能(Create a function)
- 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
- PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
- Qt冻结循环的原因?(Qt freezing cause of the loop?)
- TableView重复youtube-api结果(TableView Repeating youtube-api result)
- 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
- SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
- 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
- 以编程方式创建UITableView(Creating a UITableView Programmatically)
- 如何打破按钮上的生命周期循环(How to break do-while loop on button)
- C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
- 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
- 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
- Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
- 设置kotlin扩展名(Setting a kotlin extension)
- 如何并排放置两个元件?(How to position two elements side by side?)
- 如何在vim中启用python3?(How to enable python3 in vim?)
- 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
- 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
- Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
- dedecms如何安装?
- 在哪儿学计算机最好?
- 学php哪个的书 最好,本人菜鸟
- 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
- 如何覆盖错误堆栈getter(How to override Error stack getter)
- 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
- USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
- 电脑高中毕业学习去哪里培训
- 正则表达式验证SMTP响应(Regex to validate SMTP Responses)