首页 \ 问答 \ 线程池死锁:设计反对或检测(Threadpool Deadlock: designing against or detecting)

线程池死锁:设计反对或检测(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.防止出现问题,但是当另一个开发人员在一年内调整不相关的数字并且无法解决为什么我们在负载下每周锁定一次时,这似乎是一个破解。 我想在设计中解决这个问题。
  • BB' (一个新的线程池)提交了工作。 不起作用,因为这个扇出可能会走多步(我创建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 threadpool B which is used to hold their "owning" threads; aggregation bits of business-logic which might fan out into a handful of requests. Additionally, threads in B occasionally submit bits of work to threadpool B, 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 to B which causes an additional request x' to be submitted to B. Let's also consider B is a fixed thread pool of 50 threads. When 50 requests of type x come in at the same time, all threads in B are used to handle these requests. All of them submit their x1 to B, 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 the x 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 to B', a new threadpool. Doesn't work because this fan-out can potentially go multiple steps (do I create B'', 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
更新时间:2023-07-23 13:07

最满意答案

是的,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.

相关问答

更多
  • 在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.
  • 你应该使用ng2-charts ,它是Angular 2/4的ChartJS包装器。 使用此功能,您可以创建一个简单的圆环图(带有单击事件) ,如下所示: 模板
    这两个框架都与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', []); ...
  • 相关文章

    更多

    最新问答

    更多
  • 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)