每个请求模型的线程能否比非阻塞I / O更快?(Can the thread per request model be faster than non-blocking I/O?)

我记得在2,3年前阅读过一些文章,人们称现代线程库变得如此优秀,以致每个请求线程的服务器不仅比非阻塞服务器更容易编写,而且它们也会更快。 我相信甚至在Java中使用将Java线程映射到pthread的JVM(即Java nio开销超过了上下文切换开销)证明了这一点。

但是现在我看到所有的“尖端”服务器都使用异步库(Java nio,epoll,甚至node.js)。 这是否意味着异步赢了?


I remember 2 or 3 years ago reading a couple articles where people claimed that modern threading libraries were getting so good that thread-per-request servers would not only be easier to write than non-blocking servers but that they'd be faster, too. I believe this was even demonstrated in Java with a JVM that mapped Java threads to pthreads (i.e. the Java nio overhead was more than the context-switching overhead).

But now I see all the "cutting edge" servers use asynchronous libraries (Java nio, epoll, even node.js). Does this mean that async won?


原文:https://stackoverflow.com/questions/4929660
2023-08-09 20:08

满意答案

我不会打折嵌入Web服务器。 我之前用嵌入Jetty的Web Start应用程序完成了此操作。

下载速度非常快,服务器启动后,您可以使用BrowserLauncher立即将您的浏览器驱动到嵌入式服务器,从而驱动您的应用程序。 码头设计为模块化,占地面积小,因此您可以将其裁减为最基本的必需品。


I wouldn't discount embedding a web server. I've done this before with a web start application embedding Jetty.

The download was pretty fast, the server starts up and you can use BrowserLauncher to immediately drive your browser to the embedded server, and hence your application. Jetty is designed to be modular and have a small footprint, so you can probably cut it down to the bare necessities.

相关问答

更多

使用HTML开发桌面应用程序视图,作为Web应用程序(Develop desktop applications view with HTML, as a web application)

我不会打折嵌入Web服务器。 我之前用嵌入Jetty的Web Start应用程序完成了此操作。 下载速度非常快,服务器启动后,您可以使用BrowserLauncher立即将您的浏览器驱动到嵌入式服务器,从而驱动您的应用程序。 码头设计为模块化,占地面积小,因此您可以将其裁减为最基本的必需品。 I wouldn't discount embedding a web server. I've done this before with a web start application embedding...

桌面应用程序中的HTML / CSS / JS(HTML/CSS/JS in desktop applications)

回答最初的问题(在第一段中): 我假设他们选择使用HTML来编写它,以便更轻松地使其跨平台。 To answer the initial question (in your 1st paragraph): I assume they chose to wrote it using HTML as a way to make it cross-platform more easily.

将Web应用程序加载为Windows桌面应用程序的简单/最佳方法?(Simple/Best way to load Web App as Windows Desktop Application?)

一个简单的VB.NET应用程序应该做的伎俩。 只需创建一个新的Windows Froms项目,双击表单,将所有内容标记为: Public Class Form1 '############## Settings ##############' 'Change to your URL Dim url As String = "http://google.de" 'Change to the text the window title should have ...

如何使用HTML / CSS / JavaScript开发桌面应用程序?(How to develop Desktop Apps using HTML/CSS/JavaScript? [closed])

您可以从Titanium开始使用桌面设备。 另外您可以看一下Chromium Embedded Framework 。 它基本上是基于铬的网络浏览器控制。 它是用C ++编写的,所以你可以在你的容器应用程序中执行所有你想要的低级操作系统(咆哮,托盘图标,本地文件访问,COM端口等),然后在html / javascript中使用所有的应用程序逻辑和gui。 它允许您拦截任何http请求,以服务本地资源或执行一些自定义操作。 例如,对http://localapp.com/SetTrayIconSt...

将ASP MVC Web应用程序作为桌面应用程序运行(Running ASP MVC web application as desktop application)

可以按照说明自行承载ASP.NET 5 / MVC 6应用程序 。 也许您可以通过某种安装过程添加快捷方式,以便通过双击运行您的应用程序。 这是一个关于自托管MVC 5与某种黑客攻击的答案。 上述两种解决方案都不需要IIS。 但是,运行桌面应用程序的最佳选择是使用WPF来构建它。 Web的无状态特性使得处理比有状态桌面应用程序更加困难。 无论您选择哪种UI选项,重要的是将业务逻辑与UI分离,以便您可以稍后切换UI而无需太多精力。 It is possible to self-host an ASP...

在离线/桌面应用程序中呈现网页内容(Rendering web content in offline/desktop applications)

你可能真的想看看微软的Windows Presentation Foundation。 网络的工作方式需要很多工作,并将其应用于桌面应用程序开发。 这不完全是HTML / CSS / PHP / JS,但它也不远。 它有一点学习曲线,但标记是基于XML的,所以它主要是学习它的怪癖,当然还有.Net语言和框架(尽管理论上你可以在PHP上使用PHP。网络框架)。 您可能也对Appcelerator Titanium感兴趣,它允许您使用HTML / CSS / JS来构建桌面应用程序。 我不知道桌面开发...

Web应用程序转换为桌面应用程序[关闭](Web Applications Converted To Desktop Applications [closed])

我不鼓励将PHP用作桌面应用程序。 你应该分开2个appliaction。 使用PHP的Web应用程序 使用Java的桌面应用程序(或任何你想要的) 在您的桌面应用程序中,您应该提供一个“日志记录”系统,可以保存用户脱机的所有操作,并在用户上线(或用户需要时)上传到PHP应用程序,以便您可以在数据库中执行这些操作。 I discourage to use PHP as desktop application. You should sepearte the 2 appliaction. Web a...

用HTML / CSS GUI在Ubuntu上开发原生应用程序?(Develop Native Application on Ubuntu with HTML/CSS GUI?)

2011年8月,Ask Ubuntu问到了这个问题。 总之,选项是: SEEDKIT GNOME的JavaScript绑定。 有更多的选择,但这是两个“大牌”。 This was asked on Ask Ubuntu back in August of 2011. In summary, the options are: SeedKit The JavaScript bindings for GNOME. There are more options, but those are the two...

可以将相同的设计模式用于Web以及.net的桌面应用程序(Can same design patterns be used for web as well as desktop applications for .net)

问题确实太开放了,但这是我的两分钱。 当我从ASP.NET Web Forms和MVC开发Web到WinForms开发时,我将与您分享我的经验。 如果您对Web开发有经验,那么使用.NET进入桌面应用程序开发并不是很困难。 由于共享框架,转换非常顺利。 随着您的进步,您将遇到许多与ASP.NET Web窗体的相似之处(尽管大多数只是在表面层面)。 毕竟,这正是微软当时要实现的目标 - 使Web开发更像桌面,并以一种开发人员不必过多思考的方式抽象无状态HTTP客户端 - 服务器通信的细节。它。 这是...

如何使Web应用程序看起来像桌面应用程序?(How to make web applications look exactly like desktop applications? [closed])

你可以使用ExtJs作为前端,php作为后端.ExtJs是一个用于web应用程序的javascript框架。 http://www.sencha.com/products/extjs/ you can use ExtJs for your front end and php as back-end.ExtJs is a javascript framework for web-application. http://www.sencha.com/products/extjs/

相关文章

更多

Hadoop的I/O

1. 数据完整性:任何语言对IO的操作都要保持其数据的完整性。Hadoop当然希望数据在存储和处理中不 ...

Hadoop I/O系统介绍

看过很多Hadoop介绍或者是学习的帖子和文章,发现介绍Hadoop I/O系统的很少。很多文章都会介 ...

Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案

在使用springmvc+freemarker,有可能你会遇到以下异常(如:资源找不到重定向到404的 ...

Hadoop1.0.4 HDFS I/O性能测试

分布式RDF查询引擎的项目需要在节点之间传输中间结果,考虑HDFS可以作为一个备选的传输媒介,于是对H ...

Java中如何用I/O流读取一个Word文档的内容?

BufferedReader br = new BufferedReader(new FileRead ...

引入thread后socket接受不了报文了

不使用线程thread可以正常接受报文,加了后就在recvfrom那里不动了,是怎么回事? usin ...

线程报错 thread

/** * 只能这么写 * 不然 腾讯微博会报Can't create handler inside ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本